Skip to content

Commit

Permalink
Add new line at EOF & add license headers
Browse files Browse the repository at this point in the history
  • Loading branch information
dulithsenanayake committed Dec 13, 2022
1 parent 3d5dbe3 commit 9ab1627
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 32 deletions.
2 changes: 1 addition & 1 deletion portals/admin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ RUN echo "$PWD"
RUN npm install
RUN npm run react-prod
EXPOSE 4000
CMD ["npm", "run", "start"]
CMD ["npm", "run", "start"]
2 changes: 1 addition & 1 deletion portals/admin/bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

var app = require('../app');
var debug = require('debug')('apps:server');
// var http = require('http');
const https = require("https");
const fs = require('fs');
/**
Expand Down Expand Up @@ -93,3 +92,4 @@ function onListening() {
: 'port ' + addr.port;
debug('Listening on ' + bind);
}

19 changes: 19 additions & 0 deletions portals/admin/client/src/Apis.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React, { useEffect, useState } from 'react'
import Settings from 'Settings';

Expand Down Expand Up @@ -74,3 +92,4 @@ export default function Apis() {
</div>
)
}

19 changes: 19 additions & 0 deletions portals/admin/client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import * as React from "react";
import { useEffect } from "react";
import { Routes, Route, Link } from "react-router-dom";
Expand Down Expand Up @@ -84,3 +102,4 @@ function NoMatch() {
</div>
);
}

20 changes: 19 additions & 1 deletion portals/admin/client/src/auth/LoginButton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React from "react";

const LoginButton = () => {
Expand All @@ -7,4 +25,4 @@ const LoginButton = () => {
</button>;
};

export default LoginButton;
export default LoginButton;
20 changes: 19 additions & 1 deletion portals/admin/client/src/auth/LogoutButton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React from "react";
import { sendSignOutRequest } from "./sign-out";
import { endAuthenticatedSession } from "./session";
Expand All @@ -16,4 +34,4 @@ const LogoutButton = () => {
);
};

export default LogoutButton;
export default LogoutButton;
20 changes: 19 additions & 1 deletion portals/admin/client/src/auth/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import Base64 from "crypto-js/enc-base64";
import WordArray from "crypto-js/lib-typedarrays";
import sha256 from "crypto-js/sha256";
Expand Down Expand Up @@ -82,4 +100,4 @@ export const isValidIdToken = (idToken: any, jwk: any, clientID: string, issuer:
gracePeriod: 3600,
iss: [issuer]
});
};
};
33 changes: 19 additions & 14 deletions portals/admin/client/src/auth/sign-in.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { getCodeVerifier, getCodeChallenge, getJWKForTheIdToken, isValidIdToken } from './crypto';
import { OIDCRequestParamsInterface } from '../models/oidc-request-params';
import { TokenResponseInterface } from '../models/token-response';
Expand Down Expand Up @@ -137,20 +155,6 @@ export const sendTokenRequest = (
}
return Promise.reject(new Error("Invalid id_token in the token response: " + response.data.id_token));
});

// const body = [];
// body.push(`client_id=${requestParams.clientId}`);
// body.push(`scope=apim:api_manage apim:subscription_manage apim:tier_manage apim:admin`);
// body.push("grant_type=urn:ietf:params:oauth:grant-type:token-exchange");
// body.push(`subject_token_type=urn:ietf:params:oauth:token-type:jwt`);
// body.push(`requested_token_type=urn:ietf:params:oauth:token-type:jwt`);
// body.push(`subject_token=${response.data.access_token}`);
// body.push(`org_handle=organization`);
// return axios.post(stsEndoint, body.join("&"))
// .then((response: any) => {
// window.sessionStorage.setItem("exchanged_token", response.data.access_token);
// window.location.href = "https://localhost:4000/users";
// });
}).catch((error: any) => {
return Promise.reject(error);
});
Expand Down Expand Up @@ -207,3 +211,4 @@ export const sendRefreshTokenRequest = (
return Promise.reject(error);
});
};

18 changes: 18 additions & 0 deletions portals/admin/client/src/constants/token.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

interface ServiceResourcesType {
jwks: string;
token: string;
Expand Down
2 changes: 1 addition & 1 deletion portals/admin/client/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ root.render(
<BrowserRouter >
<App />
</BrowserRouter>
);
);
21 changes: 19 additions & 2 deletions portals/admin/client/src/models/oidc-request-params.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
/*
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* OIDC request parameters.
*/
export interface OIDCRequestParamsInterface {
clientId: string;
// redirectUri: string;
scope: string;
state: string;
serverOrigin: string;
}
}
2 changes: 1 addition & 1 deletion portals/admin/client/src/models/token-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
expiresIn: string;
scope: string;
tokenType: string;
}
}
1 change: 1 addition & 0 deletions portals/admin/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ router.get('/', function(req, res, next) {
});

module.exports = router;

2 changes: 1 addition & 1 deletion portals/admin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
}
}
}
9 changes: 1 addition & 8 deletions portals/admin/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');

module.exports = (env) => {
// const env = dotenv.config().parsed;

// // reduce it to a nice object, the same as before
// const envKeys = Object.keys(env).reduce((prev, next) => {
// prev[`process.env.${next}`] = JSON.stringify(env[next]);
// return prev;
// }, {});
const devConfig = {
entry: {
main: path.resolve(__dirname, './client/src/index.jsx'),
Expand Down Expand Up @@ -75,4 +68,4 @@ module.exports = (env) => {
...devConfig
}
}
};
};

0 comments on commit 9ab1627

Please sign in to comment.