Skip to content

Commit

Permalink
feat: user filter to search user's devices for specifc domain
Browse files Browse the repository at this point in the history
  • Loading branch information
yurem committed Jan 21, 2023
1 parent 5e49be9 commit 7c1d641
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ private Pair<ArrayNode, String> prepareAllowedCredentials(String documentDomain,
deviceRegistrationService.migrateToFido2(existingFidoRegistrations, documentDomain, username);
}

List<Fido2RegistrationEntry> existingFido2Registrations = registrationPersistenceService.findAllRegisteredByUsername(username);
List<Fido2RegistrationEntry> existingFido2Registrations = registrationPersistenceService.findByRpRegisteredUserDevices(username, documentDomain);
List<Fido2RegistrationEntry> allowedFido2Registrations = existingFido2Registrations.parallelStream()
.filter(f -> StringHelper.equals(documentDomain, f.getRegistrationData().getDomain()))
.filter(f -> StringHelper.isNotEmpty(f.getRegistrationData().getPublicKeyId())).collect(Collectors.toList());

// f.getRegistrationData().getAttenstationRequest() null check is added to maintain backward compatiblity with U2F devices when U2F devices are migrated to the FIDO2 server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,11 @@ private ObjectNode createUserCredentials(String userId, String username, String

private ArrayNode prepareExcludeCredentials(String documentDomain, String username) {
List<Fido2RegistrationEntry> existingRegistrations = registrationPersistenceService
.findAllRegisteredByUsername(username);
.findByRpRegisteredUserDevices(username, documentDomain);
List<JsonNode> excludedKeys = existingRegistrations.parallelStream()
.filter(f -> StringHelper.equals(documentDomain, f.getRegistrationData().getDomain()))
.filter(f -> StringHelper.isNotEmpty(f.getRegistrationData().getPublicKeyId()))
.map(f -> dataMapperService.convertValue(new PublicKeyCredentialDescriptor(
f.getRegistrationData().getType(), new String[] { "usb", "ble", "nfc", "internal" },
f.getRegistrationData().getType(), new String[] { "usb", "ble", "nfc", "internal", "net", "qr" },
f.getRegistrationData().getPublicKeyId()), JsonNode.class))
.collect(Collectors.toList());

Expand Down

0 comments on commit 7c1d641

Please sign in to comment.