Class JdbcPasskeyRepository
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.passkeys.JdbcPasskeyRepository
- All Implemented Interfaces:
PasskeyRepository
PasskeyRepository over the user_credentials and user_entities tables that Spring Security's
WebAuthn repositories own. It only reads them and renames or deletes a credential; registering one and updating its
signature counter stay with the framework.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringColumns of a credential, in the order the row mapper does not depend on.private static final StringStatement deleting a credential of a user.private static final StringQuery telling whether an account has at least one credential.private static final StringQuery returning one credential of a user.private static final StringQuery returning the credentials of a user.private static final StringQuery returning the user handle of an account.private final org.springframework.jdbc.core.simple.JdbcClientJDBC client used to run the statements.private final PasskeyRowMapperMaps a row to a passkey.private static final StringStatement renaming a credential of a user. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeletes a passkey of a user.booleanexistsForAccount(UUID accountId) Tells whether an account has registered at least one passkey, in a single lookup.findByIdAndUserId(String id, String userId) Finds one passkey of a user.findByUserId(String userId) Lists the passkeys of a user, oldest first.findUserIdByUsername(String username) Finds the WebAuthn user handle of an account.booleanRenames a passkey of a user.
-
Field Details
-
COLUMNS
Columns of a credential, in the order the row mapper does not depend on.- See Also:
-
FIND_USER_ID_BY_USERNAME
Query returning the user handle of an account.- See Also:
-
FIND_BY_USER_ID
Query returning the credentials of a user.- See Also:
-
FIND_BY_ID_AND_USER_ID
Query returning one credential of a user.- See Also:
-
RENAME
Statement renaming a credential of a user.- See Also:
-
DELETE
Statement deleting a credential of a user.- See Also:
-
EXISTS_FOR_ACCOUNT
Query telling whether an account has at least one credential.- See Also:
-
jdbcClient
private final org.springframework.jdbc.core.simple.JdbcClient jdbcClientJDBC client used to run the statements. -
passkeyRowMapper
Maps a row to a passkey.
-
-
Constructor Details
-
JdbcPasskeyRepository
public JdbcPasskeyRepository()
-
-
Method Details
-
findUserIdByUsername
Description copied from interface:PasskeyRepositoryFinds the WebAuthn user handle of an account.- Specified by:
findUserIdByUsernamein interfacePasskeyRepository- Parameters:
username- name of the account, as the user entity of the credential store records it.- Returns:
- the user handle, or an empty optional when the account has no user entity (never registered a passkey).
-
findByUserId
Description copied from interface:PasskeyRepositoryLists the passkeys of a user, oldest first.- Specified by:
findByUserIdin interfacePasskeyRepository- Parameters:
userId- WebAuthn user handle of the owner.- Returns:
- the passkeys, possibly empty.
-
findByIdAndUserId
Description copied from interface:PasskeyRepositoryFinds one passkey of a user.- Specified by:
findByIdAndUserIdin interfacePasskeyRepository- Parameters:
id- credential identifier.userId- WebAuthn user handle of the owner, so nobody can reach another user's passkey.- Returns:
- the passkey, or an empty optional when the user has no such passkey.
-
rename
Description copied from interface:PasskeyRepositoryRenames a passkey of a user.- Specified by:
renamein interfacePasskeyRepository- Parameters:
id- credential identifier.userId- WebAuthn user handle of the owner.label- new label.- Returns:
truewhen a passkey was renamed.
-
delete
Description copied from interface:PasskeyRepositoryDeletes a passkey of a user.- Specified by:
deletein interfacePasskeyRepository- Parameters:
id- credential identifier.userId- WebAuthn user handle of the owner.- Returns:
truewhen a passkey was deleted.
-
existsForAccount
Description copied from interface:PasskeyRepositoryTells whether an account has registered at least one passkey, in a single lookup.- Specified by:
existsForAccountin interfacePasskeyRepository- Parameters:
accountId- identifier of the account (theusersrow), not its WebAuthn user handle.- Returns:
truewhen the account has at least one passkey.
-