java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.passkeys.JdbcPasskeyRepository
All Implemented Interfaces:
PasskeyRepository

@Repository public class JdbcPasskeyRepository extends Object implements 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 Details

    • COLUMNS

      private static final String COLUMNS
      Columns of a credential, in the order the row mapper does not depend on.
      See Also:
    • FIND_USER_ID_BY_USERNAME

      private static final String FIND_USER_ID_BY_USERNAME
      Query returning the user handle of an account.
      See Also:
    • FIND_BY_USER_ID

      private static final String FIND_BY_USER_ID
      Query returning the credentials of a user.
      See Also:
    • FIND_BY_ID_AND_USER_ID

      private static final String FIND_BY_ID_AND_USER_ID
      Query returning one credential of a user.
      See Also:
    • RENAME

      private static final String RENAME
      Statement renaming a credential of a user.
      See Also:
    • DELETE

      private static final String DELETE
      Statement deleting a credential of a user.
      See Also:
    • EXISTS_FOR_ACCOUNT

      private static final String EXISTS_FOR_ACCOUNT
      Query telling whether an account has at least one credential.
      See Also:
    • jdbcClient

      private final org.springframework.jdbc.core.simple.JdbcClient jdbcClient
      JDBC client used to run the statements.
    • passkeyRowMapper

      private final PasskeyRowMapper passkeyRowMapper
      Maps a row to a passkey.
  • Constructor Details

    • JdbcPasskeyRepository

      public JdbcPasskeyRepository()
  • Method Details

    • findUserIdByUsername

      public Optional<String> findUserIdByUsername(String username)
      Description copied from interface: PasskeyRepository
      Finds the WebAuthn user handle of an account.
      Specified by:
      findUserIdByUsername in interface PasskeyRepository
      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

      public List<Passkey> findByUserId(String userId)
      Description copied from interface: PasskeyRepository
      Lists the passkeys of a user, oldest first.
      Specified by:
      findByUserId in interface PasskeyRepository
      Parameters:
      userId - WebAuthn user handle of the owner.
      Returns:
      the passkeys, possibly empty.
    • findByIdAndUserId

      public Optional<Passkey> findByIdAndUserId(String id, String userId)
      Description copied from interface: PasskeyRepository
      Finds one passkey of a user.
      Specified by:
      findByIdAndUserId in interface PasskeyRepository
      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

      public boolean rename(String id, String userId, String label)
      Description copied from interface: PasskeyRepository
      Renames a passkey of a user.
      Specified by:
      rename in interface PasskeyRepository
      Parameters:
      id - credential identifier.
      userId - WebAuthn user handle of the owner.
      label - new label.
      Returns:
      true when a passkey was renamed.
    • delete

      public boolean delete(String id, String userId)
      Description copied from interface: PasskeyRepository
      Deletes a passkey of a user.
      Specified by:
      delete in interface PasskeyRepository
      Parameters:
      id - credential identifier.
      userId - WebAuthn user handle of the owner.
      Returns:
      true when a passkey was deleted.
    • existsForAccount

      public boolean existsForAccount(UUID accountId)
      Description copied from interface: PasskeyRepository
      Tells whether an account has registered at least one passkey, in a single lookup.
      Specified by:
      existsForAccount in interface PasskeyRepository
      Parameters:
      accountId - identifier of the account (the users row), not its WebAuthn user handle.
      Returns:
      true when the account has at least one passkey.