Skip to content

Commit 717b650

Browse files
Merge pull request #5145 from topcoder-platform/develop-auth0-sync
Smoke Testing 2020-10-29 - Auth0 RS256
2 parents 12adaec + a393eaa commit 717b650

File tree

33 files changed

+83
-59
lines changed

33 files changed

+83
-59
lines changed

.circleci/config.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ workflows:
230230
filters:
231231
branches:
232232
only:
233-
- hot-fix
233+
- develop-auth0-sync
234+
- develop
234235
# This is alternate dev env for parallel testing
235236
- "build-test":
236237
context : org-global
@@ -259,8 +260,7 @@ workflows:
259260
filters:
260261
branches:
261262
only:
262-
- develop
263-
- listing-develop-sync
263+
- develop-auth0-sync
264264
# Production builds are exectuted
265265
# when PR is merged to the master
266266
# Don't change anything in this configuration

__tests__/client/client.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const mockTcAccounts = {
106106
decodeToken: () => ({ exp: Date.now() }),
107107
getFreshToken: () => Promise.resolve(tokenV3),
108108
};
109-
jest.setMock('tc-accounts', mockTcAccounts);
109+
jest.setMock('@topcoder-platform/tc-auth-lib', mockTcAccounts);
110110
111111
/* Mock auth actions */
112112
/*

__tests__/shared/components/Header/__snapshots__/index.jsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ exports[`Default render 1`] = `
165165
auth={null}
166166
authURLs={
167167
Object {
168-
"href": "https://accounts.topcoder-dev.com/member/registration?utm_source=community-app-main",
169-
"location": "https://accounts.topcoder-dev.com/member?retUrl=%S&utm_source=community-app-main",
168+
"href": "https://accounts-auth0.topcoder-dev.com?utm_source=community-app-main",
169+
"location": "https://accounts-auth0.topcoder-dev.com?retUrl=%S&utm_source=community-app-main",
170170
}
171171
}
172172
loggedIn={true}

__tests__/shared/components/__snapshots__/TopcoderFooter.jsx.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ exports[`Matches shallow shapshot 1`] = `
316316
className="src-shared-components-TopcoderFooter-___style__link___3-nzm"
317317
>
318318
<a
319-
href="https://accounts.topcoder.com/member/registration?utm_source=community&utm_campaign=tc-footer&utm_medium=promotion"
319+
href="https://accounts-auth0.topcoder-dev.com?utm_source=community&utm_campaign=tc-footer&utm_medium=promotion&retUrl="
320320
>
321321
Join Community
322322
</a>

__tests__/shared/components/tc-communities/Footer.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ test('render properly', () => {
4141
<Wrapper
4242
menuItems={[]}
4343
communityId="wipro"
44-
registerUrl="https://accounts.topcoder-dev.com/member/registration"
45-
loginUrl="https://accounts.topcoder-dev.com/member"
44+
registerUrl="https://accounts-auth0.topcoder-dev.com/member/registration"
45+
loginUrl="https://accounts-auth0.topcoder-dev.com/member"
4646
isAuthorized
4747
/>
4848
));
@@ -63,8 +63,8 @@ test('render properly', () => {
6363
url: 'leaderboard',
6464
}]}
6565
communityId="wipro"
66-
registerUrl="https://accounts.topcoder-dev.com/member/registration"
67-
loginUrl="https://accounts.topcoder-dev.com/member"
66+
registerUrl="https://accounts-auth0.topcoder-dev.com/member/registration"
67+
loginUrl="https://accounts-auth0.topcoder-dev.com/member"
6868
isAuthorized={false}
6969
theme={{
7070
container: 'container',

__tests__/shared/components/tc-communities/__snapshots__/AccessDenied.jsx.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ exports[`Matches shallow shapshot 1`] = `
2020
>
2121
<a
2222
className="tc-btn-md tc-btn-primary"
23-
href="http://accounts.topcoder-dev.com/member?utm_source="
23+
href="https://accounts-auth0.topcoder-dev.com/member?utm_source="
2424
onClick={[Function]}
2525
>
2626
Log In Here

__tests__/shared/reducers/auth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const mockActions = {
2424
2525
_.merge(actions, mockActions);
2626
27-
jest.setMock('tc-accounts', {
27+
jest.setMock('@topcoder-platform/tc-auth-lib', {
2828
decodeToken: () => 'User object',
2929
isTokenExpired: () => false,
3030
});

__tests__/shared/reducers/challenge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { mock, actions } from 'topcoder-react-lib';
1111
1212
const { mockAction } = mock;
1313
14-
jest.setMock('tc-accounts', {
14+
jest.setMock('@topcoder-platform/tc-auth-lib', {
1515
decodeToken: () => 'User object',
1616
isTokenExpired: () => false,
1717
});

bin/www

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* Enables Babel for the server-side code (with exception of this very file). */
66
require('babel-register')({
77
ignore: [
8-
/node_modules\/(?!appirio-tech.*|topcoder|tc-)/,
8+
/node_modules\/(?!appirio-tech.*|topcoder|tc-|@topcoder)/,
99
/node_modules\/topcoder-react-utils/,
1010
],
1111
});

