IdentityModel / oidc-client-js

OpenID Connect (OIDC) and OAuth2 protocol support for browser-based JavaScript applications
Apache License 2.0
2.43k stars 842 forks source link

Default storage mechanism not working #1375

Closed nilact closed 3 years ago

nilact commented 3 years ago

I'm using oidc-client.js for authentication and various flows, such as renewing the token and logout for Azure B2C AD.

I have the below configuration:

const settings = {   
    authority: 'https://test.abc.com/accounts-test.abc.com/b2c_1a_abcidnormalsignin/v2.0/.well-known/openid-configuration',
    loadUserInfo: false, 
    redirect_uri: 'http://localhost:3000/signin-callback.html',
    response_type: 'code',
    client_id: 'd47b8cd9-1234-5678-c01de-a0a57ab7a22a',
    //add client id to get access token
    scope: 'openid offline_access d47b8cd9-1234-5678-c01de-a0a57ab7a22a', 
     metadata: {     
       issuer:"https://abcidb2ctest.b2clogin.com/7c8969d1-3d1c-460c-a32f-879d8941255f/v2.0/"
      ,authorization_endpoint:"https://test.abc.com/OAuth/oauth2/v2.0/authorize?p=b2c_1a_abcidnormalsignin"
      ,token_endpoint:"https://test.abc.com/OAuth/oauth2/v2.0/token?p=b2c_1a_abcidnormalsignin",
      end_session_endpoint:"https://test.abc.com/OAuth/Logout?p=b2c_1a_abcidnormalsignin"
      ,jwks_uri:"https://abcidb2ctest.b2clogin.com/accounts-test.abc.com/discovery/v2.0/keys?p=b2c_1a_abcidnormalsignin"
  },
  //despite below it still stores token in session storage
  stateStore: new WebStorageStateStore({ store: window.localStorage }),
  userStore:new WebStorageStateStore({ store: window.localStorage }),
  post_logout_redirect_uri:'http://localhost:3000'
} as UserManagerSettings;

this.userManager = new UserManager(settings);

Despite the fact that I have mentioned the localstorage as the default storage mechanism, it still considers sessionstorage.

Do I need to make any other changes to make it work?

brockallen commented 3 years ago

You'd need to configure similar values in the signin-callback.html

nilact commented 3 years ago

@brockallen Thanks it is working after making changes in signin-callback.html.