Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

challenge changes with auth iframe url come from config #352

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions TopcoderXDeploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,11 @@ KAFKA_CLIENT_CERT_KEY: <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/
```
1 change: 0 additions & 1 deletion configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
157 changes: 73 additions & 84 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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/"
}
};

Expand All @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions src/front/src/app/auth/auth.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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',
});
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/front/src/app/main/main.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 3 additions & 2 deletions src/front/src/components/common/footer.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<div class="footer">
</div>
<div class="footer" id="footer-html" ng-controller="MainController">

</div>
10 changes: 1 addition & 9 deletions src/services/TCUserService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down