-
Notifications
You must be signed in to change notification settings - Fork 453
Fix silent refresh iframe with multiple idps #2107
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
Fix silent refresh iframe with multiple idps #2107
Conversation
|
|
||
| if (isAuthenticated) { | ||
|
|
||
| const authResult = callbackContext && 'authResult' in callbackContext |
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.
const authResult = callbackContext?.authResult ?? null;
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 tried this approach, but the types are not working out. callbackContext can be of type {configId: string}, which does not contain authResult , so in this case callbackContext.authResult is not nullish, but a type error. That is why we need 'authResult' in callbackContext to test we are not in case of {configId: string}. At least this is my understanding of the matter.
I have added another approach to make this part look nicer. let me know if the alternative makes sense
| result: unknown, | ||
| isRenewProcess: boolean | ||
| isRenewProcess: boolean, | ||
| config: OpenIdConfiguration |
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.
If only the configId is needed, please only pass the configId in.
| stateValidationResult: StateValidationResult, | ||
| isRenewProcess: boolean | ||
| isRenewProcess: boolean, | ||
| config: OpenIdConfiguration |
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.
If only configId is needed, please only pass the id in.
| stateValidationResult: StateValidationResult | null, | ||
| isRenewProcess: boolean | ||
| isRenewProcess: boolean, | ||
| config: OpenIdConfiguration |
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.
Please only pass configId in.
| stateValidationResult: StateValidationResult | null, | ||
| isRenewProcess: boolean | ||
| isRenewProcess: boolean, | ||
| config: OpenIdConfiguration |
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.
Please only pass configId in.
| const eventData = e.detail; | ||
|
|
||
| if (typeof eventData === 'object' && eventData.configId && eventData.instanceId) { | ||
| if (eventData.configId === config.configId && eventData.instanceId !== instanceId) { |
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.
please extract a method.
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.
this refers, I guess, to the same hunk as the above comment.
| config: OpenIdConfiguration | ||
| ): boolean { | ||
|
|
||
| if (e?.detail == null) { |
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.
===. But I think undefined should also be checked? if (!e?.detail)
| return false; | ||
| } | ||
|
|
||
| if (e.detail.srcFrameId != null) { |
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.
same here. We are only checking for null, so undefined is a valid value? Just do if(e.deailt.srcFrameId)
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.
e.detail.srcFrameId != null is null or undefined, notice != rather than !==. I will change however to if(e.deailt.srcFrameId). This is more consistent with the rest of the codebase.
| if (e.detail.srcFrameId != null) { | ||
|
|
||
| const frameIdPrefix = `${IFRAME_FOR_SILENT_RENEW_IDENTIFIER}_`; | ||
| let eventConfigId: string | null = null; |
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.
Would consider let as a code smell. Easy fixable by extracting a method, return the value and assign to a const here :-)
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 have made this part of code more concise.
|
|
||
| private convertToLegacyEvent(e: CustomEvent): CustomEvent { | ||
| // If event has the new format with url property, convert it to legacy format | ||
| if (e?.detail?.url != null) { |
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.
undefined is a valid value here? Better do if(e?.detail?.url)
|
What a PR. Thanks a lot!!!! Incredible work. |
This fixes compatibility issues with Angular 20+ projects created with --standalone=false flag.
|
Thanks for the review points. Working on improvements. |
Current implementation does not work correctly with multiple ips using iframe renew.
The PR is related to the following feature request #2105