Fix bug PublicKeyCredentialUserEntityRepository saves anonymousUser

Issue gh-16385

Signed-off-by: Borghi <137845283+Borghii@users.noreply.github.com>
This commit is contained in:
Borghi
2025-02-16 22:50:34 -03:00
parent 946812691e
commit 0bc9313fdd
2 changed files with 25 additions and 3 deletions

View File

@@ -536,6 +536,18 @@ class Webauthn4jRelyingPartyOperationsTests {
.isEqualTo(creationOptions.getAuthenticatorSelection().getUserVerification());
}
@Test
void shouldReturnEmptyCredentialsWhenUserIsAnonymous() {
AnonymousAuthenticationToken authentication = new AnonymousAuthenticationToken("key", "anonymousUser",
Set.of(() -> "ROLE_ANONYMOUS"));
PublicKeyCredentialRequestOptionsRequest createRequest = new ImmutablePublicKeyCredentialRequestOptionsRequest(
authentication);
PublicKeyCredentialRequestOptions credentialRequestOptions = this.rpOperations
.createCredentialRequestOptions(createRequest);
assertThat(credentialRequestOptions.getAllowCredentials()).isEmpty();
}
private static AuthenticatorAttestationResponse setFlag(byte... flags) throws Exception {
AuthenticatorAttestationResponseBuilder authAttResponseBldr = TestAuthenticatorAttestationResponse
.createAuthenticatorAttestationResponse();