Skip to content

Implement recovery key support for user storage providers - #2

Open
ShashankFC wants to merge 1 commit into
feature-recovery-keys-foundationfrom
feature-recovery-keys-implementation
Open

Implement recovery key support for user storage providers#2
ShashankFC wants to merge 1 commit into
feature-recovery-keys-foundationfrom
feature-recovery-keys-implementation

Conversation

@ShashankFC

Copy link
Copy Markdown
Contributor

Test 9

Summary by CodeRabbit

New Features

  • Recovery Codes Authentication: Added support for recovery codes as an authentication credential type, enabling users to set up and use recovery codes during login as an additional authentication method.
  • Recovery Code Verification: Implemented recovery code validation and verification within the authentication flow.
  • Backwards Compatibility: Extended legacy storage systems to support recovery codes credentials alongside existing authentication methods.

✏️ Tip: You can customize this high-level summary in your review settings.


Replicated from ai-code-review-evaluation/keycloak-coderabbit#9

closes #38445

Signed-off-by: rtufisi <rtufisi@phasetwo.io>
@ShashankFC
ShashankFC requested a review from Copilot January 30, 2026 10:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements recovery key support for user storage providers, extending backwards compatibility to allow legacy storage systems to handle recovery codes alongside existing authentication methods.

Changes:

  • Added recovery codes as a supported credential type in backwards-compatible user storage implementations
  • Implemented recovery code validation and verification logic within the authentication flow
  • Introduced utility methods to retrieve recovery code credentials from both federated and local storage

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
BackwardsCompatibilityUserStorageTest.java Added comprehensive test for recovery key setup and authentication flow
BackwardsCompatibilityUserStorageFactory.java Added method to check if user has recovery codes
BackwardsCompatibilityUserStorage.java Implemented recovery codes credential storage, validation, and retrieval
RecoveryAuthnCodeInputLoginBean.java Updated to use utility method for retrieving recovery code credentials
RecoveryAuthnCodesAction.java Refactored to use helper method for credential creation
RecoveryAuthnCodesFormAuthenticator.java Updated to use utility method for retrieving recovery code credentials
RecoveryAuthnCodesUtils.java Added utility method to retrieve credentials from federated or local storage
CredentialHelper.java Added helper method to create recovery codes in user storage or local storage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.addSubFlowExecution("Recovery-Authn-Codes subflow", AuthenticationFlow.BASIC_FLOW, AuthenticationExecutionModel.Requirement.ALTERNATIVE, altSubFlow -> altSubFlow
.addAuthenticatorExecution(AuthenticationExecutionModel.Requirement.REQUIRED, RecoveryAuthnCodesFormAuthenticatorFactory.PROVIDER_ID)
.addAuthenticatorExecution(AuthenticationExecutionModel.Requirement.REQUIRED, "delayed-authenticator", config -> {
config.setAlias("delayed-suthenticator-config");

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'suthenticator' to 'authenticator'.

Suggested change
config.setAlias("delayed-suthenticator-config");
config.setAlias("delayed-authenticator-config");

Copilot uses AI. Check for mistakes.
);
credentialModels.add(model);
} catch (IOException e) {
log.error("Could not deserialize credential of type: recovery-codes");

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space found between 'deserialize' and 'credential'.

Suggested change
log.error("Could not deserialize credential of type: recovery-codes");
log.error("Could not deserialize credential of type: recovery-codes");

Copilot uses AI. Check for mistakes.
* Checks the user storage for the credential. If not found it will look for the credential in the local storage
*
* @param user - User model
* @return - a optional credential model

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space found between 'optional' and 'credential'.

Suggested change
* @return - a optional credential model
* @return - a optional credential model

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants