New: [AEA-6292] - Authentication redirect & blocking render improvements#1865
New: [AEA-6292] - Authentication redirect & blocking render improvements#1865connoravo-nhs merged 105 commits intomainfrom
Conversation
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
…en blocking conditions Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
… concurrent on primary session on select role page Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
…on, as blocked rn Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
…-tracker-ui into AEA-6292
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
…s have a test Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
| tokenMapping.cis2IdToken !== undefined && | ||
| tokenMapping.cis2ExpiresIn !== undefined && | ||
| tokenMapping.lastActivityTime !== undefined && | ||
| tokenMapping.lastActivityTime > Date.now() - fifteenMinutes |
There was a problem hiding this comment.
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.
| function checkIfValidTokenMapping(tokenMapping: TokenMappingItem | undefined): boolean { | ||
| const fifteenMinutes = 15 * 60 * 1000 | ||
|
|
||
| return tokenMapping !== undefined && |
There was a problem hiding this comment.
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.
| return ( | ||
| <AccessContext.Provider value={{}}> | ||
| {children} | ||
| {shouldBlockChildren() ? <Layout><LoadingPage /></Layout> : children} |
There was a problem hiding this comment.
Children shown should always satisfy shouldBlockChildren within the Access Provider. Having it seperately could lead to potential race conditions.
| const isAmplifyHostRequest = config.url?.includes("/api/cis2-signout") ?? false | ||
| if (idToken === undefined && !isAmplifyHostRequest) { | ||
| controller.abort() | ||
| throw new Error("Could not get a cognito token") |
There was a problem hiding this comment.
To discuss impact on AEA-5838
| }, [auth.rolesWithAccess, auth.rolesWithoutAccess]) | ||
|
|
||
| // Handle auto-redirect for single role | ||
| useEffect(() => { |
There was a problem hiding this comment.
Shifted to AccessProvider
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
…ion. Resolve rum log sent state Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
|
|
||
| if (remainingSeconds !== undefined) { | ||
| const twoMinutes = 2 * 60 // Minutes into seconds | ||
|
|
There was a problem hiding this comment.
the timeout modal is appearing on the /select-your-role page which causes an error when you choose 'stay logged in' as handlestayloggedin works by re-selecting your role.
const currentPath = normalizePath(location.pathname)
if (currentPath === FRONTEND_PATHS.SELECT_YOUR_ROLE) {
return
}
there might be a more elegant solution but just adding the code above worked for me
Signed-off-by: Connor Avery <214469360+connoravo-nhs@users.noreply.github.com>
|



Summary
Details
Aims to resolve the bugs identified in:
Changes made:
The ensureRoleSelected function has been somewhat re-written to ensure hierarchical order is correct & that if statements are "looser" fitting to negative scenarios. Public paths shouldn't be affected by redirections apart from root and login.
The shouldBlockChildren function has also had additional conditions added, that will ensure a render block occurs, so that on-page useEffects don't run.
The shouldBlockChildren now dictates within AccessContext.Provider return, whether the children or loading page should be shown. This is believed to resolve an issue where re-rendering wasn't occurring in the event of a state change if a user was on the loading page in an auth transition state.
Token lambdas now check for a 'complete' token information in the DynamoDb table, to prevent the cause of eventual consistency of a session logout, where a dynamoDb row remains with skeleton information and no actual credentials.