8000 add configuration option to automatically add recovery codes action by dasniko · Pull Request #41849 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

add configuration option to automatically add recovery codes action - #41849

Merged
ahus1 merged 2 commits into
keycloak:mainfrom
dasniko:41836
Aug 27, 2025
Merged

ahus1 merged 2 commits into
keycloak:mainfrom
dasniko:41836

Conversation

@dasniko
@dasniko dasniko commented Aug 13, 2025 •
Copy link
Copy Markdown
Contributor

after otp configuration

closes #41836

@dasniko
dasniko force-pushed the 41836 branch 2 times, most recently from 230355c to 5778ebd Compare August 13, 2025 18:03
@dasniko
dasniko marked this pull request as ready for review August 13, 2025 18:03
@dasniko
dasniko requested a review from a team as a code owner August 13, 2025 18:03
@ahus1
ahus1 commented Aug 14, 2025
Copy link
Copy Markdown
Member

Thank you for the PR, this looks good to me. Can you please add a test?

@ahus1 ahus1 self-assigned this Aug 14, 2025
@ahus1
ahus1 marked this pull request as draft August 14, 2025 08:06
@dasniko
dasniko commented Aug 14, 2025
Copy link
Copy Markdown
Contributor Author

Is there already an existing test for the UpdateTotp action? I didn't find any. If yes, can you give me a pointer?
If not, are there already tests for required actions, where I can look for a good starter?

@ahus1
ahus1 commented Aug 14, 2025
Copy link
Copy Markdown
Member

@dasniko - there are AppInitiatedActionTotpSetupTest and RequiredActionTotpSetupTest that test this. I searched for the use of UserModel.RequiredAction.CONFIGURE_TOTP and this is how I found them. Let me know if this is helpful/sufficient as a starter.

@dasniko
dasniko commented Aug 14, 2025
Copy link
Copy Markdown
Contributor Author

Thanks. I'll have a look. Maybe this takes some time, as I'm on vacations...

…fter otp configuration

closes keycloak#41836

Signed-off-by: Niko Köbler <niko@n-k.de>
Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
@ahus1
ahus1 commented Aug 22, 2025
Copy link
Copy Markdown
Member

@dasniko - thank you for the PR.

I tested it manually and this is what I found:

  • Recovery codes will only be effective when they are enabled in the login flow. Otherwise the user would enter them, but would never be able to use them.
  • The required action needs to be enabled in order for this to work

There is a similar logic in the account console to show the credential types depending on what is enabled in the authentication flows. So I updated the logic and the docs.

Please let me know if you agree with the latest changes.

@dasniko
dasniko commented Aug 22, 2025
Copy link
Copy Markdown
Contributor Author

@ahus1, thanks for the review and the enhancements. I'm fine with these changes.

At the same time I know that people will have problems to understand these dependencies, no matter if the check is implemented or not. So, also only my enhancement would cause problems, as people won't understand that they have to enable the credential usage at multiple places. Even me, although I work nearly every day with it, I mostly forget about it in the first run, then, wenn it doesn't work like I expect it, I remember to do some additional settings...

@dasniko
dasniko commented Aug 26, 2025
Copy link
Copy Markdown
Contributor Author

Sorry if my comment lead to some confusion.
Basically I just wanted to say "yes, I'm fine with the changes" :)

@ahus1
ahus1 commented Aug 27, 2025
Copy link
Copy Markdown
Member

I did some experiments to see if I can show an extended warning message when someone enables it and the preconditions are not met.

While experiencing some bugs around that, I then considered it problematic for any automatic provisioning tool as it would then depend on the order of resources created, which would be a nuisance for everyone involved. So I decided to keep it as is.

Another thought I had was that the functionality we have here now needs to be added to all other second factors, so that they can also trigger recovery codes.

Thinking about that, it might then be good to invert this, so to have once central piece that listens for those second factors to be created, and then adds that required action.

Let's take this as a follow-up thought where it needs to be added as well, and merge this one for now. If you think it should be added in other places as well, please create a follow-up issue and corresponding pull requests.

@ahus1
ahus1 merged commit 236d2f9 into keycloak:main Aug 27, 2025
@ahus1
ahus1 commented Aug 27, 2025
Copy link
Copy Markdown
Member

FYI @keycloak/core-clients

@dasniko
dasniko deleted the 41836 branch August 28, 2025 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add config option to Configure OTP action to automatically add RecoveryCodes action upon OTP creation.

2 participants

0