Skip to content

Commit e3a715b

Browse files
committed
Fix issues identified in PR review
Signed-off-by: Borghi <137845283+Borghii@users.noreply.github.com>
1 parent 0bc9313 commit e3a715b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

web/src/main/java/org/springframework/security/web/webauthn/management/Webauthn4JRelyingPartyOperations.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -346,7 +346,8 @@ public PublicKeyCredentialRequestOptions createCredentialRequestOptions(
346346
}
347347

348348
private List<CredentialRecord> findCredentialRecords(Authentication authentication) {
349-
if (authentication instanceof AnonymousAuthenticationToken) {
349+
AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
350+
if (authentication == null || trustResolver.isAnonymous(authentication)) {
350351
return Collections.emptyList();
351352
}
352353
PublicKeyCredentialUserEntity userEntity = this.userEntities.findByUsername(authentication.getName());

web/src/test/java/org/springframework/security/web/webauthn/management/Webauthn4jRelyingPartyOperationsTests.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -548,6 +548,15 @@ void shouldReturnEmptyCredentialsWhenUserIsAnonymous() {
548548
assertThat(credentialRequestOptions.getAllowCredentials()).isEmpty();
549549
}
550550

551+
@Test
552+
void shouldReturnEmptyCredentialsWhenAnonymousUserIsDisabled() {
553+
PublicKeyCredentialRequestOptionsRequest createRequest = new ImmutablePublicKeyCredentialRequestOptionsRequest(null);
554+
PublicKeyCredentialRequestOptions credentialRequestOptions = this.rpOperations
555+
.createCredentialRequestOptions(createRequest);
556+
557+
assertThat(credentialRequestOptions.getAllowCredentials()).isEmpty();
558+
}
559+
551560
private static AuthenticatorAttestationResponse setFlag(byte... flags) throws Exception {
552561
AuthenticatorAttestationResponseBuilder authAttResponseBldr = TestAuthenticatorAttestationResponse
553562
.createAuthenticatorAttestationResponse();

0 commit comments

Comments
 (0)