8000 State Parameter is required to parse callback params · Issue #85 · keycloak/keycloak-js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
8000 Skip to content
State Parameter is required to parse callback params #85
Open
@twobiers

Description

@twobiers

Describe the bug

We discovered that the OIDC state parameter is required in order to parse the redirect URI properly. If no state is issued, the callback will not be parsed and instead a fresh login will be performed.

keycloak-js/lib/keycloak.js

Lines 1091 to 1101 in db66549

if (kc.flow === 'standard' || kc.flow === 'hybrid') {
if ((parsed.oauthParams.code || parsed.oauthParams.error) && parsed.oauthParams.state) {
parsed.oauthParams.newUrl = newUrl;
return parsed.oauthParams;
}
} else if (kc.flow === 'implicit') {
if ((parsed.oauthParams.access_token || parsed.oauthParams.error) && parsed.oauthParams.state) {
parsed.oauthParams.newUrl = newUrl;
return parsed.oauthParams;
}
}

I consider this a bug as the OIDC spec only requires the state parameter if it was present in the request, but if the request did not contain a state (I'll add details from our context under Anything else) it should accept it. Also, even if we would assume that behavior is intended, I believe that the parsing logic should not silently fail and at least a warning should be logged.

Version

26.1.4

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Anything else?

We perform user registrations using an API request. When a user verifies the E-Mail he is being redirected to a page which uses keycloak-js. As the initial authorization request is coming from an action token it will not contain a state parameter. The issue now is, that keycloak-js will attempt to start a new login but with the current window location including the callback params.
In our case we experience then issues with a firewall policy as it will lead to a double encoded iss parameter.

I'm also willing to create a PR if you confirm that behavior is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0