io.quarkus.security.webauthn.WebAuthnTrustedIdentityProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-security-webauthn Show documentation
Show all versions of quarkus-security-webauthn Show documentation
Secure your applications with WebAuthn
package io.quarkus.security.webauthn;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import io.quarkus.security.identity.AuthenticationRequestContext;
import io.quarkus.security.identity.IdentityProvider;
import io.quarkus.security.identity.SecurityIdentity;
import io.quarkus.security.identity.request.TrustedAuthenticationRequest;
import io.quarkus.security.runtime.QuarkusPrincipal;
import io.quarkus.security.runtime.QuarkusSecurityIdentity;
import io.smallrye.mutiny.Uni;
/**
* IdentityProvider for {@link TrustedAuthenticationRequest}
*/
@ApplicationScoped
public class WebAuthnTrustedIdentityProvider implements IdentityProvider {
@Inject
WebAuthnSecurity security;
@Inject
WebAuthnUserProvider userProvider;
@Override
public Class getRequestType() {
return TrustedAuthenticationRequest.class;
}
@Override
public Uni authenticate(TrustedAuthenticationRequest request, AuthenticationRequestContext context) {
QuarkusSecurityIdentity.Builder builder = QuarkusSecurityIdentity.builder();
builder.setPrincipal(new QuarkusPrincipal(request.getPrincipal()));
builder.addRoles(userProvider.getRoles(request.getPrincipal()));
return Uni.createFrom().item(builder.build());
}
}