Skip to content

Feature/auth0 rs256 idtoken #5108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e17f656
new auth0 url
Sep 4, 2020
ba6c11f
just for bypassing condition - https://github.com/topcoder-platform/n…
Sep 4, 2020
038a06f
fixing unit testing
Sep 7, 2020
238edf3
adding changes for new auth flow
Sep 8, 2020
a39e6a5
fixing yml issue
Sep 8, 2020
378bf27
fixing yml issue
Sep 8, 2020
6d48664
deploying after fixing lodash issue
Sep 9, 2020
5a4fe97
typo
Sep 9, 2020
599b236
changing auth url
Sep 9, 2020
59b4800
fixing unit test
Sep 9, 2020
5e319d0
Merge remote-tracking branch 'origin/develop' into feature/auth0-RS25…
sushilshinde Sep 16, 2020
4119aca
ci: deploying to stage and dev envs
sushilshinde Sep 18, 2020
ca7459e
Remove reauth from Frontend
luizrrodrigues Sep 18, 2020
7e91419
Merge pull request #4958 from topcoder-platform/issue-4953
luizrrodrigues Sep 18, 2020
e84f2cf
fix: prod auth0 domain url
sushilshinde Sep 22, 2020
db61f47
Re added refresh token to community-app
luizrrodrigues Sep 22, 2020
9624bf7
Merge pull request #4985 from topcoder-platform/issue-4953-hotfix
luizrrodrigues Sep 22, 2020
f6e5c5e
Fix Prod Auth0 url's
luizrrodrigues Sep 22, 2020
ac734d7
Fix https to Auth
luizrrodrigues Sep 22, 2020
95c327c
Fix URL.AUTH https to Dev
luizrrodrigues Sep 22, 2020
dcc3aa1
Fix snapshot
luizrrodrigues Sep 22, 2020
5970c21
Updated tc-auth-lib name
luizrrodrigues Sep 30, 2020
630e97c
Change tc-auth-lib name
luizrrodrigues Sep 30, 2020
4a97b20
Added @topcoder to babel transform ignore
luizrrodrigues Oct 2, 2020
0e94dd3
Merge pull request #5021 from topcoder-platform/issue-4997
luizrrodrigues Oct 2, 2020
f70d2c4
Merge branch 'develop' into feature/auth0-RS256-Idtoken
luizrrodrigues Oct 13, 2020
c853a0c
fix: for issue #4937
luizrrodrigues Oct 13, 2020
862c044
Updated footer Join Community link to new Auth0
luizrrodrigues Oct 14, 2020
319a61e
Merge branch 'develop-auth0-sync' into feature/auth0-RS256-Idtoken
sushilshinde Oct 15, 2020
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ workflows:
filters:
branches:
only:
- hot-fix
- feature/auth0-RS256-Idtoken
- develop
# This is alternate dev env for parallel testing
- "build-test":
context : org-global
Expand Down Expand Up @@ -260,7 +261,6 @@ workflows:
branches:
only:
- develop
- listing-develop-sync
# Production builds are exectuted
# when PR is merged to the master
# Don't change anything in this configuration
Expand Down
2 changes: 1 addition & 1 deletion __tests__/client/client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const mockTcAccounts = {
decodeToken: () => ({ exp: Date.now() }),
getFreshToken: () => Promise.resolve(tokenV3),
};
jest.setMock('tc-accounts', mockTcAccounts);
jest.setMock('@topcoder-platform/tc-auth-lib', mockTcAccounts);

