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

Commit 584111a

Browse files
challenge changes with auth iframe url come from config
1 parent 25df016 commit 584111a

File tree

9 files changed

+89
-108
lines changed

9 files changed

+89
-108
lines changed

Diff for: TopcoderXDeploy.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,11 @@ KAFKA_CLIENT_CERT_KEY: <key>
247247
KAFKA_URL: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
248248
NPM_CONFIG_PRODUCTION: false
249249
SESSION_SECRET: kjsdfkj34857
250-
TC_LOGIN_URL: https://accounts.topcoder-dev.com/member
251-
TC_USER_PROFILE_URL: http://api.topcoder-dev.com/v2/user/profile
252250
TOPIC: topcoder-x
253251
WEBSITE: https://x.topcoder-dev.com
254252
AWS_ACCESS_KEY_ID: FAKE_ACCESS_KEY_ID
255253
AWS_SECRET_ACCESS_KEY: FAKE_SECRET_ACCESS_KEY
256254
AWS_REGION: FAKE_REGION
257255
IS_LOCAL: true
258-
TC_LOGIN_URL: https://accounts.topcoder-dev.com/member
259-
TC_USER_PROFILE_URL: https://api.topcoder-dev.com/v2/user/profile
256+
TC_LOGIN_URL: https://accounts-auth0.topcoder-dev.com/
260257
```

Diff for: configuration.md

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ The following config parameters are supported, they are defined in `src/config.j
3434
|IS_LOCAL | Use Amazon DynamoDB Local or server. |true |
3535
|AWS_CONNECTION_TIMEOUT | The timeout used to check if the app is healthy. |10000 |
3636
|TC_LOGIN_URL | TC login url | |
37-
|TC_USER_PROFILE_URL | TC user profile url | |
3837

3938
## GitHub OAuth App Setup
4039

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"typescript": "~2.3.3",
8585
"uuid": "^3.3.2",
8686
"winston": "^2.3.1",
87-
"@topcoder-platform/tc-auth-lib": "git+https://github.com/topcoder-platform/tc-auth-lib.git#1.0.0"
87+
"tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.1"
8888
},
8989
"devDependencies": {
9090
"angular-mocks": "~1.4.4",

Diff for: src/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const express = require('express');
1515
const bodyParser = require('body-parser');
1616
const session = require('express-session');
1717
const cookieParser = require('cookie-parser');
18-
const decodeToken = require('@topcoder-platform/tc-auth-lib').decodeToken;
18+
const decodeToken = require('tc-auth-lib').decodeToken;
1919
// const secure = require('ssl-express-www');
2020
const config = require('./config');
2121
const routes = require('./routes');

Diff for: src/config.js

+73-84
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
GITHUB_CLIENT_SECRET: process.env.GITHUB_CLIENT_SECRET,
2020
GITLAB_CLIENT_ID: process.env.GITLAB_CLIENT_ID,
2121
GITLAB_CLIENT_SECRET: process.env.GITLAB_CLIENT_SECRET,
22-
22+
2323
// used as base to construct various URLs
2424
WEBSITE: process.env.WEBSITE || 'http://topcoderx.topcoder-dev.com',
2525
WEBSITE_SECURE: process.env.WEBSITE_SECURE || 'https://topcoderx.topcoder-dev.com',
@@ -61,99 +61,89 @@ module.exports = {
6161
},
6262
TOPCODER_VALUES: {
6363
dev: {
64-
TC_LOGIN_URL: process.env.TC_LOGIN_URL || 'https://accounts-auth0.topcoder-dev.com',
65-
TC_USER_PROFILE_URL: process.env.TC_USER_PROFILE_URL || 'https://api.topcoder-dev.com/v2/user/profile',
64+
TC_LOGIN_URL: process.env.TC_LOGIN_URL || 'https://accounts-auth0.topcoder-dev.com/',
6665
},
6766
prod: {
68-
TC_LOGIN_URL: process.env.TC_LOGIN_URL || 'https://accounts-auth0.topcoder.com',
69-
TC_USER_PROFILE_URL: process.env.TC_USER_PROFILE_URL || 'https://api.topcoder.com/v2/user/profile',
67+
TC_LOGIN_URL: process.env.TC_LOGIN_URL || 'https://accounts.topcoder.com/member',
7068
},
7169
},
7270
};
7371

