-
Notifications
You must be signed in to change notification settings - Fork 2
New: [AEA-6292] - Authentication redirect & blocking render improvements #1865
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
Changes from all commits
Commits
Show all changes
105 commits
Select commit
Hold shift + click to select a range
18b1a1e
Kick off env
connoravo-nhs 0d0ef11
Psuedo representation
connoravo-nhs d015274
Redirection reconfigured
connoravo-nhs ab3329d
Formatting
connoravo-nhs a86c653
Add todo clean ups
connoravo-nhs 2728205
Clean access provider
connoravo-nhs 2d748ff
Extend token mapping
connoravo-nhs 2762816
Clean up matrix changes, make them more human readable. Extend childr…
connoravo-nhs 41ccaf9
Fix access provider test for logged in root test
connoravo-nhs 2e98af8
Fix logoutpage tests
connoravo-nhs c3bde22
Introduce new requirements on mock object
connoravo-nhs de35f7c
Merge branch 'main' into AEA-6292
connoravo-nhs 93e23f4
run release #skip-qc
connoravo-nhs c9989f7
Merge branch 'main' into AEA-6292
connoravo-nhs d22c032
Further ironing out. If sign out fails, redirect to logout. Check for…
connoravo-nhs e7197eb
Fix concurrent sessions on multi-role continous loop conflict
connoravo-nhs e2a1b5c
Merge branch 'main' into AEA-6292
connoravo-nhs 9000f2f
Alter existing tests to work with adjustments
connoravo-nhs 91038df
WIP: Scenario run through for ensureRoleSelected - pages need waited …
connoravo-nhs b490100
Spplit blocking tests
connoravo-nhs 82c1f7a
Merge branch 'main' into AEA-6292
connoravo-nhs c3ce09e
Merge branch 'AEA-6292' of github.com-nhs:NHSDigital/eps-prescription…
connoravo-nhs a36e201
Fix frontend paths for ensureRoleSelected tests
connoravo-nhs cb69adf
should block children tests
connoravo-nhs 8ce83ca
Ensure tests match, cover missing scenarios. Ensure negative scenario…
connoravo-nhs 108b6f6
Merge branch 'main' into AEA-6292
connoravo-nhs 4568d0c
Fire actions
connoravo-nhs 39d777e
PR cleanup
connoravo-nhs b44f268
Merge branch 'main' into AEA-6292
connoravo-nhs 125d316
Handle new session isSignedIn on select your role, but deal with logg…
connoravo-nhs b521759
Merge branch 'main' into AEA-6292
connoravo-nhs 490ad05
Re-run but #skip-qc
connoravo-nhs a871bae
Introduce logout marker to detect logout on other tabs
connoravo-nhs 806e50b
Resolve test mock issues
connoravo-nhs c027753
trigger build
jonathanwelch1-nhs 6d19d7c
trigger build
jonathanwelch1-nhs 209dff3
Memory router wrapping
connoravo-nhs ac989c6
Reduce recent logout marker time
connoravo-nhs 146877b
fixed Buttons & ESC key can be spam clicked, leading to multiple sele…
jonathanwelch1-nhs 493405c
Tab awareness and logout marker
connoravo-nhs 4429929
fixed toms comments
jonathanwelch1-nhs 8097180
Fixes
connoravo-nhs 75c7cc9
improved test coverage
jonathanwelch1-nhs 11a88b5
Merge branch 'main' into aea-5884-comments-on-modal
jonathanwelch1-nhs 29944c7
Shuffle login to a helper func. Correct timing on signout process. WI…
connoravo-nhs 7df5151
sonarcloud refactoring
jonathanwelch1-nhs 96e1195
Merge remote-tracking branch 'origin' into aea-5884-comments-on-modal
jonathanwelch1-nhs fc3524b
Merge remote-tracking branch 'origin/aea-5884-comments-on-modal' into…
jonathanwelch1-nhs 713f1ea
updated text
jonathanwelch1-nhs 40a2e6c
Merge branch 'main' into aea-5884-comments-on-modal
connoravo-nhs 1d89176
Axios label
connoravo-nhs 916488a
Ensure RBAC isn't shown on duplicated tab logout page
connoravo-nhs be93e10
Fix require #skip-qc
connoravo-nhs cb83598
PR cleanup
connoravo-nhs 27476dd
Apply suggestion from @connoravo-nhs
connoravo-nhs 271bee8
TESTS REQ - Initial fixes to prevent both modals showing. Disable dup…
connoravo-nhs 0ff74b3
Linting and test adjustments
connoravo-nhs 4dbba97
Restore original test files - Changes not needed as access provider p…
connoravo-nhs 145bcac
Reset auth context in tests from prior
connoravo-nhs c619eac
Forgotten one
connoravo-nhs 51cb99b
Merge branch 'main' into aea-5884-comments-on-modal
connoravo-nhs 6a085ae
Update packages/cpt-ui/src/components/SessionTimeoutModal.tsx
connoravo-nhs bff556e
Update packages/cpt-ui/src/components/SessionTimeoutModal.tsx
connoravo-nhs 1e9f832
Environment var fixes
connoravo-nhs 4b81d9d
Log function name change & tab helper mocks
connoravo-nhs cedb257
Remove unneeded import
connoravo-nhs 80f26f4
Merge branch 'main' into AEA-6210
connoravo-nhs 501fb1b
Adjust initial timeLeft setting to be seconds
connoravo-nhs c4c8682
Reset time the modal pops up
connoravo-nhs e9cfb49
Potential fix for pull request finding
connoravo-nhs d7d7a51
Potential fix for pull request finding
connoravo-nhs f1693f4
Potential fix for pull request finding
connoravo-nhs 2871767
Potential fix for pull request finding
connoravo-nhs 2b2360b
Fix timeleft for all setters
connoravo-nhs 4524e75
Merge branch 'aea-5884-comments-on-modal' of github.com-nhs:NHSDigita…
connoravo-nhs a2f7a1f
Copilot suggestions refined and revert the useEffect changes as they …
connoravo-nhs 24194a2
Fix: [AEA-0000] - Trivy ignore currently recognised risk for fast-xml…
connoravo-nhs 11be413
Merge branch 'trivyignore180326' into aea-5884-comments-on-modal
connoravo-nhs 92cf471
Merge branch 'main' into aea-5884-comments-on-modal
connoravo-nhs 9457e62
Merge branch 'main' into AEA-6292
connoravo-nhs a262153
Fix user initiated logout modal not hiding on click
connoravo-nhs 7ec81cc
Removals
connoravo-nhs be990e8
Protect rum logs. Remove logout marker appropriately for new clicking…
connoravo-nhs 94c4d08
Fix concurrent sessions
connoravo-nhs 804705f
Fix some tests #skip-qc
connoravo-nhs 7b8b6f6
Test fixes
connoravo-nhs a11da04
Merge branch 'main' into AEA-6292
connoravo-nhs 43c21f6
Log out marker fixes #skip-qc
connoravo-nhs 0a5e846
Merge branch 'main' into AEA-6292
anthony-nhs f198907
Removing loading screens on select role and logout
connoravo-nhs 5a57d41
Merge branch 'AEA-6292' of github.com-nhs:NHSDigital/eps-prescription…
connoravo-nhs 45976e5
Fix logout marker timing and auto-delete if it's expired
connoravo-nhs e522e87
Merge branch 'main' into AEA-6292
connoravo-nhs ca9ce2f
Update regression test version
connoravo-nhs eaf885e
Merge branch 'AEA-6292' of github.com-nhs:NHSDigital/eps-prescription…
connoravo-nhs b068a42
Merge branch 'main' into AEA-6292
connoravo-nhs 9c17701
Modify session timed out invalid session cause reason
connoravo-nhs d219966
Test resolves
connoravo-nhs 7334a30
Merge branch 'main' into AEA-6292
connoravo-nhs 631852d
PR review cleanup
connoravo-nhs c768a8a
Resolve linting issues
connoravo-nhs 0e15cf2
Logging to debugs. Test repairs. Add new tests for logout path condit…
connoravo-nhs 06546d1
Merge branch 'main' into AEA-6292
connoravo-nhs f4b6b30
Ensure session logged out is also ignored from redirections to login
connoravo-nhs 3b87196
Merge branch 'main' into AEA-6292
connoravo-nhs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ import inputOutputLogger from "@middy/input-output-logger" | |
| import {parse} from "querystring" | ||
| import {PrivateKey} from "jsonwebtoken" | ||
| import {exchangeTokenForApigeeAccessToken, fetchUserInfo, initializeOidcConfig} from "@cpt-ui-common/authFunctions" | ||
| import {insertTokenMapping, tryGetTokenMapping} from "@cpt-ui-common/dynamoFunctions" | ||
| import {insertTokenMapping, tryGetTokenMapping, TokenMappingItem} from "@cpt-ui-common/dynamoFunctions" | ||
| import {MiddyErrorHandler} from "@cpt-ui-common/middyErrorHandler" | ||
| import jwt from "jsonwebtoken" | ||
| import axios from "axios" | ||
|
|
@@ -72,6 +72,17 @@ async function createSignedJwt(claims: Record<string, unknown>) { | |
| }) | ||
| } | ||
|
|
||
| function checkIfValidTokenMapping(tokenMapping: TokenMappingItem | undefined): boolean { | ||
| const fifteenMinutes = 15 * 60 * 1000 | ||
|
|
||
| return tokenMapping !== undefined && | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A strange case where a token wasn't fully "cleaned" from the database, it existed as a user entry but no further information. This was presenting as a concurrent session to users who weren't logged in elsewhere. |
||
| tokenMapping.sessionId !== undefined && | ||
| tokenMapping.apigeeAccessToken !== undefined && | ||
| tokenMapping.apigeeExpiresIn !== undefined && | ||
| tokenMapping.lastActivityTime !== undefined && | ||
| tokenMapping.lastActivityTime > Date.now() - fifteenMinutes | ||
| } | ||
|
|
||
| const lambdaHandler = async (event: APIGatewayProxyEvent): Promise<APIGatewayProxyResult> => { | ||
| const apigeeApiKey = await getSecret(apigeeApiKeyArn) | ||
| const apigeeApiSecret = await getSecret(apigeeApiSecretArn) | ||
|
|
@@ -154,7 +165,7 @@ const lambdaHandler = async (event: APIGatewayProxyEvent): Promise<APIGatewayPro | |
| ) | ||
| logger.info("Existing token mapping for user", {existingTokenMapping}) | ||
|
|
||
| let tokenMappingItem = { | ||
| let tokenMappingItem: TokenMappingItem = { | ||
| username: `Mock_${baseUsername}`, | ||
| sessionId: sessionId, | ||
| apigeeAccessToken: exchangeResult.accessToken, | ||
|
|
@@ -167,11 +178,9 @@ const lambdaHandler = async (event: APIGatewayProxyEvent): Promise<APIGatewayPro | |
| lastActivityTime: Date.now() | ||
| } | ||
|
|
||
| const fifteenMinutes = 15 * 60 * 1000 | ||
|
|
||
| const sessionManagementTableName = mockOidcConfig.sessionManagementTableName | ||
|
|
||
| if (existingTokenMapping !== undefined && existingTokenMapping.lastActivityTime > Date.now() - fifteenMinutes) { | ||
| const validToken = checkIfValidTokenMapping(existingTokenMapping) | ||
| if (validToken) { | ||
| const username = tokenMappingItem.username | ||
| logger.info("User already exists in token mapping table, creating draft session", | ||
| {username}, {sessionManagementTableName}) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A strange case where a token wasn't fully "cleaned" from the database, it existed as a user entry but no further information. This was presenting as a concurrent session to users who weren't logged in elsewhere.