-
Notifications
You must be signed in to change notification settings - Fork 8
[SCAL-288254] Token Refresh #393
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
base: main
Are you sure you want to change the base?
Changes from all commits
ef8d648
7d82476
5cd10d2
183de1b
d4435c9
bf87caf
4daa1d8
8a5951a
14fa36a
83a0d28
8a6956b
5ece501
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -479,6 +479,7 @@ export class TsEmbed { | |||||
| this.embedConfig.customVariablesForThirdPartyTools || {}, | ||||||
| hiddenListColumns: this.viewConfig.hiddenListColumns || [], | ||||||
| customActions: customActionsResult.actions, | ||||||
| embedExpiryInAuthToken: this.viewConfig.refreshAuthTokenOnNearExpiry, | ||||||
| ...getInterceptInitData(this.viewConfig), | ||||||
| }; | ||||||
|
|
||||||
|
|
@@ -507,6 +508,28 @@ export class TsEmbed { | |||||
| } | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
| * Refresh the auth token if the autoLogin is true and the authType is TrustedAuthTokenCookieless | ||||||
| * @param _ | ||||||
| * @param responder | ||||||
| */ | ||||||
| private tokenRefresh = async (_: any, responder: any) => { | ||||||
|
Contributor
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. For better type safety and code clarity, consider providing specific types for the
Suggested change
|
||||||
| const { authType, autoLogin } = this.embedConfig; | ||||||
| const isAutoLoginTrue = autoLogin ?? (authType === AuthType.TrustedAuthTokenCookieless); | ||||||
ruchI9897 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| if (isAutoLoginTrue && authType === AuthType.TrustedAuthTokenCookieless) { | ||||||
| try { | ||||||
| const authToken = await getAuthenticationToken(this.embedConfig, true); | ||||||
| responder({ | ||||||
| type: EmbedEvent.RefreshAuthToken, | ||||||
| data: { authToken }, | ||||||
| }); | ||||||
| } catch (e) { | ||||||
| logger.error(`${ERROR_MESSAGE.INVALID_TOKEN_ERROR} Error : ${e?.message}`); | ||||||
| processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el); | ||||||
| } | ||||||
|
Comment on lines
+520
to
+529
Contributor
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. This |
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Sends updated auth token to the iFrame to avoid user logout | ||||||
| * @param _ | ||||||
|
|
@@ -569,9 +592,10 @@ export class TsEmbed { | |||||
|
|
||||||
| const embedListenerReadyHandler = this.createEmbedContainerHandler(EmbedEvent.EmbedListenerReady); | ||||||
| this.on(EmbedEvent.EmbedListenerReady, embedListenerReadyHandler, { start: false }, true); | ||||||
|
|
||||||
| const authInitHandler = this.createEmbedContainerHandler(EmbedEvent.AuthInit); | ||||||
| this.on(EmbedEvent.AuthInit, authInitHandler, { start: false }, true); | ||||||
| this.on(EmbedEvent.RefreshAuthToken, this.tokenRefresh, { start: false }, true); | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
|
|
||||||
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.
why. have we added this to the normal flow ?
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.
I am using the same function for the refresh token as well, but since the token is not yet expired incase of refresh call, it sends the same cached token, add this flag to skip the cache check.