-
Notifications
You must be signed in to change notification settings - Fork 969
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
fix: omit irrelevant OIDC providers in forced refresh login flows #3608
fix: omit irrelevant OIDC providers in forced refresh login flows #3608
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3608 +/- ##
==========================================
+ Coverage 78.19% 78.21% +0.01%
==========================================
Files 341 341
Lines 23142 23202 +60
==========================================
+ Hits 18097 18148 +51
- Misses 3689 3691 +2
- Partials 1356 1363 +7
|
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.
Very nice! Could you please add an e2e test to show that this works end-to-end as well and doesn't encounter regressions in the future? :)
@aeneasr Done 🙂 |
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.
Very nice changes! Thank you for adding the e2e test.
…y#3608) Whenever an user is asked to reauthenticate (e.g. because they wish to execute settings flow touching their credentials and their session is no longer privileged) they are asked to provide their credentials again. The forced-refresh login flow generated for such cases already excludes some strategies that are enabled in Kratos but cannot be used to authenticate as current identity, and for example the form presented to the user will not have a password field if the identity does not have a password credential. This, however, does not currently apply to OIDC providers; the user will always see the full set even if some of them can't be used to sign in as current identity. This change causes forced refresh login flows to also omit irrelevant OIDC providers in generated form in order to avoid confunding the user about which strategies/providers are valid and can actually be used to reauthenticate.
Whenever an user is asked to reauthenticate (e.g. because they wish to execute settings flow touching their credentials and their session is no longer privileged) they are asked to provide their credentials again. The forced-refresh login flow generated for such cases already excludes some strategies that are enabled in Kratos but cannot be used to authenticate as current identity, and for example the form presented to the user will not have a password field if the identity does not have a password credential.
This, however, does not currently apply to OIDC providers; the user will always see the full set even if some of them can't be used to sign in as current identity. This change causes forced refresh login flows to also omit irrelevant OIDC providers in generated form in order to avoid confunding the user about which strategies/providers are valid and can actually be used to reauthenticate.
Related issue(s)
Not reported separately. To reproduce:
The inverse does not happen: if registering with OIDC, the form does not have a password field because the identity does not have a password credential yet.
Checklist
introduces a new feature.
contributing code guidelines.
vulnerability. If this pull request addresses a security vulnerability, I
confirm that I got the approval (please contact
[email protected]) from the maintainers to push
the changes.
works.
Further Comments
Removing nodes/providers should be safe enough because we are operating in the context of previously authenticated identity. The user already knows which OIDC providers are linked because they can see this info in settings flow itself.
I've tested this by extending Settings flow linking and unlinking when unauthed scenarios but right now the check is a bit fragile (because it extracts login flow ID from URL query params) and probably not as precise as it could be (because I'm only checking that there are no nodes for providers other than our identity's
ory
andgithub
but ideally I'd do a set-equals there). If you have any ideas on how to improve testing this, let me know and I'll try to apply them.Hopefully no E2E tests rely on current behavior 🙏