Skip to content

Commit

Permalink
fix: accept state, nonce as login args
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed May 23, 2019
1 parent e183009 commit e5579e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/schemes/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class Oauth2Scheme {
return this.$auth.reset()
}

login ({ params } = {}) {
login ({ params, state, nonce } = {}) {
const opts = {
protocol: 'oauth2',
response_type: this.options.response_type,
Expand All @@ -73,7 +73,7 @@ export default class Oauth2Scheme {
scope: this._scope,
// Note: The primary reason for using the state parameter is to mitigate CSRF attacks.
// https://auth0.com/docs/protocols/oauth2/oauth-state
state: nanoid(),
state: state || nanoid(),
...params
}

Expand All @@ -87,7 +87,7 @@ export default class Oauth2Scheme {
if (opts.response_type.includes('id_token')) {
// nanoid auto-generates an URL Friendly, unique Cryptographic string
// Recommended by Auth0 on https://auth0.com/docs/api-auth/tutorials/nonce
opts.nonce = nanoid()
opts.nonce = nonce || nanoid()
}

this.$auth.$storage.setLocalStorage(this.name + '.state', opts.state)
Expand Down

0 comments on commit e5579e9

Please sign in to comment.