diff --git a/TopcoderXDeploy.md b/TopcoderXDeploy.md index 2099b43..bb86ca6 100644 --- a/TopcoderXDeploy.md +++ b/TopcoderXDeploy.md @@ -247,14 +247,11 @@ KAFKA_CLIENT_CERT_KEY: KAFKA_URL: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094 NPM_CONFIG_PRODUCTION: false SESSION_SECRET: kjsdfkj34857 -TC_LOGIN_URL: https://accounts.topcoder-dev.com/member -TC_USER_PROFILE_URL: http://api.topcoder-dev.com/v2/user/profile TOPIC: topcoder-x WEBSITE: https://x.topcoder-dev.com AWS_ACCESS_KEY_ID: FAKE_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY: FAKE_SECRET_ACCESS_KEY AWS_REGION: FAKE_REGION IS_LOCAL: true -TC_LOGIN_URL: https://accounts.topcoder-dev.com/member -TC_USER_PROFILE_URL: https://api.topcoder-dev.com/v2/user/profile +TC_LOGIN_URL: https://accounts-auth0.topcoder-dev.com/ ``` diff --git a/configuration.md b/configuration.md index 425d4d9..69b8ca2 100644 --- a/configuration.md +++ b/configuration.md @@ -34,7 +34,6 @@ The following config parameters are supported, they are defined in `src/config.j |IS_LOCAL | Use Amazon DynamoDB Local or server. |true | |AWS_CONNECTION_TIMEOUT | The timeout used to check if the app is healthy. |10000 | |TC_LOGIN_URL | TC login url | | -|TC_USER_PROFILE_URL | TC user profile url | | ## GitHub OAuth App Setup diff --git a/package.json b/package.json index 9d6d615..a761392 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "typescript": "~2.3.3", "uuid": "^3.3.2", "winston": "^2.3.1", - "@topcoder-platform/tc-auth-lib": "git+https://github.com/topcoder-platform/tc-auth-lib.git#1.0.0" + "tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.1" }, "devDependencies": { "angular-mocks": "~1.4.4", diff --git a/src/app.js b/src/app.js index 264f55f..777538d 100644 --- a/src/app.js +++ b/src/app.js @@ -15,7 +15,7 @@ const express = require('express'); const bodyParser = require('body-parser'); const session = require('express-session'); const cookieParser = require('cookie-parser'); -const decodeToken = require('@topcoder-platform/tc-auth-lib').decodeToken; +const decodeToken = require('tc-auth-lib').decodeToken; // const secure = require('ssl-express-www'); const config = require('./config'); const routes = require('./routes'); diff --git a/src/config.js b/src/config.js index 244c1b6..d405fde 100644 --- a/src/config.js +++ b/src/config.js @@ -19,7 +19,7 @@ module.exports = { GITHUB_CLIENT_SECRET: process.env.GITHUB_CLIENT_SECRET, GITLAB_CLIENT_ID: process.env.GITLAB_CLIENT_ID, GITLAB_CLIENT_SECRET: process.env.GITLAB_CLIENT_SECRET, - + // used as base to construct various URLs WEBSITE: process.env.WEBSITE || 'http://topcoderx.topcoder-dev.com', WEBSITE_SECURE: process.env.WEBSITE_SECURE || 'https://topcoderx.topcoder-dev.com', @@ -61,99 +61,89 @@ module.exports = { }, TOPCODER_VALUES: { dev: { - TC_LOGIN_URL: process.env.TC_LOGIN_URL || 'https://accounts-auth0.topcoder-dev.com', - TC_USER_PROFILE_URL: process.env.TC_USER_PROFILE_URL || 'https://api.topcoder-dev.com/v2/user/profile', + TC_LOGIN_URL: process.env.TC_LOGIN_URL || 'https://accounts-auth0.topcoder-dev.com/', }, prod: { - TC_LOGIN_URL: process.env.TC_LOGIN_URL || 'https://accounts-auth0.topcoder.com', - TC_USER_PROFILE_URL: process.env.TC_USER_PROFILE_URL || 'https://api.topcoder.com/v2/user/profile', + TC_LOGIN_URL: process.env.TC_LOGIN_URL || 'https://accounts.topcoder.com/member', }, }, }; const frontendConfigs = { - "local":{ - "JWT_V3_NAME":"v3jwt", - "JWT_V2_NAME":"tcjwt", - "COOKIES_SECURE":false, - "TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com", - "TC_USER_PROFILE_URL": "http://api.topcoder-dev.com/v2/user/profile", - "API_URL": "https://127.0.0.1:8443", - "ADMIN_TOOL_URL": "http://localhost:8080/api/v2", - "ACCOUNTS_CONNECTOR_URL": "https://accounts-auth0.topcoder-dev.com", - "DIRECT_URL_BASE": "https://www.topcoder-dev/direct/projectOverview?formData.projectId=", - "OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login", - "OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login", - "TOPCODER_URL": "https://topcoder-dev.com", - "GITHUB_TEAM_URL": "https://github.com/orgs/", - "GITLAB_GROUP_URL": "https://gitlab.com/groups/" + "local": { + "JWT_V3_NAME": "v3jwt", + "JWT_V2_NAME": "tcjwt", + "COOKIES_SECURE": false, + "TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com/", + "API_URL": "https://127.0.0.1:8443", + "ADMIN_TOOL_URL": "http://localhost:8080/api/v2", + "ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-dev.com/connector.html", + "DIRECT_URL_BASE": "https://www.topcoder-dev/direct/projectOverview?formData.projectId=", + "OWNER_LOGIN_GITHUB_URL": "/api/v1/github/owneruser/login", + "OWNER_LOGIN_GITLAB_URL": "/api/v1/gitlab/owneruser/login", + "TOPCODER_URL": "https://topcoder-dev.com", + "GITHUB_TEAM_URL": "https://github.com/orgs/", + "GITLAB_GROUP_URL": "https://gitlab.com/groups/" }, - "heroku":{ - "JWT_V3_NAME":"v3jwt", - "JWT_V2_NAME":"tcjwt", - "COOKIES_SECURE":false, - "TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com", - "TC_USER_PROFILE_URL": "https://api.topcoder-dev.com/v2/user/profile", - "API_URL": "https://api.topcoder-dev.com", - "ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2", - "ACCOUNTS_CONNECTOR_URL": "https://accounts-auth0.topcoder-dev.com", - "DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=", - "OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login", - "OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login", - "TOPCODER_URL": "https://topcoder-dev.com", - "GITHUB_TEAM_URL": "https://github.com/orgs/", - "GITLAB_GROUP_URL": "https://gitlab.com/groups/" + "heroku": { + "JWT_V3_NAME": "v3jwt", + "JWT_V2_NAME": "tcjwt", + "COOKIES_SECURE": false, + "TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com/", + "API_URL": "https://api.topcoder-dev.com", + "ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2", + "ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-dev.com/connector.html", + "DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=", + "OWNER_LOGIN_GITHUB_URL": "/api/v1/github/owneruser/login", + "OWNER_LOGIN_GITLAB_URL": "/api/v1/gitlab/owneruser/login", + "TOPCODER_URL": "https://topcoder-dev.com", + "GITHUB_TEAM_URL": "https://github.com/orgs/", + "GITLAB_GROUP_URL": "https://gitlab.com/groups/" }, - "dev":{ - "JWT_V3_NAME":"v3jwt", - "JWT_V2_NAME":"tcjwt", - "COOKIES_SECURE":false, - "TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com", - - // TODO: we can clean this conf, as no need https://github.com/topcoder-platform/topcoder-x-ui/issues/342 - "TC_USER_PROFILE_URL": "https://api.topcoder-dev.com/v2/user/profile", - - "API_URL": "https://api.topcoder-dev.com", - "ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2", - "ACCOUNTS_CONNECTOR_URL": "https://accounts-auth0.topcoder-dev.com", - "DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=", - "OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login", - "OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login", - "TOPCODER_URL": "https://topcoder-dev.com", - "GITHUB_TEAM_URL": "https://github.com/orgs/", - "GITLAB_GROUP_URL": "https://gitlab.com/groups/" + "dev": { + "JWT_V3_NAME": "v3jwt", + "JWT_V2_NAME": "tcjwt", + "COOKIES_SECURE": false, + "TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com/", + "API_URL": "https://api.topcoder-dev.com", + "ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2", + "ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-dev.com/connector.html", + "DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=", + "OWNER_LOGIN_GITHUB_URL": "/api/v1/github/owneruser/login", + "OWNER_LOGIN_GITLAB_URL": "/api/v1/gitlab/owneruser/login", + "TOPCODER_URL": "https://topcoder-dev.com", + "GITHUB_TEAM_URL": "https://github.com/orgs/", + "GITLAB_GROUP_URL": "https://gitlab.com/groups/" }, - "qa":{ - "JWT_V3_NAME":"v3jwt", - "JWT_V2_NAME":"tcjwt", - "COOKIES_SECURE":false, - "TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com", - "TC_USER_PROFILE_URL": "https://api.topcoder-dev.com/v2/user/profile", - "API_URL": "https://api.topcoder-qa.com", - "ADMIN_TOOL_URL": "https://api.topcoder-qa.com/v2", - "ACCOUNTS_CONNECTOR_URL": "https://accounts-auth0.topcoder-dev.com", - "DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=", - "OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login", - "OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login", - "TOPCODER_URL": "https://topcoder-dev.com", - "GITHUB_TEAM_URL": "https://github.com/orgs/", - "GITLAB_GROUP_URL": "https://gitlab.com/groups/" + "qa": { + "JWT_V3_NAME": "v3jwt", + "JWT_V2_NAME": "tcjwt", + "COOKIES_SECURE": false, + "TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com/", + "API_URL": "https://api.topcoder-qa.com", + "ADMIN_TOOL_URL": "https://api.topcoder-qa.com/v2", + "ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-qa.com/connector.html", + "DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=", + "OWNER_LOGIN_GITHUB_URL": "/api/v1/github/owneruser/login", + "OWNER_LOGIN_GITLAB_URL": "/api/v1/gitlab/owneruser/login", + "TOPCODER_URL": "https://topcoder-dev.com", + "GITHUB_TEAM_URL": "https://github.com/orgs/", + "GITLAB_GROUP_URL": "https://gitlab.com/groups/" }, - "prod":{ - "JWT_V3_NAME":"v3jwt", - "JWT_V2_NAME":"tcjwt", - "COOKIES_SECURE":false, - "TC_LOGIN_URL": "https://accounts-auth0.topcoder.com", - "TC_USER_PROFILE_URL": "https://api.topcoder.com/v2/user/profile", - "API_URL": "https://api.topcoder.com", - "ADMIN_TOOL_URL": "https://api.topcoder.com/v2", - "ACCOUNTS_CONNECTOR_URL": "https://accounts-auth0.topcoder.com", - "DIRECT_URL_BASE": "https://www.topcoder.com/direct/projectOverview?formData.projectId=", - "OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login", - "OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login", - "TOPCODER_URL": "https://topcoder-dev.com", - "GITHUB_TEAM_URL": "https://github.com/orgs/", - "GITLAB_GROUP_URL": "https://gitlab.com/groups/" + "prod": { + "JWT_V3_NAME": "v3jwt", + "JWT_V2_NAME": "tcjwt", + "COOKIES_SECURE": false, + "TC_LOGIN_URL": "https://accounts.topcoder.com/member", + "API_URL": "https://api.topcoder.com", + "ADMIN_TOOL_URL": "https://api.topcoder.com/v2", + "ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder.com/connector.html", + "DIRECT_URL_BASE": "https://www.topcoder.com/direct/projectOverview?formData.projectId=", + "OWNER_LOGIN_GITHUB_URL": "/api/v1/github/owneruser/login", + "OWNER_LOGIN_GITLAB_URL": "/api/v1/gitlab/owneruser/login", + "TOPCODER_URL": "https://topcoder-dev.com", + "GITHUB_TEAM_URL": "https://github.com/orgs/", + "GITLAB_GROUP_URL": "https://gitlab.com/groups/" } }; @@ -166,7 +156,6 @@ module.exports.frontendConfigs = { JWT_V2_NAME: process.env.JWT_V2_NAME || frontendConfigs[activeEnv].JWT_V2_NAME, COOKIES_SECURE: process.env.COOKIES_SECURE || frontendConfigs[activeEnv].COOKIES_SECURE, TC_LOGIN_URL: process.env.TC_LOGIN_URL || frontendConfigs[activeEnv].TC_LOGIN_URL, - TC_USER_PROFILE_URL: process.env.TC_USER_PROFILE_URL || frontendConfigs[activeEnv].TC_USER_PROFILE_URL, API_URL: process.env.API_URL || frontendConfigs[activeEnv].API_URL, ADMIN_TOOL_URL: process.env.ADMIN_TOOL_URL || frontendConfigs[activeEnv].ADMIN_TOOL_URL, ACCOUNTS_CONNECTOR_URL: process.env.ACCOUNTS_CONNECTOR_URL || frontendConfigs[activeEnv].ACCOUNTS_CONNECTOR_URL, diff --git a/src/front/src/app/auth/auth.service.js b/src/front/src/app/auth/auth.service.js index acdec7a..fd50543 100644 --- a/src/front/src/app/auth/auth.service.js +++ b/src/front/src/app/auth/auth.service.js @@ -24,6 +24,7 @@ angular.module('topcoderX') iframe.width = 0; iframe.height = 0; iframe.frameborder = 0; + iframe.crossorigin = 'anonymous'; // set inline style cross-browser way to make iframe completely invisible angular.element(iframe).css({ @@ -164,10 +165,12 @@ angular.module('topcoderX') * This has to called once when app starts */ AuthService.init = function () { - // add hidden iframe which is used to get API v3 token - configureConnector({ - connectorUrl: $rootScope.appConfig ? $rootScope.appConfig.ACCOUNTS_CONNECTOR_URL : null, - frameId: 'tc-accounts-iframe', + AuthService.getAppConfig().then(function (data) { + // add hidden iframe which is used to get refresh token + configureConnector({ + connectorUrl: data.TC_LOGIN_URL, + frameId: 'tc-accounts-iframe', + }); }); } diff --git a/src/front/src/app/main/main.controller.js b/src/front/src/app/main/main.controller.js index 6b29f0d..7999df6 100644 --- a/src/front/src/app/main/main.controller.js +++ b/src/front/src/app/main/main.controller.js @@ -2,8 +2,8 @@ angular.module('topcoderX') .controller('MainController', ['$scope', '$rootScope', 'Alert', '$state', 'AuthService', 'IssueService', - 'SettingService', 'Tutorial', 'ProjectService', '$log', '$location', - function ($scope, $rootScope, Alert, $state, AuthService, IssueService, SettingService, Tutorial, + 'SettingService', 'Tutorial', 'ProjectService', '$log', '$location', + function ($scope, $rootScope, Alert, $state, AuthService, IssueService, SettingService, Tutorial, ProjectService, $log, $location) { $scope.isLoaded = false; $scope.tableConfig = { diff --git a/src/front/src/components/common/footer.html b/src/front/src/components/common/footer.html index e569562..f67eaba 100644 --- a/src/front/src/components/common/footer.html +++ b/src/front/src/components/common/footer.html @@ -1,2 +1,3 @@ - + \ No newline at end of file diff --git a/src/services/TCUserService.js b/src/services/TCUserService.js index 4c7d556..023b7a8 100644 --- a/src/services/TCUserService.js +++ b/src/services/TCUserService.js @@ -9,7 +9,7 @@ * @version 1.0 */ const Joi = require('joi'); -const decodeToken = require('@topcoder-platform/tc-auth-lib').decodeToken; +const decodeToken = require('tc-auth-lib').decodeToken; const errors = require('../common/errors'); const helper = require('../common/helper'); const UserMapping = require('../models').UserMapping; @@ -20,14 +20,6 @@ const UserMapping = require('../models').UserMapping; * @returns {String} the handle */ async function getHandle(token) { - //issue - https://github.com/topcoder-platform/topcoder-x-ui/issues/342 - - /* const handle = await request - .get(config.TOPCODER_VALUES[config.TOPCODER_ENV].TC_USER_PROFILE_URL) - .set('Authorization', `Bearer ${token}`) - .end() - .then((res) => res.body.handle); - */ const decoded = decodeToken(token); return decoded.handle; }