From 9ab16275f5d033419a3866148e14f8f95cd83520 Mon Sep 17 00:00:00 2001 From: dulith Date: Tue, 13 Dec 2022 10:07:43 +0530 Subject: [PATCH] Add new line at EOF & add license headers --- portals/admin/Dockerfile | 2 +- portals/admin/bin/www | 2 +- portals/admin/client/src/Apis.js | 19 +++++++++++ portals/admin/client/src/App.tsx | 19 +++++++++++ portals/admin/client/src/auth/LoginButton.tsx | 20 ++++++++++- .../admin/client/src/auth/LogoutButton.tsx | 20 ++++++++++- portals/admin/client/src/auth/crypto.ts | 20 ++++++++++- portals/admin/client/src/auth/sign-in.ts | 33 +++++++++++-------- portals/admin/client/src/constants/token.ts | 18 ++++++++++ portals/admin/client/src/index.jsx | 2 +- .../client/src/models/oidc-request-params.ts | 21 ++++++++++-- .../admin/client/src/models/token-response.ts | 2 +- portals/admin/routes/users.js | 1 + portals/admin/tsconfig.json | 2 +- portals/admin/webpack.config.js | 9 +---- 15 files changed, 158 insertions(+), 32 deletions(-) diff --git a/portals/admin/Dockerfile b/portals/admin/Dockerfile index 60ee583c0c2..424bd28089e 100644 --- a/portals/admin/Dockerfile +++ b/portals/admin/Dockerfile @@ -7,4 +7,4 @@ RUN echo "$PWD" RUN npm install RUN npm run react-prod EXPOSE 4000 -CMD ["npm", "run", "start"] \ No newline at end of file +CMD ["npm", "run", "start"] diff --git a/portals/admin/bin/www b/portals/admin/bin/www index 82b338534fc..ca33d0cbf56 100755 --- a/portals/admin/bin/www +++ b/portals/admin/bin/www @@ -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'); /** @@ -93,3 +92,4 @@ function onListening() { : 'port ' + addr.port; debug('Listening on ' + bind); } + diff --git a/portals/admin/client/src/Apis.js b/portals/admin/client/src/Apis.js index a6bb29e21c7..02d29ab314c 100644 --- a/portals/admin/client/src/Apis.js +++ b/portals/admin/client/src/Apis.js @@ -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'; @@ -74,3 +92,4 @@ export default function Apis() { ) } + diff --git a/portals/admin/client/src/App.tsx b/portals/admin/client/src/App.tsx index 4270c4ea607..ebc6528e935 100644 --- a/portals/admin/client/src/App.tsx +++ b/portals/admin/client/src/App.tsx @@ -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"; @@ -84,3 +102,4 @@ function NoMatch() { ); } + diff --git a/portals/admin/client/src/auth/LoginButton.tsx b/portals/admin/client/src/auth/LoginButton.tsx index c2b198c0629..48bb4fb6ec4 100644 --- a/portals/admin/client/src/auth/LoginButton.tsx +++ b/portals/admin/client/src/auth/LoginButton.tsx @@ -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 = () => { @@ -7,4 +25,4 @@ const LoginButton = () => { ; }; -export default LoginButton; \ No newline at end of file +export default LoginButton; diff --git a/portals/admin/client/src/auth/LogoutButton.tsx b/portals/admin/client/src/auth/LogoutButton.tsx index 2f7e0d5bb88..ac7996c2f9b 100644 --- a/portals/admin/client/src/auth/LogoutButton.tsx +++ b/portals/admin/client/src/auth/LogoutButton.tsx @@ -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"; @@ -16,4 +34,4 @@ const LogoutButton = () => { ); }; -export default LogoutButton; \ No newline at end of file +export default LogoutButton; diff --git a/portals/admin/client/src/auth/crypto.ts b/portals/admin/client/src/auth/crypto.ts index e383ab181b7..bfec7556732 100644 --- a/portals/admin/client/src/auth/crypto.ts +++ b/portals/admin/client/src/auth/crypto.ts @@ -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"; @@ -82,4 +100,4 @@ export const isValidIdToken = (idToken: any, jwk: any, clientID: string, issuer: gracePeriod: 3600, iss: [issuer] }); -}; \ No newline at end of file +}; diff --git a/portals/admin/client/src/auth/sign-in.ts b/portals/admin/client/src/auth/sign-in.ts index a4dfc8b99bd..85893fefa7b 100644 --- a/portals/admin/client/src/auth/sign-in.ts +++ b/portals/admin/client/src/auth/sign-in.ts @@ -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'; @@ -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); }); @@ -207,3 +211,4 @@ export const sendRefreshTokenRequest = ( return Promise.reject(error); }); }; + diff --git a/portals/admin/client/src/constants/token.ts b/portals/admin/client/src/constants/token.ts index 1a2e24d4e10..31c2638a0c6 100644 --- a/portals/admin/client/src/constants/token.ts +++ b/portals/admin/client/src/constants/token.ts @@ -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; diff --git a/portals/admin/client/src/index.jsx b/portals/admin/client/src/index.jsx index 89f4e65a3bf..3a4775e82d2 100644 --- a/portals/admin/client/src/index.jsx +++ b/portals/admin/client/src/index.jsx @@ -8,4 +8,4 @@ root.render( -); \ No newline at end of file +); diff --git a/portals/admin/client/src/models/oidc-request-params.ts b/portals/admin/client/src/models/oidc-request-params.ts index d4a7f84d90e..3cc26a40d56 100644 --- a/portals/admin/client/src/models/oidc-request-params.ts +++ b/portals/admin/client/src/models/oidc-request-params.ts @@ -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; -} \ No newline at end of file +} diff --git a/portals/admin/client/src/models/token-response.ts b/portals/admin/client/src/models/token-response.ts index 3a5b0f0085b..9ee90d85780 100644 --- a/portals/admin/client/src/models/token-response.ts +++ b/portals/admin/client/src/models/token-response.ts @@ -8,4 +8,4 @@ expiresIn: string; scope: string; tokenType: string; -} \ No newline at end of file +} diff --git a/portals/admin/routes/users.js b/portals/admin/routes/users.js index c9035685c3c..f53888227af 100644 --- a/portals/admin/routes/users.js +++ b/portals/admin/routes/users.js @@ -7,3 +7,4 @@ router.get('/', function(req, res, next) { }); module.exports = router; + diff --git a/portals/admin/tsconfig.json b/portals/admin/tsconfig.json index fdcc091ce4c..059c64b5d06 100644 --- a/portals/admin/tsconfig.json +++ b/portals/admin/tsconfig.json @@ -10,4 +10,4 @@ "moduleResolution": "node", "allowSyntheticDefaultImports": true, } -} \ No newline at end of file +} diff --git a/portals/admin/webpack.config.js b/portals/admin/webpack.config.js index f70c88b47e6..02115ea5462 100644 --- a/portals/admin/webpack.config.js +++ b/portals/admin/webpack.config.js @@ -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'), @@ -75,4 +68,4 @@ module.exports = (env) => { ...devConfig } } -}; \ No newline at end of file +};