Skip to content

Commit 2211bb7

Browse files
authored
Revert "Handle token expiration in SSO (#611)" (#815)
This reverts commit 001cee1.
1 parent 2a33380 commit 2211bb7

File tree

7 files changed

+13
-108
lines changed

7 files changed

+13
-108
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
"mui-color": "^2.0.0-beta.2",
7373
"mui-nested-menu": "^3.2.1",
7474
"neo4j-client-sso": "^1.2.2",
75-
"neo4j-driver": "^5.12.0",
7675
"openai": "^3.3.0",
7776
"postcss": "^8.4.21",
7877
"postcss-loader": "^7.2.4",

src/application/ApplicationActions.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* This file contains all state-changing actions relevant for the main application.
33
*/
44

5-
import { SSOProviderOriginal } from 'neo4j-client-sso';
6-
75
export const CLEAR_NOTIFICATION = 'APPLICATION/CLEAR_NOTIFICATION';
86
export const clearNotification = () => ({
97
type: CLEAR_NOTIFICATION,
@@ -58,11 +56,10 @@ export const setConnectionProperties = (
5856
port: string,
5957
database: string,
6058
username: string,
61-
password: string,
62-
ssoProviders?: SSOProviderOriginal[]
59+
password: string
6360
) => ({
6461
type: SET_CONNECTION_PROPERTIES,
65-
payload: { protocol, url, port, database, username, password, ssoProviders },
62+
payload: { protocol, url, port, database, username, password },
6663
});
6764

6865
export const SET_BASIC_CONNECTION_PROPERTIES = 'APPLICATION/SET_BASIC_CONNECTION_PROPERTIES';

src/application/ApplicationReducer.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const initialState = {
6464
database: '',
6565
username: 'neo4j',
6666
password: '',
67-
ssoProviders: [],
6867
},
6968
shareDetails: undefined,
7069
desktopConnection: null,
@@ -247,7 +246,7 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
247246
return state;
248247
}
249248
case SET_CONNECTION_PROPERTIES: {
250-
const { protocol, url, port, database, username, password, ssoProviders } = payload;
249+
const { protocol, url, port, database, username, password } = payload;
251250
state = update(state, {
252251
connection: {
253252
protocol: protocol,
@@ -256,7 +255,6 @@ export const applicationReducer = (state = initialState, action: { type: any; pa
256255
database: database,
257256
username: username,
258257
password: password,
259-
ssoProviders,
260258
},
261259
});
262260
return state;

src/application/ApplicationThunks.ts

Lines changed: 7 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createDriver } from 'use-neo4j';
12
import { initializeSSO } from '../component/sso/SSOUtils';
23
import { DEFAULT_SCREEN, Screens } from '../config/ApplicationConfig';
34
import { setDashboard } from '../dashboard/DashboardActions';
@@ -43,9 +44,6 @@ import {
4344
} from './ApplicationActions';
4445
import { setLoggingMode, setLoggingDatabase, setLogErrorNotification } from './logging/LoggingActions';
4546
import { version } from '../modal/AboutModal';
46-
import neo4j, { auth, authTokenManagers } from 'neo4j-driver';
47-
import type { Neo4jScheme } from 'use-neo4j/dist/neo4j-config.interface';
48-
import { SSOProviderOriginal, handleRefreshingToken } from 'neo4j-client-sso';
4947
import { applicationIsStandalone } from './ApplicationSelectors';
5048
import { applicationGetLoggingSettings } from './logging/LoggingSelectors';
5149
import { createLogThunk } from './logging/LoggingThunk';
@@ -56,47 +54,6 @@ import { createUUID } from '../utils/uuid';
5654
* Several actions/other thunks may be dispatched from here.
5755
*/
5856

59-
export const createDriver = (
60-
scheme: Neo4jScheme,
61-
host: string,
62-
port: string | number,
63-
username?: string,
64-
password?: string,
65-
config?: { userAgent?: string },
66-
ssoProviders: SSOProviderOriginal[] = []
67-
) => {
68-
if (ssoProviders.length > 0) {
69-
const authTokenMgr = authTokenManagers.bearer({
70-
tokenProvider: async () => {
71-
const credentials = await handleRefreshingToken(ssoProviders);
72-
const token = auth.bearer(credentials.password);
73-
// Get the expiration from the JWT's payload, which is a JSON string encoded
74-
// using base64. You could also use a JWT parsing lib
75-
const [, payloadBase64] = credentials.password.split('.');
76-
const payload: unknown = JSON.parse(window.atob(payloadBase64 ?? ''));
77-
let expiration: Date;
78-
if (typeof payload === 'object' && payload !== null && 'exp' in payload) {
79-
expiration = new Date(Number(payload.exp) * 1000);
80-
} else {
81-
expiration = new Date();
82-
}
83-
84-
return {
85-
expiration,
86-
token,
87-
};
88-
},
89-
});
90-
return neo4j.driver(`${scheme}://${host}:${port}`, authTokenMgr, config);
91-
}
92-
93-
if (!username || !password) {
94-
return neo4j.driver(`${scheme}://${host}:${port}`);
95-
}
96-
97-
return neo4j.driver(`${scheme}://${host}:${port}`, neo4j.auth.basic(username, password), config);
98-
};
99-
10057
/**
10158
* Establish a connection to Neo4j with the specified credentials. Open/close the relevant windows when connection is made (un)successfully.
10259
* @param protocol - the neo4j protocol (e.g. bolt, bolt+s, neo4j+s, ...)
@@ -105,24 +62,14 @@ export const createDriver = (
10562
* @param database - the Neo4j database to connect to.
10663
* @param username - Neo4j username.
10764
* @param password - Neo4j password.
108-
* @param SSOProviders - List of available SSO providers
10965
*/
11066
export const createConnectionThunk =
111-
(protocol, url, port, database, username, password, SSOProviders = []) =>
112-
(dispatch: any, getState: any) => {
67+
(protocol, url, port, database, username, password) => (dispatch: any, getState: any) => {
11368
const loggingState = getState();
11469
const loggingSettings = applicationGetLoggingSettings(loggingState);
11570
const neodashMode = applicationIsStandalone(loggingState) ? 'Standalone' : 'Editor';
11671
try {
117-
const driver = createDriver(
118-
protocol,
119-
url,
120-
port,
121-
username,
122-
password,
123-
{ userAgent: `neodash/v${version}` },
124-
SSOProviders
125-
);
72+
const driver = createDriver(protocol, url, port, username, password, { userAgent: `neodash/v${version}` });
12673
// eslint-disable-next-line no-console
12774
console.log('Attempting to connect...');
12875
const validateConnection = (records) => {
@@ -561,7 +508,7 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
561508
dispatch(setAboutModalOpen(false));
562509
dispatch(setConnected(false));
563510
dispatch(setWelcomeScreenOpen(false));
564-
const success = await initializeSSO(state.application.cachedSSODiscoveryUrl, (credentials, ssoProviders) => {
511+
const success = await initializeSSO(state.application.cachedSSODiscoveryUrl, (credentials) => {
565512
if (standalone) {
566513
// Redirected from SSO and running in viewer mode, merge retrieved config with hardcoded credentials.
567514
dispatch(
@@ -571,8 +518,7 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
571518
config.standalonePort,
572519
config.standaloneDatabase,
573520
credentials.username,
574-
credentials.password,
575-
ssoProviders
521+
credentials.password
576522
)
577523
);
578524
dispatch(
@@ -582,8 +528,7 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
582528
config.standalonePort,
583529
config.standaloneDatabase,
584530
credentials.username,
585-
credentials.password,
586-
ssoProviders
531+
credentials.password
587532
)
588533
);
589534
} else {
@@ -595,8 +540,7 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
595540
state.application.connection.port,
596541
state.application.connection.database,
597542
credentials.username,
598-
credentials.password,
599-
ssoProviders
543+
credentials.password
600544
)
601545
);
602546
dispatch(setConnected(true));

src/component/sso/SSOUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const initializeSSO = async (cachedSSODiscoveryUrl, _setCredentials) => {
118118
// Successful credentials retrieval.
119119
// Log in at the Neo4j dbms now using the Neo4j (js) driver.
120120
//
121-
_setCredentials(credentials, mergedSSOProviders);
121+
_setCredentials(credentials);
122122

123123
// Exemplifying retrieval of stored URL paramenters
124124
_retrieveAdditionalURLParameters();

src/dashboard/Dashboard.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ import NeoPage from '../page/Page';
33
import NeoDashboardHeader from './header/DashboardHeader';
44
import NeoDashboardTitle from './header/DashboardTitle';
55
import NeoDashboardHeaderPageList from './header/DashboardHeaderPageList';
6-
import { Neo4jProvider } from 'use-neo4j';
6+
import { createDriver, Neo4jProvider } from 'use-neo4j';
77
import { applicationGetConnection, applicationGetStandaloneSettings } from '../application/ApplicationSelectors';
88
import { connect } from 'react-redux';
99
import NeoDashboardConnectionUpdateHandler from '../component/misc/DashboardConnectionUpdateHandler';
1010
import { forceRefreshPage } from '../page/PageActions';
1111
import { getPageNumber } from '../settings/SettingsSelectors';
1212
import { createNotificationThunk } from '../page/PageThunks';
1313
import { version } from '../modal/AboutModal';
14-
import { createDriver } from '../application/ApplicationThunks';
1514
import NeoDashboardSidebar from './sidebar/DashboardSidebar';
1615

1716
const Dashboard = ({
@@ -33,10 +32,8 @@ const Dashboard = ({
3332
connection.port,
3433
connection.username,
3534
connection.password,
36-
{ userAgent: `neodash/v${version}` },
37-
connection.ssoProviders
35+
{ userAgent: `neodash/v${version}` }
3836
);
39-
// @ts-ignore wrong driver version
4037
setDriver(newDriver);
4138
}
4239
const content = (

yarn.lock

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10435,15 +10435,6 @@ neo4j-client-sso@^1.2.2:
1043510435
jwt-decode "^3.1.2"
1043610436
lodash.pick "^4.4.0"
1043710437

10438-
10439-
version "5.12.0"
10440-
resolved "https://registry.yarnpkg.com/neo4j-driver-bolt-connection/-/neo4j-driver-bolt-connection-5.12.0.tgz#aff161367d287579d7bdd3ee4179eed324398210"
10441-
integrity sha512-dlYbFsfT0HopGItitG5uDK4nAkcqSPNtRqMz318qy//7fb/7OXVLGYikj57Ve1toJiJD8IIVErt/dVuEUHVxGA==
10442-
dependencies:
10443-
buffer "^6.0.3"
10444-
neo4j-driver-core "5.12.0"
10445-
string_decoder "^1.3.0"
10446-
1044710438
neo4j-driver-bolt-connection@^4.4.10:
1044810439
version "4.4.10"
1044910440
resolved "https://registry.yarnpkg.com/neo4j-driver-bolt-connection/-/neo4j-driver-bolt-connection-4.4.10.tgz#a8b5b7f82b1d6f9a71a43eafcb0e21512ea24908"
@@ -10453,11 +10444,6 @@ neo4j-driver-bolt-connection@^4.4.10:
1045310444
neo4j-driver-core "^4.4.10"
1045410445
string_decoder "^1.3.0"
1045510446

10456-
10457-
version "5.12.0"
10458-
resolved "https://registry.yarnpkg.com/neo4j-driver-core/-/neo4j-driver-core-5.12.0.tgz#1f8616da7e945921574811368a68f5d2501bfd35"
10459-
integrity sha512-xBRi5oezysDUvtvBiIgBchzumkDZxvR9ol9sUtA9PBgVENeSmPH3CncitY8S979CFELS6wH7kydcjPLB4QMOzA==
10460-
1046110447
neo4j-driver-core@^4.4.10:
1046210448
version "4.4.10"
1046310449
resolved "https://registry.yarnpkg.com/neo4j-driver-core/-/neo4j-driver-core-4.4.10.tgz#6f4c1ccc1199f864b149bdcef5e50e45ff95c29e"
@@ -10473,15 +10459,6 @@ neo4j-driver@^4.4.5:
1047310459
neo4j-driver-core "^4.4.10"
1047410460
rxjs "^6.6.3"
1047510461

10476-
neo4j-driver@^5.12.0:
10477-
version "5.12.0"
10478-
resolved "https://registry.yarnpkg.com/neo4j-driver/-/neo4j-driver-5.12.0.tgz#1b2d7db1672ad224f0146542efee306a0a156a11"
10479-
integrity sha512-T2Vz63XDkL9TomM16dBusuXbo7d9SIGw2g3VR/rmrWTdbl1V1LYFx/u1P7AwBsFuX08oncKHfZwHGsWrCvdMyA==
10480-
dependencies:
10481-
neo4j-driver-bolt-connection "5.12.0"
10482-
neo4j-driver-core "5.12.0"
10483-
rxjs "^7.8.1"
10484-
1048510462
next-tick@1, next-tick@^1.0.0, next-tick@^1.1.0:
1048610463
version "1.1.0"
1048710464
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb"
@@ -12311,13 +12288,6 @@ rxjs@^7.5.1, rxjs@^7.5.5, rxjs@^7.8.0:
1231112288
dependencies:
1231212289
tslib "^2.1.0"
1231312290

12314-
rxjs@^7.8.1:
12315-
version "7.8.1"
12316-
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543"
12317-
integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==
12318-
dependencies:
12319-
tslib "^2.1.0"
12320-
1232112291
sade@^1.7.3:
1232212292
version "1.8.1"
1232312293
resolved "https://registry.yarnpkg.com/sade/-/sade-1.8.1.tgz#0a78e81d658d394887be57d2a409bf703a3b2701"

0 commit comments

Comments
 (0)