From 9af3b6431ba0cbde7ce9d9ac2212c8cf16979995 Mon Sep 17 00:00:00 2001 From: Dusan Jakub Date: Wed, 27 Sep 2023 12:12:52 +0200 Subject: [PATCH] replace the index page --- .../java/com/ysoft/geecon/IndexResource.java | 30 +++ .../ysoft/geecon/webauthn/LoginResource.java | 56 ---- .../resources/META-INF/resources/index.html | 254 ------------------ .../templates/IndexResource/index.html | 16 ++ 4 files changed, 46 insertions(+), 310 deletions(-) create mode 100644 src/main/java/com/ysoft/geecon/IndexResource.java delete mode 100644 src/main/java/com/ysoft/geecon/webauthn/LoginResource.java delete mode 100644 src/main/resources/META-INF/resources/index.html create mode 100644 src/main/resources/templates/IndexResource/index.html diff --git a/src/main/java/com/ysoft/geecon/IndexResource.java b/src/main/java/com/ysoft/geecon/IndexResource.java new file mode 100644 index 0000000..612b187 --- /dev/null +++ b/src/main/java/com/ysoft/geecon/IndexResource.java @@ -0,0 +1,30 @@ +package com.ysoft.geecon; + +import io.quarkus.qute.CheckedTemplate; +import io.quarkus.qute.TemplateInstance; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path("/") +public class IndexResource { + + @GET + @Produces(MediaType.TEXT_HTML) + public TemplateInstance index() { + return Templates.index(); + } + + + @CheckedTemplate + public static class Templates { + public static native TemplateInstance index(); + } +} + + + + + + diff --git a/src/main/java/com/ysoft/geecon/webauthn/LoginResource.java b/src/main/java/com/ysoft/geecon/webauthn/LoginResource.java deleted file mode 100644 index c60ce5b..0000000 --- a/src/main/java/com/ysoft/geecon/webauthn/LoginResource.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.ysoft.geecon.webauthn; - -import com.ysoft.geecon.repo.UsersRepo; -import io.quarkus.security.webauthn.WebAuthnLoginResponse; -import io.quarkus.security.webauthn.WebAuthnRegisterResponse; -import io.quarkus.security.webauthn.WebAuthnSecurity; -import io.vertx.ext.auth.webauthn.Authenticator; -import io.vertx.ext.web.RoutingContext; -import jakarta.inject.Inject; -import jakarta.ws.rs.BeanParam; -import jakarta.ws.rs.POST; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.core.Response; -import jakarta.ws.rs.core.Response.Status; - -import java.net.URI; - -@Path("webauthn") -public class LoginResource { - - @Inject - WebAuthnSecurity webAuthnSecurity; - @Inject - UsersRepo usersRepo; - - @Path("/login") - @POST - public Response login(@BeanParam WebAuthnLoginResponse webAuthnResponse, - RoutingContext ctx) { - // Input validation - if (!webAuthnResponse.isSet() - || !webAuthnResponse.isValid()) { - return Response.status(Status.BAD_REQUEST).build(); - } - - Authenticator authenticator = this.webAuthnSecurity.login(webAuthnResponse, ctx) - .await().indefinitely(); - - return Response.seeOther(URI.create("/")).build(); - } - - @Path("/register") - @POST - public Response register(@BeanParam WebAuthnRegisterResponse webAuthnResponse, - RoutingContext ctx) { - // Input validation - if (!webAuthnResponse.isSet() || !webAuthnResponse.isValid()) { - return Response.status(Status.BAD_REQUEST).build(); - } - - Authenticator authenticator = this.webAuthnSecurity.register(webAuthnResponse, ctx) - .await().indefinitely(); - - return Response.seeOther(URI.create("/")).build(); - } -} \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/index.html b/src/main/resources/META-INF/resources/index.html deleted file mode 100644 index d8a2134..0000000 --- a/src/main/resources/META-INF/resources/index.html +++ /dev/null @@ -1,254 +0,0 @@ - - - - - Login - - - - - - - - - - - - - - -
-
- - -
- -
- The interaction starts with an AJAX call. -
POST -
-
- -
- -
- The server prepares a challenge for the browser to sign. -
- -
- - - - - - -
-
- -
- -
-
- - - - \ No newline at end of file diff --git a/src/main/resources/templates/IndexResource/index.html b/src/main/resources/templates/IndexResource/index.html new file mode 100644 index 0000000..92bf76a --- /dev/null +++ b/src/main/resources/templates/IndexResource/index.html @@ -0,0 +1,16 @@ +{#include base} + {#title}Welcome{/title} +
+
+
+
+
+ Welcome +
Please start your journey at https://oauth-playground.online
+
+
+
+
+
+{/include}