config/default.js

+7-14
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ module.exports = {
7878
},
7979
},
8080

81-
/* Amount of time [seconds] before expiration of authentication tokens,
82-
* when the frontend will automatically trigger their refreshment. Once
83-
* ready, it will either write to the Redux store fresh token, or will
84-
* remove auth tokens from the store.
85-
* NOTE: With the current implementation of accounts-app this value must be
86-
* smaller than 60 seconds (earlier than 60 seconds before expiration of an
87-
* auth token, a call to the getFreshToken() method returns the old token,
88-
* due to caching). */
89-
REAUTH_TIME: 55,
90-
9181
/* API key for Segment.io. For development environment the value is set inside
9282
* development.json, for production environment it is set via CircleCI
9383
* variables. */
@@ -104,7 +94,7 @@ module.exports = {
10494
* platform. */
10595
URL: {
10696
/* Connector URL of the TC accounts App. */
107-
ACCOUNTS_APP_CONNECTOR: 'https://accounts.topcoder-dev.com/connector.html',
97+
ACCOUNTS_APP_CONNECTOR: 'https://accounts-auth0.topcoder-dev.com',
10898

10999
/* The remote address where the app is deployed. */
110100
APP: 'https://community-app.topcoder-dev.com',
@@ -114,7 +104,7 @@ module.exports = {
114104
COMMUNITY_APP: 'https://community-app.topcoder-dev.com',
115105

116106
ARENA: 'https://arena.topcoder-dev.com',
117-
AUTH: 'http://accounts.topcoder-dev.com',
107+
AUTH: 'https://accounts-auth0.topcoder-dev.com',
118108
BASE: 'https://www.topcoder-dev.com',
119109
HOME: '/my-dashboard',
120110
BLOG: 'https://www.topcoder-dev.com/blog',
@@ -129,6 +119,8 @@ module.exports = {
129119
BLOCKCHAIN: 'https://blockchain.topcoder-dev.com',
130120
COGNITIVE: 'https://cognitive.topcoder-dev.com',
131121
ZURICH: 'https://community-app.topcoder-dev.com/__community__/zurich',
122+
COMCAST: 'https://community-app.topcoder-dev.com/__community__/comcast',
123+
CS: 'https://community-app.topcoder-dev.com/__community__/cs',
132124
},
133125

134126
/* Dedicated section to group together links to various articles in
@@ -152,6 +144,7 @@ module.exports = {
152144
STUDIO: 'https://studio.topcoder-dev.com',
153145
TCO: 'https://www.topcoder.com/tco',
154146
TCO17: 'https://tco17.topcoder.com/',
147+
TCO19: 'https://community-app.topcoder-dev.com/__community__/tco19',
155148

156149
TOPGEAR: 'https://dev-topgear.wipro.com',
157150

@@ -384,8 +377,8 @@ module.exports = {
384377
],
385378
HEADER_MENU_THEME: 'light',
386379
HEADER_AUTH_URLS: {
387-
href: 'https://accounts.topcoder-dev.com/member/registration?utm_source=community-app-main',
388-
location: 'https://accounts.topcoder-dev.com/member?retUrl=%S&utm_source=community-app-main',
380+
href: 'https://accounts-auth0.topcoder-dev.com?utm_source=community-app-main',
381+
location: 'https://accounts-auth0.topcoder-dev.com?retUrl=%S&utm_source=community-app-main',
389382
},
390383
ACCOUNT_MENU: [
391384
{

config/jest/default.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const config = require('topcoder-react-utils/config/jest/default');
22
const nodeConfig = require('config');
33

4-
config.transformIgnorePatterns[0] = '/node_modules/(?!appirio-tech|topcoder|tc-)';
4+
config.transformIgnorePatterns[0] = '/node_modules/(?!appirio-tech|topcoder|tc-|@topcoder)';
55
// config.testMatch[0] = '**/__tests__/shared/containers/challenge-listing/FilterPanel.jsx';
66

77
// Include the directories whose tests has been written to minimize coverage time

config/production.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626
* as a more verbose name for the param. */
2727
COMMUNITY_APP: 'https://community-app.topcoder.com',
2828

29-
AUTH: 'https://accounts.topcoder.com',
29+
AUTH: 'https://accounts-auth0.topcoder.com',
3030
BASE: 'https://www.topcoder.com',
3131
HOME: '/my-dashboard',
3232
COMMUNITY: 'https://community.topcoder.com',
@@ -39,8 +39,9 @@ module.exports = {
3939
IOS: 'https://ios.topcoder.com',
4040

4141
/* Connector URL of the TC accounts App. */
42-
ACCOUNTS_APP_CONNECTOR: 'https://accounts.topcoder.com/connector.html',
42+
ACCOUNTS_APP_CONNECTOR: 'https://accounts-auth0.topcoder.com/',
4343
TCO17: 'https://tco17.topcoder.com/',
44+
TCO19: 'https://tco19.topcoder.com/',
4445

4546
TOPGEAR: 'https://topgear-app.wipro.com',
4647

@@ -50,6 +51,8 @@ module.exports = {
5051
BLOCKCHAIN: 'https://blockchain.topcoder.com',
5152
COGNITIVE: 'https://cognitive.topcoder.com',
5253
ZURICH: 'https://zurich.topcoder.com',
54+
COMCAST: 'https://comcast.topcoder.com',
55+
CS: 'https://cs.topcoder.com',
5356
},
5457
EMAIL_VERIFY_URL: 'http://www.topcoder.com/settings/account/changeEmail',
5558
},
@@ -184,8 +187,8 @@ module.exports = {
184187
],
185188
HEADER_MENU_THEME: 'light',
186189
HEADER_AUTH_URLS: {
187-
href: 'https://accounts.topcoder.com/member/registration?utm_source=community-app-main',
188-
location: 'https://accounts.topcoder.com/member?retUrl=%S&utm_source=community-app-main',
190+
href: 'https://accounts-auth0.topcoder.com?utm_source=community-app-main',
191+
location: 'https://accounts-auth0.topcoder.com?retUrl=%S&utm_source=community-app-main',
189192
},
190193
ACCOUNT_MENU: [
191194
{

config/webpack/development.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const standardDevelopmentConfig = configFactory({
1717

1818
const jsxRule = standardDevelopmentConfig.module.rules.find(rule => rule.loader === 'babel-loader');
1919
jsxRule.exclude = [
20-
/node_modules[\\/](?!appirio-tech.*|topcoder|tc-)/,
20+
/node_modules[\\/](?!appirio-tech.*|topcoder|tc-|@topcoder)/,
2121
/src[\\/]assets[\\/]fonts/,
2222
/src[\\/]assets[\\/]images[\\/]dashboard/,
2323
];

config/webpack/production.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const standardDevelopmentConfig = configFactory({
2424

2525
const jsxRule = standardDevelopmentConfig.module.rules.find(rule => rule.loader === 'babel-loader');
2626
jsxRule.exclude = [
27-
/node_modules[\\/](?!appirio-tech.*|topcoder|tc-)/,
27+
/node_modules[\\/](?!appirio-tech.*|topcoder|tc-|@topcoder)/,
2828
/src[\\/]assets[\\/]fonts/,
2929
/src[\\/]assets[\\/]images[\\/]dashboard/,
3030
];

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
},
3838
"dependencies": {
3939
"@hapi/joi": "^16.1.4",
40+
"@topcoder-platform/tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.1",
4041
"aos": "^2.3.4",
4142
"atob": "^2.1.1",
4243
"babel-register": "^6.26.0",
@@ -137,10 +138,9 @@
137138
"showdown": "^1.8.6",
138139
"slick-carousel": "^1.8.1",
139140
"supertest": "^3.1.0",
140-
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
141141
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
142142
"tc-ui": "^1.0.12",
143-
"topcoder-react-lib": "1.0.8",
143+
"topcoder-react-lib": "1000.23.3",
144144
"topcoder-react-ui-kit": "2.0.1",
145145
"topcoder-react-utils": "0.7.8",
146146
"turndown": "^4.0.2",

src/client/index.jsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
configureConnector,
1212
decodeToken,
1313
getFreshToken,
14-
} from 'tc-accounts';
14+
} from '@topcoder-platform/tc-auth-lib';
1515
import { actions, logger, errors } from 'topcoder-react-lib';
1616
import { client, redux } from 'topcoder-react-utils';
1717

@@ -113,10 +113,9 @@ function authenticate(store) {
113113
if (tctV2) time = decodeToken(tctV2).exp;
114114
if (userV3) time = Math.min(time, userV3.exp);
115115
if (time < Number.MAX_VALUE) {
116-
time = 1000 * (time - window.CONFIG.REAUTH_TIME);
117-
time = Math.max(0, time - Date.now());
116+
time = Math.max(1000, (time * 1000) - Date.now());
118117
logger.log('Reauth scheduled in', time / 1000, 'seconds');
119-
setTimeout(() => authenticate(store), time);
118+
setTimeout(() => authenticate(store), time + 1000);
120119
}
121120
});
122121
}

src/shared/actions/challenge-listing/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import _ from 'lodash';
66
import { createActions } from 'redux-actions';
7-
import { decodeToken } from 'tc-accounts';
7+
import { decodeToken } from '@topcoder-platform/tc-auth-lib';
88
import 'isomorphic-fetch';
99
import { processSRM } from 'utils/tc';
1010
import { errors, services } from 'topcoder-react-lib';

src/shared/components/TopcoderFooter/index.jsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import cookies from 'browser-cookies';
12
import moment from 'moment';
23
import PT from 'prop-types';
34
import React from 'react';
45

5-
import { config } from 'topcoder-react-utils';
6+
import { config, isomorphy } from 'topcoder-react-utils';
67

78
import FacebookIcon from './icons/icon-fb.svg';
89
import YouTubeIcon from './icons/icon-youtube.svg';
@@ -33,6 +34,9 @@ Link.propTypes = {
3334

3435
export default function TopcoderFooter() {
3536
const base = config.URL.BASE;
37+
const authUrl = config.URL.AUTH;
38+
const retUrl = isomorphy.isClientSide() ? encodeURIComponent(window.location.href) : '';
39+
const loggedIn = isomorphy.isClientSide() && cookies.get('tcjwt') !== null;
3640
const currentYear = moment().year();
3741
return (
3842
<div styleName="footer" role="contentinfo">
@@ -90,7 +94,9 @@ export default function TopcoderFooter() {
9094
<ul styleName="navi-col-links">
9195
<Link to={`${base}/community/admins`}>Admins</Link>
9296
<Link to={`${base}/community/contact`}>Contact Us</Link>
93-
<Link to="https://accounts.topcoder.com/member/registration?utm_source=community&utm_campaign=tc-footer&utm_medium=promotion">Join Community</Link>
97+
{!loggedIn
98+
&& <Link to={`${authUrl}?utm_source=community&utm_campaign=tc-footer&utm_medium=promotion&retUrl=${retUrl}`}>Join Community</Link>
99+
}
94100
<Link to={`${base}/community/learn`}>About Community</Link>
95101
<Link to={`${base}/community/changelog`}>Changelog</Link>
96102
<Link to={`${base}/contact-us/`}>Talk to Sales</Link>

src/shared/components/challenge-detail/MySubmissions/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import PT from 'prop-types';
77
import _ from 'lodash';
88
import { goToLogin } from 'utils/tc';
99
import LoadingIndicator from 'components/LoadingIndicator';
10-
import { isTokenExpired } from 'tc-accounts';
10+
import { isTokenExpired } from '@topcoder-platform/tc-auth-lib';
1111

1212
import SubmissionsList from './SubmissionsList';
1313
import SubmissionsDetail from './SubmissionsDetail';

src/shared/components/challenge-detail/Submissions/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import _ from 'lodash';
1111
import { connect } from 'react-redux';
1212
import { config } from 'topcoder-react-utils';
1313
import { submission as submissionUtils } from 'topcoder-react-lib';
14-
import { isTokenExpired } from 'tc-accounts';
14+
import { isTokenExpired } from '@topcoder-platform/tc-auth-lib';
1515
import cn from 'classnames';
1616
import { PrimaryButton } from 'topcoder-react-ui-kit';
1717

src/shared/components/tc-communities/Header/index.jsx

+15-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import DesktopSubMenu from 'components/TopcoderHeader/desktop/SubMenu';
1212
import React from 'react';
1313
import PT from 'prop-types';
1414
import { Avatar, PrimaryButton, Button } from 'topcoder-react-ui-kit';
15-
import { config, Link, NavLink } from 'topcoder-react-utils';
15+
import {
16+
config,
17+
Link,
18+
NavLink,
19+
isomorphy,
20+
} from 'topcoder-react-utils';
1621
import { getRatingColor } from 'utils/tc';
1722
import Dropdown from 'components/tc-communities/Dropdown';
1823
import { themr } from 'react-css-super-themr';
@@ -47,10 +52,13 @@ function Header(props) {
4752
onMobileToggleClick,
4853
profile,
4954
theme,
50-
logoutRedirect,
5155
meta,
5256
} = props;
5357

58+
let {
59+
logoutRedirect,
60+
} = props;
61+
5462
const BASE_URL = config.URL.BASE;
5563
const AUTH_URL = config.URL.AUTH;
5664
const normalizedProfile = profile && _.clone(profile);
@@ -59,6 +67,10 @@ function Header(props) {
5967
meta.competitorsGroupIds,
6068
) : [];
6169

70+
if (_.isEmpty(logoutRedirect) && isomorphy.isClientSide()) {
71+
logoutRedirect = window.location.href;
72+
}
73+
6274
let userSubMenu;
6375
if (profile) {
6476
userSubMenu = {
@@ -81,7 +93,7 @@ function Header(props) {
8193
icon: <IconNavExit />,
8294
// TODO: In addition to hitting ${AUTH_URL}/logout, which logs out
8395
// from the accounts-app, we should wipe out auth cookies!
84-
link: `${AUTH_URL}/logout?retUrl=${logoutRedirect}`,
96+
link: `${AUTH_URL}?logout=true&retUrl=${encodeURIComponent(logoutRedirect)}`,
8597
title: 'Log Out',
8698
}],
8799
};

src/shared/containers/Dashboard/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { updateChallengeType } from 'utils/challenge';
2525
import challengeListingActions from 'actions/challenge-listing';
2626
import communityActions from 'actions/tc-communities';
2727

28-
import { isTokenExpired, decodeToken } from 'tc-accounts';
28+
import { isTokenExpired, decodeToken } from '@topcoder-platform/tc-auth-lib';
2929
import { config, isomorphy } from 'topcoder-react-utils';
3030

3131
import './styles.scss';

0 commit comments

Comments
 (0)