Skip to content
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

No state in response when doing readSigninResponseState #1712

Open
jamalavedra opened this issue Oct 21, 2024 · 3 comments
Open

No state in response when doing readSigninResponseState #1712

jamalavedra opened this issue Oct 21, 2024 · 3 comments

Comments

@jamalavedra
Copy link

jamalavedra commented Oct 21, 2024

Hi,

when doing a silent signing, the callback always expects that there is a custom state url_state. This is required because:
SigninResponse.ts:

const splitState = decodeURIComponent(this.state).split(URL_STATE_DELIMITER);
this.state = splitState[0];

And then at the callback it throws readSigninResponseState: Error: No state in response from the readSigninResponseState function from OidcClient.ts.
This happens because when url_state is provided:

SigninRequest.ts

        if (url_state) {
            stateParam = `${stateParam}${URL_STATE_DELIMITER}${url_state}`;
        }

but url_state is optional.

@pamapa
Copy link
Member

pamapa commented Oct 21, 2024

I do not understand what you mean:

SigninResponse.ts is protected by a if (this.state):

if (this.state) {
const splitState = decodeURIComponent(this.state).split(URL_STATE_DELIMITER);
this.state = splitState[0];
if (splitState.length > 1) {
this.url_state = splitState.slice(1).join(URL_STATE_DELIMITER);
}
}

SigninRequest.ts is protected by a if if (url_state):

if (url_state) {
stateParam = `${stateParam}${URL_STATE_DELIMITER}${url_state}`;
}

@jamalavedra
Copy link
Author

but when if (this.state) is true, then at

if (!response.state) {
it will throw an error of No state in response.
The state is indeed present because its properly prepared when creating the siginRequest, but if im not using a the url_state then the this.state = splitState[0] will be undefined which will make the condition above throw.

@pamapa
Copy link
Member

pamapa commented Oct 22, 2024

it will throw an error of No state in response.
The state is indeed present because its properly prepared when creating the siginRequest, but if i'm not using a the url_state then the this.state = splitState[0] will be undefined which will make the condition above throw.

url_state is optional. You always have a state. This state is required to match the original request. See

return new SigninRequest({
url: parsedUrl.href,
state,
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants