-
Notifications
You must be signed in to change notification settings - Fork 43
feat: add passwordless passkey-only account support #267
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/com/digitalsanctuary/spring/user/dto/AuthMethodsResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package com.digitalsanctuary.spring.user.dto; | ||
|
|
||
| import com.digitalsanctuary.spring.user.persistence.model.User; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
|
|
||
| /** | ||
| * Response DTO for the auth-methods endpoint. | ||
| * <p> | ||
| * Provides information about which authentication methods are configured | ||
| * for the current user, enabling the UI to show/hide relevant options. | ||
| * </p> | ||
| * | ||
| * @author Devon Hillard | ||
| */ | ||
| @Data | ||
| @Builder | ||
| public class AuthMethodsResponse { | ||
|
|
||
| /** Whether the user has a password set. */ | ||
| private boolean hasPassword; | ||
|
|
||
| /** Whether the user has any passkeys registered. */ | ||
| private boolean hasPasskeys; | ||
|
|
||
| /** The number of passkeys registered. */ | ||
| private long passkeysCount; | ||
|
|
||
| /** Whether WebAuthn is enabled on the server. */ | ||
| private boolean webAuthnEnabled; | ||
|
|
||
| /** The user's authentication provider. */ | ||
| private User.Provider provider; | ||
| } |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/digitalsanctuary/spring/user/dto/PasswordlessRegistrationDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package com.digitalsanctuary.spring.user.dto; | ||
|
|
||
| import jakarta.validation.constraints.Email; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Size; | ||
| import lombok.Data; | ||
|
|
||
| /** | ||
| * Data Transfer Object for passwordless user registration. | ||
| * <p> | ||
| * Used for registering users who will authenticate exclusively with passkeys, | ||
| * without setting an initial password. Contains only the user's name and email. | ||
| * </p> | ||
| * | ||
| * @author Devon Hillard | ||
| */ | ||
| @Data | ||
| public class PasswordlessRegistrationDto { | ||
|
|
||
| /** The first name. */ | ||
| @NotBlank(message = "First name is required") | ||
| @Size(max = 50, message = "First name must not exceed 50 characters") | ||
| private String firstName; | ||
|
|
||
| /** The last name. */ | ||
| @NotBlank(message = "Last name is required") | ||
| @Size(max = 50, message = "Last name must not exceed 50 characters") | ||
| private String lastName; | ||
|
|
||
| /** The email. */ | ||
| @NotBlank(message = "Email is required") | ||
| @Email(message = "Please provide a valid email address") | ||
| @Size(max = 100, message = "Email must not exceed 100 characters") | ||
| private String email; | ||
|
|
||
| } |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/digitalsanctuary/spring/user/dto/SetPasswordDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.digitalsanctuary.spring.user.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Size; | ||
| import lombok.Data; | ||
| import lombok.ToString; | ||
|
|
||
| /** | ||
| * Data Transfer Object for setting an initial password on a passwordless account. | ||
| * <p> | ||
| * Used when a user who registered without a password (passkey-only) wants to add | ||
| * a password to their account. Contains the new password and confirmation. | ||
| * </p> | ||
| * | ||
| * @author Devon Hillard | ||
| */ | ||
| @Data | ||
| public class SetPasswordDto { | ||
|
|
||
| /** The new password to set. */ | ||
| @ToString.Exclude | ||
| @NotBlank(message = "Password is required") | ||
| @Size(min = 8, max = 128, message = "Password must be between 8 and 128 characters") | ||
| private String newPassword; | ||
|
|
||
| /** Confirmation of the new password (must match newPassword). */ | ||
| @ToString.Exclude | ||
| @NotBlank(message = "Password confirmation is required") | ||
| private String confirmPassword; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The test coverage for the new UserAPI endpoints (
/user/auth-methods,/user/registration/passwordless, and/user/setPassword) is missing. The existing test suiteUserAPIUnitTest.javacontains comprehensive tests for other endpoints like registration, password reset, and profile updates, but there are no tests for the three new API endpoints introduced in this PR. These endpoints should have unit tests that verify success cases, error cases, validation, and edge cases, following the existing test patterns in the codebase.