-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(auth): add option to disable idp oauth flow #13373
base: v5-stable
Are you sure you want to change the base?
feat(auth): add option to disable idp oauth flow #13373
Conversation
@@ -2437,6 +2444,7 @@ export class AuthClass { | |||
? this._config.oauth.redirectSignIn | |||
: this._config.oauth.redirectUri; | |||
|
|||
this._storage.setItem('amplify-sp-initiated-oauth-inFlight', 'true'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this flag set when Auth.federatedSignIn
is called ?
if this issue is web specific, we probably can exclude RN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this flag is set when Auth.federatedSignIn
is called. This is to determine if an SP initiated oauth is in progress.
The following flow is common for web and RN
- add a flag when
Auth.federatedSignIn
is called - When redirected back from HostedUI, if ^^ flag is present allow urlListener to get fired, hence handling oauth
- remove flag from storage
if (this._storage.getItem('amplify-sp-initiated-oauth-inFlight')) { | ||
this._storage.removeItem('amplify-sp-initiated-oauth-inFlight'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering if it make sense to clean any keys after the user has finished the oauth flow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When _handleAuthResponse
is called we handle Oauth only when the url contains code
| error
. Hence clearing the flag specifically here. Irrespective of success/failure clearing the flag early on.
WDYT
3ca7394
to
e2d577f
Compare
NOTE: The actual naming of the flag ( |
Description of changes
Amplify supports two types of oauth flows in V5 "IDP (initiated by provider)" and "SP (initiated by client)". Since IDP flow is initiated outside of Amplify we uses a global urlListener to handle the oauth response when the url query params contain
code
,access_token
orerror
.However even if the app isn't redirected from HostedUI but contains the the url query params
code
,access_token
orerror
, the global urlListener is hit and the url is replaced with the redirectSignIn urlSolution
Amplify.configure()
to optionally disable IDP initiated flow to avoid calling the global urlListeneramplify-sp-initiated-oauth-inFlight
flag in local storageIssue #, if available
Description of how you validated changes
Tested the following flows
idpEnabled
in Amplify.configureidpEnabled: true
and ignored whenidpEnabled: false
idpEnabled: false
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.