feat: [M3-7921] - Added Dialog to Refresh Proxy Tokens as Time Expires#10361
feat: [M3-7921] - Added Dialog to Refresh Proxy Tokens as Time Expires#10361jaalah-akamai merged 14 commits intolinode:developfrom
Conversation
| isSideMenuOpen={!desktopMenuIsOpen} | ||
| openSideMenu={() => toggleMenu(true)} | ||
| username={username} | ||
| <SessionExpirationProvider value={sessionExpirationContextValue}> |
There was a problem hiding this comment.
Only change in JSX was to add a new context provider
| interface Props { | ||
| onClose: () => void; | ||
| open: boolean; | ||
| proxyToken?: Token; |
There was a problem hiding this comment.
No need to pass token in anymore, we're handling this within component now.
| const currentParentTokenWithBearer = | ||
| getStorage('authentication/parent_token/token') ?? ''; | ||
|
|
||
| const handleProxyTokenRevocation = React.useCallback(async () => { |
There was a problem hiding this comment.
Handled by useParentChildAuthentication.revokeToken and removed toasts since they're not necessary when switching accounts.
| validateParentToken, | ||
| } = useParentChildAuthentication({ | ||
| tokenIdToRevoke: pendingRevocationToken?.id ?? -1, | ||
| }); |
There was a problem hiding this comment.
This is how the new hook will be used
| * For 'proxy' userType, use the stored parent token in the request. | ||
| * Determine whether the tokens used for switchable accounts are still valid. | ||
| */ | ||
| export const isParentTokenValid = (): boolean => { |
There was a problem hiding this comment.
These functions were moved from parent utils file since they pertain to Account Switching.
isParentTokenValidsetTokenInLocalStorageupdateCurrentTokenBasedOnUserTypegetPersonalAccessTokenForRevocation
| token.token && | ||
| currentTokenWithBearer.replace('Bearer ', '').startsWith(token.token) | ||
| ); | ||
| } |
There was a problem hiding this comment.
Moved all these to /SwitchAccounts/utils
packages/manager/src/features/Account/SwitchAccounts/useParentChildAuthentication.tsx
Outdated
Show resolved
Hide resolved
mjac0bs
left a comment
There was a problem hiding this comment.
Thanks again for the pair review on this; it was definitely helpful to digest these changes. Confirmed that the token will refresh if a user clicks "Continue Working", won't refresh if they cancel out, and will either log out the user and return them to the parent account or to login if the parent token has expired.
I wonder if the proxy log out and return to parent account will be surprising to the parent, since they may be expecting to be logged out of CM entirely. I would imagine it would be a welcome feature from their end, though I'm not sure if it would be immediately clear to them what happened. We could consider adding something like "If your own session is still valid, you will be returned to your parent account on logout." to the session dialog, but maybe we get some input from UX or wait to see if parent users report and feedback or confusion before making any adjustments.
I left comments on a few other things I've noticed while testing. It also looks like the unit test for SessionExpirationDialog is currently failing. I replicated that locally:
|
|
Coverage Report: ✅ |
mjac0bs
left a comment
There was a problem hiding this comment.
Switching accounts from parent to proxy and back, as well as to other child accounts via proxy is still looking good with the latest. Confirmed the slow network edge case behavior I was seeing before is fixed. The dialog still works as expected; I set it to 14 minutes and confirmed it popped up on time. New dialog copy looks good to me.
This should be unrelated to this PR; I just happened to notice it while testing: token revoke events, which are plentiful if you switch between accounts or continue working many times, try to make a network request to /account/users/[proxy-username] and get 403 forbidden as a response. It looks gravatar related to me. 😓 (just furthering our hopes 🪓 )
| '&:disabled': { | ||
| color: theme.palette.text.disabled, | ||
| cursor: 'not-allowed', | ||
| }, | ||
| '&:hover:not(:disabled)': { |
There was a problem hiding this comment.
This looks nice!


Description 📝
When time is about to expire, we want to prompt the user with a modal window that indicates they will be logged out soon (show when 5min is remaining) and ask them if they want to continue working (refresh their token).
Note
I also did refactoring in
SwitchAccountDrawerto implement theuseParentChildAuthentication, hopefully making the file more readable.Additional Issues
Changes 🔄
New Files:
Deleted:
usePendingRevocationToken: We are now usingusePersonalAccessTokensQuerydirectly in places it's needed.Changes:
useParentTokenManagementtouseIsParentTokenExpiredfor clarityTarget release date 🗓️
4/29
Preview 📷
feature.mp4
How to test 🧪
Prerequisites
Reproduction steps
Loading Indicators:
Verification steps
Loading Indicators:
Session Expiry:
if (timeRemaining.minutes < 15) {to observe modaltrueto test that logging out sends you to log inAs an Author I have considered 🤔
Check all that apply