Passwordless login redirect (but it doesn't work yet)

This commit is contained in:
Dusan Jakub
2023-09-26 16:08:46 +02:00
parent 7cc76c3e99
commit fc0af19981
2 changed files with 7 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ import io.quarkus.runtime.util.StringUtil;
import io.quarkus.security.webauthn.WebAuthnLoginResponse; import io.quarkus.security.webauthn.WebAuthnLoginResponse;
import io.quarkus.security.webauthn.WebAuthnRegisterResponse; import io.quarkus.security.webauthn.WebAuthnRegisterResponse;
import io.quarkus.security.webauthn.WebAuthnSecurity; import io.quarkus.security.webauthn.WebAuthnSecurity;
import io.smallrye.common.annotation.Blocking;
import io.vertx.ext.auth.webauthn.Authenticator; import io.vertx.ext.auth.webauthn.Authenticator;
import io.vertx.ext.web.RoutingContext; import io.vertx.ext.web.RoutingContext;
import jakarta.inject.Inject; import jakarta.inject.Inject;
@@ -38,7 +39,6 @@ public class OAuthResource {
SessionsRepo sessionsRepo; SessionsRepo sessionsRepo;
@Inject @Inject
UriInfo uriInfo; UriInfo uriInfo;
@Inject @Inject
WebAuthnSecurity webAuthnSecurity; WebAuthnSecurity webAuthnSecurity;
@@ -72,6 +72,7 @@ public class OAuthResource {
@GET @GET
@Path("passwordless") @Path("passwordless")
@Produces(MediaType.TEXT_HTML) @Produces(MediaType.TEXT_HTML)
@Blocking
public TemplateInstance getPasswordless(AuthParams params) { public TemplateInstance getPasswordless(AuthParams params) {
var client = validateClient(params); var client = validateClient(params);
String sessionId = sessionsRepo.newAuthorizationSession(params, client); String sessionId = sessionsRepo.newAuthorizationSession(params, client);
@@ -82,6 +83,7 @@ public class OAuthResource {
@Path("passwordless/register") @Path("passwordless/register")
@Produces(MediaType.TEXT_HTML) @Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Blocking
public TemplateInstance registerPasswordless(@FormParam("sessionId") String sessionId, public TemplateInstance registerPasswordless(@FormParam("sessionId") String sessionId,
@BeanParam WebAuthnRegisterResponse webAuthnResponse, @BeanParam WebAuthnRegisterResponse webAuthnResponse,
RoutingContext ctx) { RoutingContext ctx) {
@@ -105,6 +107,7 @@ public class OAuthResource {
@Path("passwordless/login") @Path("passwordless/login")
@Produces(MediaType.TEXT_HTML) @Produces(MediaType.TEXT_HTML)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Blocking
public TemplateInstance loginPasswordless(@FormParam("sessionId") String sessionId, public TemplateInstance loginPasswordless(@FormParam("sessionId") String sessionId,
@BeanParam WebAuthnLoginResponse webAuthnResponse, @BeanParam WebAuthnLoginResponse webAuthnResponse,
RoutingContext ctx) { RoutingContext ctx) {

View File

@@ -116,7 +116,7 @@
</div> </div>
<form action="#" method="POST"> <form action="#" method="POST">
<input name="sessionId" type="hidden" value="somesessionid"> <input name="sessionId" type="hidden" value="{sessionId}">
<div id="form-generated"></div> <div id="form-generated"></div>
</form> </form>
</div> </div>
@@ -257,7 +257,7 @@
result.replaceChildren(); result.replaceChildren();
webAuthn.loginOnly({ name: userName }) webAuthn.loginOnly({ name: userName })
.then(body => { .then(body => {
form("/webauthn/login", { form("/auth/passwordless/login", {
'webAuthnId': body.id, 'webAuthnId': body.id,
'webAuthnRawId': body.rawId, 'webAuthnRawId': body.rawId,
'webAuthnResponseClientDataJSON': body.response.clientDataJSON, 'webAuthnResponseClientDataJSON': body.response.clientDataJSON,
@@ -286,7 +286,7 @@
webAuthn.registerOnly({ name: userName, displayName: userName /*firstName + " " + lastName*/}) webAuthn.registerOnly({ name: userName, displayName: userName /*firstName + " " + lastName*/})
.then(body => { .then(body => {
form("/webauthn/register", { form("/auth/passwordless/register", {
'webAuthnId': body.id, 'webAuthnId': body.id,
'webAuthnRawId': body.rawId, 'webAuthnRawId': body.rawId,
'webAuthnResponseAttestationObject': body.response.attestationObject, 'webAuthnResponseAttestationObject': body.response.attestationObject,