Skip to content

Commit cbfa7f1

Browse files
authored
Merge pull request #5108 from topcoder-platform/feature/auth0-RS256-Idtoken
Feature/auth0 rs256 idtoken
2 parents 12adaec + 319a61e commit cbfa7f1

File tree

25 files changed

+42
-51
lines changed

25 files changed

+42
-51
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ workflows:
230230
filters:
231231
branches:
232232
only:
233-
- hot-fix
233+
- feature/auth0-RS256-Idtoken
234+
- develop
234235
# This is alternate dev env for parallel testing
235236
- "build-test":
236237
context : org-global
@@ -260,7 +261,6 @@ workflows:
260261
branches:
261262
only:
262263
- develop
263-
- listing-develop-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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 14 deletions
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',
@@ -384,8 +374,8 @@ module.exports = {
384374
],
385375
HEADER_MENU_THEME: 'light',
386376
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',
377+
href: 'https://accounts-auth0.topcoder-dev.com?utm_source=community-app-main',
378+
location: 'https://accounts-auth0.topcoder-dev.com?retUrl=%S&utm_source=community-app-main',
389379
},
390380
ACCOUNT_MENU: [
391381
{

config/jest/default.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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,7 +39,7 @@ 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/',
4444

4545
TOPGEAR: 'https://topgear-app.wipro.com',
@@ -184,8 +184,8 @@ module.exports = {
184184
],
185185
HEADER_MENU_THEME: 'light',
186186
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',
187+
href: 'https://accounts-auth0.topcoder.com?utm_source=community-app-main',
188+
location: 'https://accounts-auth0.topcoder.com?retUrl=%S&utm_source=community-app-main',
189189
},
190190
ACCOUNT_MENU: [
191191
{

config/webpack/development.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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.2",
144144
"topcoder-react-ui-kit": "2.0.1",
145145
"topcoder-react-utils": "0.7.8",
146146
"turndown": "^4.0.2",

src/client/index.jsx

Lines changed: 3 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import moment from 'moment';
22
import PT from 'prop-types';
33
import React from 'react';
44

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

77
import FacebookIcon from './icons/icon-fb.svg';
88
import YouTubeIcon from './icons/icon-youtube.svg';
@@ -33,6 +33,8 @@ Link.propTypes = {
3333

3434
export default function TopcoderFooter() {
3535
const base = config.URL.BASE;
36+
const auth = config.URL.AUTH;
37+
const retUrl = isomorphy.isClientSide() ? encodeURIComponent(window.location.href) : '';
3638
const currentYear = moment().year();
3739
return (
3840
<div styleName="footer" role="contentinfo">
@@ -90,7 +92,7 @@ export default function TopcoderFooter() {
9092
<ul styleName="navi-col-links">
9193
<Link to={`${base}/community/admins`}>Admins</Link>
9294
<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>
95+
<Link to={`${auth}?utm_source=community&utm_campaign=tc-footer&utm_medium=promotion&retUrl=${retUrl}`}>Join Community</Link>
9496
<Link to={`${base}/community/learn`}>About Community</Link>
9597
<Link to={`${base}/community/changelog`}>Changelog</Link>
9698
<Link to={`${base}/contact-us/`}>Talk to Sales</Link>

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/containers/Dashboard/index.jsx

Lines changed: 1 addition & 1 deletion
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';

src/shared/containers/EmailVerification/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import PT from 'prop-types';
88
import {connect} from "react-redux";
99
import { actions } from "topcoder-react-lib";
1010
import { Redirect } from 'react-router';
11-
import {isTokenExpired} from "tc-accounts";
11+
import {isTokenExpired} from '@topcoder-platform/tc-auth-lib';
1212
import * as queryString from 'query-string';
1313
import LoadingIndicator from 'components/LoadingIndicator';
1414
import Error404 from 'components/Error404';

src/shared/containers/Settings.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import React from 'react';
66
import PT from 'prop-types';
77
import { connect } from 'react-redux';
88

9-
import { isTokenExpired } from 'tc-accounts';
9+
import { isTokenExpired } from '@topcoder-platform/tc-auth-lib';
1010
import { goToLogin } from 'utils/tc';
1111

1212
import { actions } from 'topcoder-react-lib';

src/shared/reducers/tc-communities/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import _ from 'lodash';
88
import actions from 'actions/tc-communities';
99
import { logger, services, errors } from 'topcoder-react-lib';
1010
import { handleActions } from 'redux-actions';
11-
import { decodeToken } from 'tc-accounts';
11+
import { decodeToken } from '@topcoder-platform/tc-auth-lib';
1212
import { getAuthTokens } from 'utils/tc';
1313
import { STATE as JOIN_COMMUNITY } from 'components/tc-communities/JoinCommunity';
1414
import { getCommunityId } from 'server/services/communities';

src/shared/utils/tc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import _ from 'lodash';
77
import moment from 'moment-timezone';
8-
import { isTokenExpired } from 'tc-accounts';
8+
import { isTokenExpired } from '@topcoder-platform/tc-auth-lib';
99
import { config, isomorphy } from 'topcoder-react-utils';
1010

1111
import { tc } from 'topcoder-react-lib';

0 commit comments

Comments
 (0)