/* Mock auth actions */
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ exports[`Default render 1`] = `
auth={null}
authURLs={
Object {
"href": "https://accounts.topcoder-dev.com/member/registration?utm_source=community-app-main",
"location": "https://accounts.topcoder-dev.com/member?retUrl=%S&utm_source=community-app-main",
"href": "https://accounts-auth0.topcoder-dev.com?utm_source=community-app-main",
"location": "https://accounts-auth0.topcoder-dev.com?retUrl=%S&utm_source=community-app-main",
}
}
loggedIn={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ exports[`Matches shallow shapshot 1`] = `
className="src-shared-components-TopcoderFooter-___style__link___3-nzm"
>
<a
href="https://accounts.topcoder.com/member/registration?utm_source=community&utm_campaign=tc-footer&utm_medium=promotion"
href="https://accounts-auth0.topcoder-dev.com?utm_source=community&utm_campaign=tc-footer&utm_medium=promotion&retUrl="
>
Join Community
</a>
Expand Down
8 changes: 4 additions & 4 deletions __tests__/shared/components/tc-communities/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ test('render properly', () => {
<Wrapper
menuItems={[]}
communityId="wipro"
registerUrl="https://accounts.topcoder-dev.com/member/registration"
loginUrl="https://accounts.topcoder-dev.com/member"
registerUrl="https://accounts-auth0.topcoder-dev.com/member/registration"
loginUrl="https://accounts-auth0.topcoder-dev.com/member"
isAuthorized
/>
));
Expand All @@ -63,8 +63,8 @@ test('render properly', () => {
url: 'leaderboard',
}]}
communityId="wipro"
registerUrl="https://accounts.topcoder-dev.com/member/registration"
loginUrl="https://accounts.topcoder-dev.com/member"
registerUrl="https://accounts-auth0.topcoder-dev.com/member/registration"
loginUrl="https://accounts-auth0.topcoder-dev.com/member"
isAuthorized={false}
theme={{
container: 'container',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports[`Matches shallow shapshot 1`] = `
>
<a
className="tc-btn-md tc-btn-primary"
href="http://accounts.topcoder-dev.com/member?utm_source="
href="https://accounts-auth0.topcoder-dev.com/member?utm_source="
onClick={[Function]}
>
Log In Here
Expand Down
2 changes: 1 addition & 1 deletion __tests__/shared/reducers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const mockActions = {

_.merge(actions, mockActions);

jest.setMock('tc-accounts', {
jest.setMock('@topcoder-platform/tc-auth-lib', {
decodeToken: () => 'User object',
isTokenExpired: () => false,
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/shared/reducers/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { mock, actions } from 'topcoder-react-lib';

const { mockAction } = mock;

jest.setMock('tc-accounts', {
jest.setMock('@topcoder-platform/tc-auth-lib', {
decodeToken: () => 'User object',
isTokenExpired: () => false,
});
Expand Down
2 changes: 1 addition & 1 deletion bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* Enables Babel for the server-side code (with exception of this very file). */
require('babel-register')({
ignore: [
/node_modules\/(?!appirio-tech.*|topcoder|tc-)/,
/node_modules\/(?!appirio-tech.*|topcoder|tc-|@topcoder)/,
/node_modules\/topcoder-react-utils/,
],
});
Expand Down
18 changes: 4 additions & 14 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ module.exports = {
},
},

/* Amount of time [seconds] before expiration of authentication tokens,
* when the frontend will automatically trigger their refreshment. Once
* ready, it will either write to the Redux store fresh token, or will
* remove auth tokens from the store.
* NOTE: With the current implementation of accounts-app this value must be
* smaller than 60 seconds (earlier than 60 seconds before expiration of an
* auth token, a call to the getFreshToken() method returns the old token,
* due to caching). */
REAUTH_TIME: 55,

/* API key for Segment.io. For development environment the value is set inside
* development.json, for production environment it is set via CircleCI
* variables. */
Expand All @@ -104,7 +94,7 @@ module.exports = {
* platform. */
URL: {
/* Connector URL of the TC accounts App. */
ACCOUNTS_APP_CONNECTOR: 'https://accounts.topcoder-dev.com/connector.html',
ACCOUNTS_APP_CONNECTOR: 'https://accounts-auth0.topcoder-dev.com',

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

ARENA: 'https://arena.topcoder-dev.com',
AUTH: 'http://accounts.topcoder-dev.com',
AUTH: 'https://accounts-auth0.topcoder-dev.com',
BASE: 'https://www.topcoder-dev.com',
HOME: '/my-dashboard',
BLOG: 'https://www.topcoder-dev.com/blog',
Expand Down Expand Up @@ -384,8 +374,8 @@ module.exports = {
],
HEADER_MENU_THEME: 'light',
HEADER_AUTH_URLS: {
href: 'https://accounts.topcoder-dev.com/member/registration?utm_source=community-app-main',
location: 'https://accounts.topcoder-dev.com/member?retUrl=%S&utm_source=community-app-main',
href: 'https://accounts-auth0.topcoder-dev.com?utm_source=community-app-main',
location: 'https://accounts-auth0.topcoder-dev.com?retUrl=%S&utm_source=community-app-main',
},
ACCOUNT_MENU: [
{
Expand Down
2 changes: 1 addition & 1 deletion config/jest/default.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = require('topcoder-react-utils/config/jest/default');
const nodeConfig = require('config');

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

// Include the directories whose tests has been written to minimize coverage time
Expand Down
8 changes: 4 additions & 4 deletions config/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
* as a more verbose name for the param. */
COMMUNITY_APP: 'https://community-app.topcoder.com',

AUTH: 'https://accounts.topcoder.com',
AUTH: 'https://accounts-auth0.topcoder.com',
BASE: 'https://www.topcoder.com',
HOME: '/my-dashboard',
COMMUNITY: 'https://community.topcoder.com',
Expand All @@ -39,7 +39,7 @@ module.exports = {
IOS: 'https://ios.topcoder.com',

/* Connector URL of the TC accounts App. */
ACCOUNTS_APP_CONNECTOR: 'https://accounts.topcoder.com/connector.html',
ACCOUNTS_APP_CONNECTOR: 'https://accounts-auth0.topcoder.com/',
TCO17: 'https://tco17.topcoder.com/',

TOPGEAR: 'https://topgear-app.wipro.com',
Expand Down Expand Up @@ -184,8 +184,8 @@ module.exports = {
],
HEADER_MENU_THEME: 'light',
HEADER_AUTH_URLS: {
href: 'https://accounts.topcoder.com/member/registration?utm_source=community-app-main',
location: 'https://accounts.topcoder.com/member?retUrl=%S&utm_source=community-app-main',
href: 'https://accounts-auth0.topcoder.com?utm_source=community-app-main',
location: 'https://accounts-auth0.topcoder.com?retUrl=%S&utm_source=community-app-main',
},
ACCOUNT_MENU: [
{
Expand Down
2 changes: 1 addition & 1 deletion config/webpack/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const standardDevelopmentConfig = configFactory({

const jsxRule = standardDevelopmentConfig.module.rules.find(rule => rule.loader === 'babel-loader');
jsxRule.exclude = [
/node_modules[\\/](?!appirio-tech.*|topcoder|tc-)/,
/node_modules[\\/](?!appirio-tech.*|topcoder|tc-|@topcoder)/,
/src[\\/]assets[\\/]fonts/,
/src[\\/]assets[\\/]images[\\/]dashboard/,
];
Expand Down
2 changes: 1 addition & 1 deletion config/webpack/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const standardDevelopmentConfig = configFactory({

const jsxRule = standardDevelopmentConfig.module.rules.find(rule => rule.loader === 'babel-loader');
jsxRule.exclude = [
/node_modules[\\/](?!appirio-tech.*|topcoder|tc-)/,
/node_modules[\\/](?!appirio-tech.*|topcoder|tc-|@topcoder)/,
/src[\\/]assets[\\/]fonts/,
/src[\\/]assets[\\/]images[\\/]dashboard/,
];
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"dependencies": {
"@hapi/joi": "^16.1.4",
"@topcoder-platform/tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.1",
"aos": "^2.3.4",
"atob": "^2.1.1",
"babel-register": "^6.26.0",
Expand Down Expand Up @@ -137,10 +138,9 @@
"showdown": "^1.8.6",
"slick-carousel": "^1.8.1",
"supertest": "^3.1.0",
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
"tc-ui": "^1.0.12",
"topcoder-react-lib": "1.0.8",
"topcoder-react-lib": "1000.23.2",
"topcoder-react-ui-kit": "2.0.1",
"topcoder-react-utils": "0.7.8",
"turndown": "^4.0.2",
Expand Down
7 changes: 3 additions & 4 deletions src/client/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
configureConnector,
decodeToken,
getFreshToken,
} from 'tc-accounts';
} from '@topcoder-platform/tc-auth-lib';
import { actions, logger, errors } from 'topcoder-react-lib';
import { client, redux } from 'topcoder-react-utils';

Expand Down Expand Up @@ -113,10 +113,9 @@ function authenticate(store) {
if (tctV2) time = decodeToken(tctV2).exp;
if (userV3) time = Math.min(time, userV3.exp);
if (time < Number.MAX_VALUE) {
time = 1000 * (time - window.CONFIG.REAUTH_TIME);
time = Math.max(0, time - Date.now());
time = Math.max(1000, (time * 1000) - Date.now());
logger.log('Reauth scheduled in', time / 1000, 'seconds');
setTimeout(() => authenticate(store), time);
setTimeout(() => authenticate(store), time + 1000);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/actions/challenge-listing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import _ from 'lodash';
import { createActions } from 'redux-actions';
import { decodeToken } from 'tc-accounts';
import { decodeToken } from '@topcoder-platform/tc-auth-lib';
import 'isomorphic-fetch';
import { processSRM } from 'utils/tc';
import { errors, services } from 'topcoder-react-lib';
Expand Down
6 changes: 4 additions & 2 deletions src/shared/components/TopcoderFooter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import moment from 'moment';
import PT from 'prop-types';
import React from 'react';

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

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

export default function TopcoderFooter() {
const base = config.URL.BASE;
const auth = config.URL.AUTH;
const retUrl = isomorphy.isClientSide() ? encodeURIComponent(window.location.href) : '';
const currentYear = moment().year();
return (
<div styleName="footer" role="contentinfo">
Expand Down Expand Up @@ -90,7 +92,7 @@ export default function TopcoderFooter() {
<ul styleName="navi-col-links">
<Link to={`${base}/community/admins`}>Admins</Link>
<Link to={`${base}/community/contact`}>Contact Us</Link>
<Link to="https://accounts.topcoder.com/member/registration?utm_source=community&utm_campaign=tc-footer&utm_medium=promotion">Join Community</Link>
<Link to={`${auth}?utm_source=community&utm_campaign=tc-footer&utm_medium=promotion&retUrl=${retUrl}`}>Join Community</Link>
<Link to={`${base}/community/learn`}>About Community</Link>
<Link to={`${base}/community/changelog`}>Changelog</Link>
<Link to={`${base}/contact-us/`}>Talk to Sales</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PT from 'prop-types';
import _ from 'lodash';
import { goToLogin } from 'utils/tc';
import LoadingIndicator from 'components/LoadingIndicator';
import { isTokenExpired } from 'tc-accounts';
import { isTokenExpired } from '@topcoder-platform/tc-auth-lib';

import SubmissionsList from './SubmissionsList';
import SubmissionsDetail from './SubmissionsDetail';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import _ from 'lodash';
import { connect } from 'react-redux';
import { config } from 'topcoder-react-utils';
import { submission as submissionUtils } from 'topcoder-react-lib';
import { isTokenExpired } from 'tc-accounts';
import { isTokenExpired } from '@topcoder-platform/tc-auth-lib';
import cn from 'classnames';
import { PrimaryButton } from 'topcoder-react-ui-kit';

Expand Down
2 changes: 1 addition & 1 deletion src/shared/containers/Dashboard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { updateChallengeType } from 'utils/challenge';
import challengeListingActions from 'actions/challenge-listing';
import communityActions from 'actions/tc-communities';

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

import './styles.scss';
Expand Down
2 changes: 1 addition & 1 deletion src/shared/containers/EmailVerification/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PT from 'prop-types';
import {connect} from "react-redux";
import { actions } from "topcoder-react-lib";
import { Redirect } from 'react-router';
import {isTokenExpired} from "tc-accounts";
import {isTokenExpired} from '@topcoder-platform/tc-auth-lib';
import * as queryString from 'query-string';
import LoadingIndicator from 'components/LoadingIndicator';
import Error404 from 'components/Error404';
Expand Down
2 changes: 1 addition & 1 deletion src/shared/containers/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React from 'react';
import PT from 'prop-types';
import { connect } from 'react-redux';

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

import { actions } from 'topcoder-react-lib';
Expand Down
2 changes: 1 addition & 1 deletion src/shared/reducers/tc-communities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import _ from 'lodash';
import actions from 'actions/tc-communities';
import { logger, services, errors } from 'topcoder-react-lib';
import { handleActions } from 'redux-actions';
import { decodeToken } from 'tc-accounts';
import { decodeToken } from '@topcoder-platform/tc-auth-lib';
import { getAuthTokens } from 'utils/tc';
import { STATE as JOIN_COMMUNITY } from 'components/tc-communities/JoinCommunity';
import { getCommunityId } from 'server/services/communities';
Expand Down
2 changes: 1 addition & 1 deletion src/shared/utils/tc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

import { tc } from 'topcoder-react-lib';
Expand Down