7472
const frontendConfigs = {
75-
"local":{
76-
"JWT_V3_NAME":"v3jwt",
77-
"JWT_V2_NAME":"tcjwt",
78-
"COOKIES_SECURE":false,
79-
"TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com",
80-
"TC_USER_PROFILE_URL": "http://api.topcoder-dev.com/v2/user/profile",
81-
"API_URL": "https://127.0.0.1:8443",
82-
"ADMIN_TOOL_URL": "http://localhost:8080/api/v2",
83-
"ACCOUNTS_CONNECTOR_URL": "https://accounts-auth0.topcoder-dev.com",
84-
"DIRECT_URL_BASE": "https://www.topcoder-dev/direct/projectOverview?formData.projectId=",
85-
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
86-
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
87-
"TOPCODER_URL": "https://topcoder-dev.com",
88-
"GITHUB_TEAM_URL": "https://github.com/orgs/",
89-
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
73+
"local": {
74+
"JWT_V3_NAME": "v3jwt",
75+
"JWT_V2_NAME": "tcjwt",
76+
"COOKIES_SECURE": false,
77+
"TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com/",
78+
"API_URL": "https://127.0.0.1:8443",
79+
"ADMIN_TOOL_URL": "http://localhost:8080/api/v2",
80+
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-dev.com/connector.html",
81+
"DIRECT_URL_BASE": "https://www.topcoder-dev/direct/projectOverview?formData.projectId=",
82+
"OWNER_LOGIN_GITHUB_URL": "/api/v1/github/owneruser/login",
83+
"OWNER_LOGIN_GITLAB_URL": "/api/v1/gitlab/owneruser/login",
84+
"TOPCODER_URL": "https://topcoder-dev.com",
85+
"GITHUB_TEAM_URL": "https://github.com/orgs/",
86+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
9087
},
91-
"heroku":{
92-
"JWT_V3_NAME":"v3jwt",
93-
"JWT_V2_NAME":"tcjwt",
94-
"COOKIES_SECURE":false,
95-
"TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com",
96-
"TC_USER_PROFILE_URL": "https://api.topcoder-dev.com/v2/user/profile",
97-
"API_URL": "https://api.topcoder-dev.com",
98-
"ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2",
99-
"ACCOUNTS_CONNECTOR_URL": "https://accounts-auth0.topcoder-dev.com",
100-
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
101-
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
102-
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
103-
"TOPCODER_URL": "https://topcoder-dev.com",
104-
"GITHUB_TEAM_URL": "https://github.com/orgs/",
105-
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
88+
"heroku": {
89+
"JWT_V3_NAME": "v3jwt",
90+
"JWT_V2_NAME": "tcjwt",
91+
"COOKIES_SECURE": false,
92+
"TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com/",
93+
"API_URL": "https://api.topcoder-dev.com",
94+
"ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2",
95+
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-dev.com/connector.html",
96+
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
97+
"OWNER_LOGIN_GITHUB_URL": "/api/v1/github/owneruser/login",
98+
"OWNER_LOGIN_GITLAB_URL": "/api/v1/gitlab/owneruser/login",
99+
"TOPCODER_URL": "https://topcoder-dev.com",
100+
"GITHUB_TEAM_URL": "https://github.com/orgs/",
101+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
106102
},
107-
"dev":{
108-
"JWT_V3_NAME":"v3jwt",
109-
"JWT_V2_NAME":"tcjwt",
110-
"COOKIES_SECURE":false,
111-
"TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com",
112-
113-
// TODO: we can clean this conf, as no need https://github.com/topcoder-platform/topcoder-x-ui/issues/342
114-
"TC_USER_PROFILE_URL": "https://api.topcoder-dev.com/v2/user/profile",
115-
116-
"API_URL": "https://api.topcoder-dev.com",
117-
"ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2",
118-
"ACCOUNTS_CONNECTOR_URL": "https://accounts-auth0.topcoder-dev.com",
119-
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
120-
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
121-
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
122-
"TOPCODER_URL": "https://topcoder-dev.com",
123-
"GITHUB_TEAM_URL": "https://github.com/orgs/",
124-
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
103+
"dev": {
104+
"JWT_V3_NAME": "v3jwt",
105+
"JWT_V2_NAME": "tcjwt",
106+
"COOKIES_SECURE": false,
107+
"TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com/",
108+
"API_URL": "https://api.topcoder-dev.com",
109+
"ADMIN_TOOL_URL": "https://api.topcoder-dev.com/v2",
110+
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-dev.com/connector.html",
111+
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
112+
"OWNER_LOGIN_GITHUB_URL": "/api/v1/github/owneruser/login",
113+
"OWNER_LOGIN_GITLAB_URL": "/api/v1/gitlab/owneruser/login",
114+
"TOPCODER_URL": "https://topcoder-dev.com",
115+
"GITHUB_TEAM_URL": "https://github.com/orgs/",
116+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
125117
},
126-
"qa":{
127-
"JWT_V3_NAME":"v3jwt",
128-
"JWT_V2_NAME":"tcjwt",
129-
"COOKIES_SECURE":false,
130-
"TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com",
131-
"TC_USER_PROFILE_URL": "https://api.topcoder-dev.com/v2/user/profile",
132-
"API_URL": "https://api.topcoder-qa.com",
133-
"ADMIN_TOOL_URL": "https://api.topcoder-qa.com/v2",
134-
"ACCOUNTS_CONNECTOR_URL": "https://accounts-auth0.topcoder-dev.com",
135-
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
136-
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
137-
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
138-
"TOPCODER_URL": "https://topcoder-dev.com",
139-
"GITHUB_TEAM_URL": "https://github.com/orgs/",
140-
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
118+
"qa": {
119+
"JWT_V3_NAME": "v3jwt",
120+
"JWT_V2_NAME": "tcjwt",
121+
"COOKIES_SECURE": false,
122+
"TC_LOGIN_URL": "https://accounts-auth0.topcoder-dev.com/",
123+
"API_URL": "https://api.topcoder-qa.com",
124+
"ADMIN_TOOL_URL": "https://api.topcoder-qa.com/v2",
125+
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder-qa.com/connector.html",
126+
"DIRECT_URL_BASE": "https://www.topcoder-dev.com/direct/projectOverview?formData.projectId=",
127+
"OWNER_LOGIN_GITHUB_URL": "/api/v1/github/owneruser/login",
128+
"OWNER_LOGIN_GITLAB_URL": "/api/v1/gitlab/owneruser/login",
129+
"TOPCODER_URL": "https://topcoder-dev.com",
130+
"GITHUB_TEAM_URL": "https://github.com/orgs/",
131+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
141132
},
142-
"prod":{
143-
"JWT_V3_NAME":"v3jwt",
144-
"JWT_V2_NAME":"tcjwt",
145-
"COOKIES_SECURE":false,
146-
"TC_LOGIN_URL": "https://accounts-auth0.topcoder.com",
147-
"TC_USER_PROFILE_URL": "https://api.topcoder.com/v2/user/profile",
148-
"API_URL": "https://api.topcoder.com",
149-
"ADMIN_TOOL_URL": "https://api.topcoder.com/v2",
150-
"ACCOUNTS_CONNECTOR_URL": "https://accounts-auth0.topcoder.com",
151-
"DIRECT_URL_BASE": "https://www.topcoder.com/direct/projectOverview?formData.projectId=",
152-
"OWNER_LOGIN_GITHUB_URL":"/api/v1/github/owneruser/login",
153-
"OWNER_LOGIN_GITLAB_URL":"/api/v1/gitlab/owneruser/login",
154-
"TOPCODER_URL": "https://topcoder-dev.com",
155-
"GITHUB_TEAM_URL": "https://github.com/orgs/",
156-
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
133+
"prod": {
134+
"JWT_V3_NAME": "v3jwt",
135+
"JWT_V2_NAME": "tcjwt",
136+
"COOKIES_SECURE": false,
137+
"TC_LOGIN_URL": "https://accounts.topcoder.com/member",
138+
"API_URL": "https://api.topcoder.com",
139+
"ADMIN_TOOL_URL": "https://api.topcoder.com/v2",
140+
"ACCOUNTS_CONNECTOR_URL": "https://accounts.topcoder.com/connector.html",
141+
"DIRECT_URL_BASE": "https://www.topcoder.com/direct/projectOverview?formData.projectId=",
142+
"OWNER_LOGIN_GITHUB_URL": "/api/v1/github/owneruser/login",
143+
"OWNER_LOGIN_GITLAB_URL": "/api/v1/gitlab/owneruser/login",
144+
"TOPCODER_URL": "https://topcoder-dev.com",
145+
"GITHUB_TEAM_URL": "https://github.com/orgs/",
146+
"GITLAB_GROUP_URL": "https://gitlab.com/groups/"
157147
}
158148
};
159149

@@ -166,7 +156,6 @@ module.exports.frontendConfigs = {
166156
JWT_V2_NAME: process.env.JWT_V2_NAME || frontendConfigs[activeEnv].JWT_V2_NAME,
167157
COOKIES_SECURE: process.env.COOKIES_SECURE || frontendConfigs[activeEnv].COOKIES_SECURE,
168158
TC_LOGIN_URL: process.env.TC_LOGIN_URL || frontendConfigs[activeEnv].TC_LOGIN_URL,
169-
TC_USER_PROFILE_URL: process.env.TC_USER_PROFILE_URL || frontendConfigs[activeEnv].TC_USER_PROFILE_URL,
170159
API_URL: process.env.API_URL || frontendConfigs[activeEnv].API_URL,
171160
ADMIN_TOOL_URL: process.env.ADMIN_TOOL_URL || frontendConfigs[activeEnv].ADMIN_TOOL_URL,
172161
ACCOUNTS_CONNECTOR_URL: process.env.ACCOUNTS_CONNECTOR_URL || frontendConfigs[activeEnv].ACCOUNTS_CONNECTOR_URL,

Diff for: src/front/src/app/auth/auth.service.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ angular.module('topcoderX')
2424
iframe.width = 0;
2525
iframe.height = 0;
2626
iframe.frameborder = 0;
27+
iframe.crossorigin = 'anonymous';
2728

2829
// set inline style cross-browser way to make iframe completely invisible
2930
angular.element(iframe).css({
@@ -164,10 +165,12 @@ angular.module('topcoderX')
164165
* This has to called once when app starts
165166
*/
166167
AuthService.init = function () {
167-
// add hidden iframe which is used to get API v3 token
168-
configureConnector({
169-
connectorUrl: $rootScope.appConfig ? $rootScope.appConfig.ACCOUNTS_CONNECTOR_URL : null,
170-
frameId: 'tc-accounts-iframe',
168+
AuthService.getAppConfig().then(function (data) {
169+
// add hidden iframe which is used to get refresh token
170+
configureConnector({
171+
connectorUrl: data.TC_LOGIN_URL,
172+
frameId: 'tc-accounts-iframe',
173+
});
171174
});
172175
}
173176

Diff for: src/front/src/app/main/main.controller.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
angular.module('topcoderX')
44
.controller('MainController', ['$scope', '$rootScope', 'Alert', '$state', 'AuthService', 'IssueService',
5-
'SettingService', 'Tutorial', 'ProjectService', '$log', '$location',
6-
function ($scope, $rootScope, Alert, $state, AuthService, IssueService, SettingService, Tutorial,
5+
'SettingService', 'Tutorial', 'ProjectService', '$log', '$location',
6+
function ($scope, $rootScope, Alert, $state, AuthService, IssueService, SettingService, Tutorial,
77
ProjectService, $log, $location) {
88
$scope.isLoaded = false;
99
$scope.tableConfig = {

Diff for: src/front/src/components/common/footer.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
<div class="footer">
2-
</div>
1+
<div class="footer" id="footer-html" ng-controller="MainController">
2+
3+
</div>

Diff for: src/services/TCUserService.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @version 1.0
1010
*/
1111
const Joi = require('joi');
12-
const decodeToken = require('@topcoder-platform/tc-auth-lib').decodeToken;
12+
const decodeToken = require('tc-auth-lib').decodeToken;
1313
const errors = require('../common/errors');
1414
const helper = require('../common/helper');
1515
const UserMapping = require('../models').UserMapping;
@@ -20,14 +20,6 @@ const UserMapping = require('../models').UserMapping;
2020
* @returns {String} the handle
2121
*/
2222
async function getHandle(token) {
23-
//issue - https://github.com/topcoder-platform/topcoder-x-ui/issues/342
24-
25-
/* const handle = await request
26-
.get(config.TOPCODER_VALUES[config.TOPCODER_ENV].TC_USER_PROFILE_URL)
27-
.set('Authorization', `Bearer ${token}`)
28-
.end()
29-
.then((res) => res.body.handle);
30-
*/
3123
const decoded = decodeToken(token);
3224
return decoded.handle;
3325
}

0 commit comments

Comments
 (0)