SpoonX / aurelia-authentication

Authentication plugin for aurelia.
http://aurelia-authentication.spoonx.org
MIT License
90 stars 60 forks source link

auth0-lock v11 and responseType = 'token' #403

Closed vidaritos closed 5 years ago

vidaritos commented 5 years ago

I'm having the most difficult time getting the authorization flow working with Auth0.

I tried first the examples provided by the Auth0 site to integrate the authentication with my SPA, which works fine, but when I use aurelia-authentication plugin using the same config, it fails. The flow stops at the /authorize endpoint If I set the responseType = 'token', I get the following error in the console: Unhandled rejection TypeError: Cannot read property 'token' of null Other attempts: responseType = 'token id_token' gives me this error: Unhandled rejection Error: Only 'token' responseType is supported

responseType = 'token%20id_token' results in /authroize to return HTTP 501

If I change the line https://github.com/SpoonX/aurelia-authentication/blob/9ae76ac2a5fb6111c5ee5427587e746112911dc5/src/authLock.js#L63-L64 to opts.auth.responseType = provider.responseType.replace('%20', ' '); It seems to work. /authorize then returns HTTP 200

Should the following if-statement here also include to check responseType === 'token id_token'?
https://github.com/SpoonX/aurelia-authentication/blob/9ae76ac2a5fb6111c5ee5427587e746112911dc5/src/authLock.js#L93-L96 Or am I missing something here?

I found this https://github.com/auth0/lock/issues/809, indicating responseType = 'token id_token' is now mandatory?

AuthConfig:

export default {
  endpoint: 'api',
  configureEndpoints: ['api'], 
  storageKey: 'aurelia_authentication_auth0',
  providers: {
    auth0: {

      oauthType: 'auth0-lock',
      responseType: 'token',
      clientId: 'random',
      clientDomain: 'mydomain.eu.auth0.com',
      lockOptions: {
        auth: {          
          audience: 'http://mydomain.com/api',
          params: { scope: 'openid profile' },
        }
      },
      state: function () {
        return Math.random().toString(36).substr(2);
      }
    }
  }
};
RWOverdijk commented 5 years ago

Should the following if-statement here also include to check responseType === 'token id_token'?

It did, before you removed the %20 :D

provider.responseType === 'token%20id_token'

Any way, it looks like you caught a bug (or at least some icky code) there. Would you mind sending in a PR?