Skip to content

Commit e5579e9

Browse files
author
pooya parsa
committed
fix: accept state, nonce as login args
1 parent e183009 commit e5579e9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/schemes/oauth2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default class Oauth2Scheme {
6464
return this.$auth.reset()
6565
}
6666

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

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

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

0 commit comments

Comments
 (0)