Package io.quarkus.security.webauthn
Class WebAuthnSecurity
java.lang.Object
io.quarkus.security.webauthn.WebAuthnSecurity
Utility class that allows users to manually login or register users using WebAuthn
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) WebAuthnAuthenticationMechanism(package private) io.quarkus.tls.TlsConfigurationRegistry(package private) WebAuthnAuthenticatorStorage -
Constructor Summary
ConstructorsConstructorDescriptionWebAuthnSecurity(WebAuthnRunTimeConfig config, io.vertx.core.Vertx vertx, WebAuthnAuthenticatorStorage database) -
Method Summary
Modifier and TypeMethodDescription(package private) static booleancontainsRequiredString(io.vertx.core.json.JsonObject json, String key) getAllowedOrigins(io.vertx.ext.web.RoutingContext ctx) Returns the list of allowed origins, or defaults to the current request's origin if unconfigured.io.smallrye.mutiny.Uni<com.webauthn4j.data.PublicKeyCredentialRequestOptions> getLoginChallenge(String username, io.vertx.ext.web.RoutingContext ctx) Obtains a login challenge for the given optional username.io.smallrye.mutiny.Uni<com.webauthn4j.data.PublicKeyCredentialCreationOptions> getRegisterChallenge(String username, String displayName, io.vertx.ext.web.RoutingContext ctx) Obtains a registration challenge for the given required username and displayName.com.webauthn4j.async.WebAuthnAsyncManagerReturns the underlying WebAuthn4J authenticatorio.smallrye.mutiny.Uni<WebAuthnCredentialRecord> login(WebAuthnLoginResponse response, io.vertx.ext.web.RoutingContext ctx) Logs an existing WebAuthn user in.io.smallrye.mutiny.Uni<WebAuthnCredentialRecord> login(io.vertx.core.json.JsonObject response, io.vertx.ext.web.RoutingContext ctx) Logs an existing WebAuthn user in.voidlogout(io.vertx.ext.web.RoutingContext ctx) Clears the login cookie on the current requestio.smallrye.mutiny.Uni<WebAuthnCredentialRecord> register(String username, WebAuthnRegisterResponse response, io.vertx.ext.web.RoutingContext ctx) Registers a new WebAuthn credentials.io.smallrye.mutiny.Uni<WebAuthnCredentialRecord> register(String username, io.vertx.core.json.JsonObject response, io.vertx.ext.web.RoutingContext ctx) Registers a new WebAuthn credentials.voidrememberUser(String userID, io.vertx.ext.web.RoutingContext ctx) Adds a login cookie to the current request for the given user ID(package private) static voidremoveCookie(io.vertx.ext.web.RoutingContext ctx, String name) (package private) WebAuthnAuthenticatorStoragestorage()toJsonString(com.webauthn4j.data.PublicKeyCredentialCreationOptions challenge) toJsonString(com.webauthn4j.data.PublicKeyCredentialRequestOptions challenge)
-
Field Details
-
certificates
@Inject io.quarkus.tls.TlsConfigurationRegistry certificates -
authMech
-
storage
-
-
Constructor Details
-
WebAuthnSecurity
public WebAuthnSecurity(WebAuthnRunTimeConfig config, io.vertx.core.Vertx vertx, WebAuthnAuthenticatorStorage database)
-
-
Method Details
-
getRegisterChallenge
public io.smallrye.mutiny.Uni<com.webauthn4j.data.PublicKeyCredentialCreationOptions> getRegisterChallenge(String username, String displayName, io.vertx.ext.web.RoutingContext ctx) Obtains a registration challenge for the given required username and displayName. This will also create and save a challenge in a session cookie.- Parameters:
username- the username for the registrationdisplayName- the displayName for the registrationctx- the Vert.x context- Returns:
- the registration challenge.
-
getLoginChallenge
public io.smallrye.mutiny.Uni<com.webauthn4j.data.PublicKeyCredentialRequestOptions> getLoginChallenge(String username, io.vertx.ext.web.RoutingContext ctx) Obtains a login challenge for the given optional username. This will also create and save a challenge in a session cookie.- Parameters:
username- the optional username for the loginctx- the Vert.x context- Returns:
- the login challenge.
-
register
public io.smallrye.mutiny.Uni<WebAuthnCredentialRecord> register(String username, WebAuthnRegisterResponse response, io.vertx.ext.web.RoutingContext ctx) Registers a new WebAuthn credentials. This will check it, clear the challenge cookie and return it in case of success, but not invokeWebAuthnUserProvider.store(WebAuthnCredentialRecord), you have to do it manually in case of success. This will also not set a login cookie, you have to do it manually usingrememberUser(String, RoutingContext)or using any other way.- Parameters:
response- the Webauthn registration infoctx- the current requestthe- username to register credentials for- Returns:
- the newly created credentials
-
register
public io.smallrye.mutiny.Uni<WebAuthnCredentialRecord> register(String username, io.vertx.core.json.JsonObject response, io.vertx.ext.web.RoutingContext ctx) Registers a new WebAuthn credentials. This will check it, clear the challenge cookie and return it in case of success, but not invokeWebAuthnUserProvider.store(WebAuthnCredentialRecord), you have to do it manually in case of success. This will also not set a login cookie, you have to do it manually usingrememberUser(String, RoutingContext)or using any other way.- Parameters:
response- the Webauthn registration infoctx- the current requestthe- username to register credentials for- Returns:
- the newly created credentials
-
login
public io.smallrye.mutiny.Uni<WebAuthnCredentialRecord> login(WebAuthnLoginResponse response, io.vertx.ext.web.RoutingContext ctx) Logs an existing WebAuthn user in. This will check it, clear the challenge cookie and return the updated credentials in case of success, but not invokeWebAuthnUserProvider.update(String, long), you have to do it manually in case of success. This will also not set a login cookie, you have to do it manually usingrememberUser(String, RoutingContext)or using any other way.- Parameters:
response- the Webauthn login infoctx- the current request- Returns:
- the updated credentials
-
login
public io.smallrye.mutiny.Uni<WebAuthnCredentialRecord> login(io.vertx.core.json.JsonObject response, io.vertx.ext.web.RoutingContext ctx) Logs an existing WebAuthn user in. This will check it, clear the challenge cookie and return the updated credentials in case of success, but not invokeWebAuthnUserProvider.update(String, long), you have to do it manually in case of success. This will also not set a login cookie, you have to do it manually usingrememberUser(String, RoutingContext)or using any other way.- Parameters:
response- the Webauthn login infoctx- the current request- Returns:
- the updated credentials
-
removeCookie
-
getWebAuthn4J
public com.webauthn4j.async.WebAuthnAsyncManager getWebAuthn4J()Returns the underlying WebAuthn4J authenticator- Returns:
- the underlying WebAuthn4J authenticator
-
rememberUser
Adds a login cookie to the current request for the given user ID- Parameters:
userID- the user ID to use asPrincipalctx- the current request, in order to add a cookie
-
logout
public void logout(io.vertx.ext.web.RoutingContext ctx) Clears the login cookie on the current request- Parameters:
ctx- the current request, in order to clear the login cookie
-
containsRequiredString
-
toJsonString
-
toJsonString
-
getAllowedOrigins
Returns the list of allowed origins, or defaults to the current request's origin if unconfigured. -
storage
WebAuthnAuthenticatorStorage storage()
-