Interface PasskeyRepository

All Known Implementing Classes:
JdbcPasskeyRepository

public interface PasskeyRepository
Port that reads and manages the passkeys users registered. Creating a credential and verifying its signatures belong to the WebAuthn framework, so this port only lists, renames and deletes. It never returns null.
  • Method Details

    • findUserIdByUsername

      Optional<String> findUserIdByUsername(String username)
      Finds the WebAuthn user handle of an account.
      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

      List<Passkey> findByUserId(String userId)
      Lists the passkeys of a user, oldest first.
      Parameters:
      userId - WebAuthn user handle of the owner.
      Returns:
      the passkeys, possibly empty.
    • findByIdAndUserId

      Optional<Passkey> findByIdAndUserId(String id, String userId)
      Finds one passkey of a user.
      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

      boolean rename(String id, String userId, String label)
      Renames a passkey of a user.
      Parameters:
      id - credential identifier.
      userId - WebAuthn user handle of the owner.
      label - new label.
      Returns:
      true when a passkey was renamed.
    • delete

      boolean delete(String id, String userId)
      Deletes a passkey of a user.
      Parameters:
      id - credential identifier.
      userId - WebAuthn user handle of the owner.
      Returns:
      true when a passkey was deleted.
    • existsForAccount

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