Package io.quarkus.security.webauthn
Interface WebAuthnUserProvider
public interface WebAuthnUserProvider
Implement this interface in order to tell Quarkus WebAuthn how to look up
WebAuthn credentials, store new credentials, or update the credentials' counter,
as well as what roles those credentials map to.
-
Method Summary
Modifier and TypeMethodDescriptionio.smallrye.mutiny.Uni<WebAuthnCredentialRecord> findByCredentialId(String credentialId) Look up a WebAuthn credential by credential ID, this should return an exception Uni rather than return a null-item Uni in case the credential is not found.io.smallrye.mutiny.Uni<List<WebAuthnCredentialRecord>> findByUsername(String username) Look up a WebAuthn credential by username.Returns the set of roles for the given usernamedefault io.smallrye.mutiny.Uni<Void> store(WebAuthnCredentialRecord credentialRecord) Store a new WebAuthn credential.default io.smallrye.mutiny.Uni<Void> Update an existing WebAuthn credential's counter.
-
Method Details
-
findByUsername
Look up a WebAuthn credential by username. This should return an empty list Uni if the user name is not found.- Parameters:
username- the username- Returns:
- a list of credentials for this username, or an empty list if there are no credentials or if the user name is not found.
-
findByCredentialId
Look up a WebAuthn credential by credential ID, this should return an exception Uni rather than return a null-item Uni in case the credential is not found.- Parameters:
credentialId- the credential ID- Returns:
- a credentials for this credential ID.
-
update
Update an existing WebAuthn credential's counter. This is only used by the default login endpoint, which is disabled by default and can be enabled via thequarkus.webauthn.enable-login-endpoint. You don't have to implement this method if you handle logins manually viaWebAuthnSecurity.login(WebAuthnLoginResponse, io.vertx.ext.web.RoutingContext). The default behaviour is to not do anything.- Parameters:
credentialId- the credential ID- Returns:
- a uni completion object
-
store
Store a new WebAuthn credential. This is only used by the default registration endpoint, which is disabled by default and can be enabled via thequarkus.webauthn.enable-registration-endpoint. You don't have to implement this method if you handle registration manually viaMake sure that you never allow creating new credentials for a `username` that already exists. Otherwise you risk allowing third-parties to impersonate existing users by letting them add their own credentials to existing accounts. If you want to allow existing users to register more than one WebAuthn credential, you must make sure that the user is currently logged in under the sameinvalid reference
WebAuthnSecurity#register(WebAuthnRegisterResponse, io.vertx.ext.web.RoutingContext)usernameto which you want to add new credentials. In every other case, make sure to return a failedUnifrom this method. The default behaviour is to not do anything.- Parameters:
credentialRecord- the new credentials to store- Returns:
- a uni completion object
- Throws:
Exception- a failedUniif thecredentialIdalready exists, or theusernamealready has a credential and you disallow having more, or if trying to add credentials to other users than the current user.
-
getRoles
Returns the set of roles for the given username- Parameters:
username- the username- Returns:
- the set of roles (defaults to an empty set)
-