Keycloak state param in redirect URL on Login

See original GitHub issue

I am having SSO implementation using keaycloak in an angular app and it is working fine, But on login into the application it redirects to the app URL with having state param in URL as below.

image

I am using angular-oauth2-oidc v10.0.3

Is there any way or config for removing the state param from URL.

AuthConfig:

export var authConfig: AuthConfig = {
  issuer: 'https://keycloak.poc.com/auth/realms/local',
  redirectUri: 'http://localhost:4200/',
  responseType: 'code',
  requireHttps: false,
  showDebugInformation: true,
  disableAtHashCheck: false
};

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
eskindergcommented, May 30, 2022

I don’t know why this got closed but i am having the same problem of having the state in the URL after login. The hard part is, if you refresh the page in your first login attempt, keycloak will give you an error because of the long URL.

1reaction
kmohit520commented, May 7, 2021

Thanks for quick response. Checked the flow using those breakpoints and it is going inside below codeblock of tryLoginCodeFlow

if (!options.preventClearHashAfterLogin) {
            const href = location.href
                .replace(/[&\?]code=[^&\$]*/, '')
                .replace(/[&\?]scope=[^&\$]*/, '')
                .replace(/[&\?]state=[^&\$]*/, '')
                .replace(/[&\?]session_state=[^&\$]*/, '');
            history.replaceState(null, window.name, href);
        }

and clearing the params.

What I wanted to know is, if it is possible to never have that ?state param at anytime in URL. Both current and desired flow mentioned below:

Current Flow:

  1. Keycloak Login

Screenshot (1008)

  1. Redirect with state param

image

  1. Redirected to App Home Page

image

Desired Flow: (Without any state param in URL)

  1. Keycloak Login

Screenshot (1008)

  1. Redirect to App Home Page

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keycloak state param in redirect URL on Login - Bountysource
I am having SSO implementation using keaycloak in an angular app and it is working fine, But on login into the application it...
Read more >
Is there any way I can redirect to login page without showing ...
I tested (1)java login page > (2)redirect to keycloak login page > (3)user ... it returns me the parameters (code, state and session...
Read more >
Keycloak - use authorization code with state parameter
Once the user login is successfull the keycloak will respond back to your redirect url with the authorization code and also your state...
Read more >
The importance of the “state” parameter in OAuth - Medium
The CLI application redirects the user's browser to the Keycloak login page and at the same time it starts the HTTP server on...
Read more >
OIDC 'state' parameter is url-encoded twice in Token Response
a protected resource the app redirects to the Keycloak login screen and asks the user to sign in. ... the requested ID and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found