-
Notifications
You must be signed in to change notification settings - Fork 223
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
Make signinPopup work when calling window is iframe #1744
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -152,7 +152,7 @@ export class OidcClient { | |
return signinRequest; | ||
} | ||
|
||
public async readSigninResponseState(url: string, removeState = false): Promise<{ state: SigninState; response: SigninResponse }> { | ||
public async readSigninResponseState(url: string, removeState = false): Promise<{ state: SigninState|undefined; response: SigninResponse }> { | ||
const logger = this._logger.create("readSigninResponseState"); | ||
|
||
const response = new SigninResponse(UrlUtils.readParams(url, this.settings.response_mode)); | ||
|
@@ -163,12 +163,8 @@ export class OidcClient { | |
} | ||
|
||
const storedStateString = await this.settings.stateStore[removeState ? "remove" : "get"](response.state); | ||
if (!storedStateString) { | ||
logger.throw(new Error("No matching state found in storage")); | ||
throw null; // https://github.com/microsoft/TypeScript/issues/46972 | ||
} | ||
|
||
const state = await SigninState.fromStorageString(storedStateString); | ||
const state = storedStateString ? await SigninState.fromStorageString(storedStateString) : undefined; | ||
return { state, response }; | ||
} | ||
|
||
|
@@ -183,6 +179,11 @@ export class OidcClient { | |
extraHeaders = { ...extraHeaders, "DPoP": dpopProof }; | ||
} | ||
|
||
if (!state) { | ||
logger.throw(new Error("No state was found in storage or response")); | ||
throw null; // | ||
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. please re-add comment from above |
||
} | ||
|
||
/** | ||
* The DPoP spec describes a method for Authorization Servers to supply a nonce value | ||
* in order to limit the lifetime of a given DPoP proof. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,6 +394,13 @@ export class UserManager { | |
*/ | ||
public async signinCallback(url = window.location.href): Promise<User | undefined> { | ||
const { state } = await this._client.readSigninResponseState(url); | ||
|
||
// if no state from storage, assume signin popup | ||
if (state === undefined) { | ||
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.
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. How are we sure it was a "signin popup request" here? What about "No matching state found in storage" in the non "signin popup" request case? |
||
await this.signinPopupCallback(url); | ||
return undefined; | ||
} | ||
|
||
switch (state.request_type) { | ||
case "si:r": | ||
return await this.signinRedirectCallback(url); | ||
|
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 add spaces in-between:
SigninState | undefined