Skip to content

Commit 1e71824

Browse files
committed
Revert "Revert "Updated webauthn quickstarts""
This reverts commit ea6709c.
1 parent ea6709c commit 1e71824

File tree

6 files changed

+23
-22
lines changed

6 files changed

+23
-22
lines changed

security-webauthn-quickstart/src/main/resources/META-INF/resources/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<li><a href="/api/users/me">User API</a></li>
4949
<li><a href="/api/admin">Admin API</a></li>
5050
<li><a href="/q/webauthn/logout">Logout</a></li>
51+
</ul>
5152
</nav>
5253
<div class="container">
5354
<div class="item">
@@ -86,7 +87,7 @@ <h1>Register</h1>
8687

8788
const loginButton = document.getElementById('login');
8889

89-
loginButton.onclick = () => {
90+
loginButton.addEventListener("click", (e) => {
9091
var userName = document.getElementById('userNameLogin').value;
9192
result.replaceChildren();
9293
webAuthn.login({ name: userName })
@@ -97,11 +98,11 @@ <h1>Register</h1>
9798
result.append("Login failed: "+err);
9899
});
99100
return false;
100-
};
101+
});
101102

102103
const registerButton = document.getElementById('register');
103104

104-
registerButton.onclick = () => {
105+
registerButton.addEventListener("click", (e) => {
105106
var userName = document.getElementById('userNameRegister').value;
106107
var firstName = document.getElementById('firstName').value;
107108
var lastName = document.getElementById('lastName').value;
@@ -114,7 +115,7 @@ <h1>Register</h1>
114115
result.append("Registration failed: "+err);
115116
});
116117
return false;
117-
};
118+
});
118119
</script>
119120
</body>
120121
</html>

security-webauthn-quickstart/src/test/java/org/acme/security/webauthn/test/WebAuthnResourceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ private void invokeCustomEndpoint(String uri, Filter cookieFilter, Consumer<Requ
9696
.then()
9797
.statusCode(200)
9898
.log().ifValidationFails()
99-
.cookie(WebAuthnController.CHALLENGE_COOKIE, Matchers.is(""))
100-
.cookie(WebAuthnController.USERNAME_COOKIE, Matchers.is(""))
101-
.cookie("quarkus-credential", Matchers.notNullValue());
99+
.cookie(WebAuthnEndpointHelper.getChallengeCookie(), Matchers.is(""))
100+
.cookie(WebAuthnEndpointHelper.getChallengeUsernameCookie(), Matchers.is(""))
101+
.cookie(WebAuthnEndpointHelper.getMainCookie(), Matchers.notNullValue());
102102
}
103103

104104
private void verifyLoggedIn(Filter cookieFilter, String userName, User user) {

security-webauthn-reactive-quickstart/src/main/java/org/acme/security/webauthn/LoginResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import org.jboss.resteasy.reactive.RestForm;
1111

12-
import io.quarkus.hibernate.reactive.panache.common.runtime.ReactiveTransactional;
12+
import io.quarkus.hibernate.reactive.panache.common.WithTransaction;
1313
import io.quarkus.security.webauthn.WebAuthnLoginResponse;
1414
import io.quarkus.security.webauthn.WebAuthnRegisterResponse;
1515
import io.quarkus.security.webauthn.WebAuthnSecurity;
@@ -25,7 +25,7 @@ public class LoginResource {
2525

2626
@Path("/login")
2727
@POST
28-
@ReactiveTransactional
28+
@WithTransaction
2929
public Uni<Response> login(@RestForm String userName,
3030
@BeanParam WebAuthnLoginResponse webAuthnResponse,
3131
RoutingContext ctx) {
@@ -63,7 +63,7 @@ public Uni<Response> login(@RestForm String userName,
6363

6464
@Path("/register")
6565
@POST
66-
@ReactiveTransactional
66+
@WithTransaction
6767
public Uni<Response> register(@RestForm String userName,
6868
@BeanParam WebAuthnRegisterResponse webAuthnResponse,
6969
RoutingContext ctx) {

security-webauthn-reactive-quickstart/src/main/java/org/acme/security/webauthn/MyWebAuthnSetup.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import java.util.Set;
88

99
import jakarta.enterprise.context.ApplicationScoped;
10-
11-
import io.quarkus.hibernate.reactive.panache.common.runtime.ReactiveTransactional;
10+
import io.quarkus.hibernate.reactive.panache.common.WithTransaction;
1211
import io.quarkus.security.webauthn.WebAuthnUserProvider;
1312
import io.smallrye.mutiny.Uni;
1413
import io.vertx.ext.auth.webauthn.AttestationCertificates;
@@ -17,21 +16,21 @@
1716
@ApplicationScoped
1817
public class MyWebAuthnSetup implements WebAuthnUserProvider {
1918

20-
@ReactiveTransactional
19+
@WithTransaction
2120
@Override
2221
public Uni<List<Authenticator>> findWebAuthnCredentialsByUserName(String userName) {
2322
return WebAuthnCredential.findByUserName(userName)
2423
.flatMap(MyWebAuthnSetup::toAuthenticators);
2524
}
2625

27-
@ReactiveTransactional
26+
@WithTransaction
2827
@Override
2928
public Uni<List<Authenticator>> findWebAuthnCredentialsByCredID(String credID) {
3029
return WebAuthnCredential.findByCredID(credID)
3130
.flatMap(MyWebAuthnSetup::toAuthenticators);
3231
}
3332

34-
@ReactiveTransactional
33+
@WithTransaction
3534
@Override
3635
public Uni<Void> updateOrStoreWebAuthnCredentials(Authenticator authenticator) {
3736
// leave the scooby user to the manual endpoint, because if we do it here it will be

security-webauthn-reactive-quickstart/src/main/resources/META-INF/resources/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<li><a href="/api/users/me">User API</a></li>
4949
<li><a href="/api/admin">Admin API</a></li>
5050
<li><a href="/q/webauthn/logout">Logout</a></li>
51+
</ul>
5152
</nav>
5253
<div class="container">
5354
<div class="item">
@@ -86,7 +87,7 @@ <h1>Register</h1>
8687

8788
const loginButton = document.getElementById('login');
8889

89-
loginButton.onclick = () => {
90+
loginButton.addEventListener("click", (e) => {
9091
var userName = document.getElementById('userNameLogin').value;
9192
result.replaceChildren();
9293
webAuthn.login({ name: userName })
@@ -97,11 +98,11 @@ <h1>Register</h1>
9798
result.append("Login failed: "+err);
9899
});
99100
return false;
100-
};
101+
});
101102

102103
const registerButton = document.getElementById('register');
103104

104-
registerButton.onclick = () => {
105+
registerButton.addEventListener("click", (e) => {
105106
var userName = document.getElementById('userNameRegister').value;
106107
var firstName = document.getElementById('firstName').value;
107108
var lastName = document.getElementById('lastName').value;
@@ -114,7 +115,7 @@ <h1>Register</h1>
114115
result.append("Registration failed: "+err);
115116
});
116117
return false;
117-
};
118+
});
118119
</script>
119120
</body>
120121
</html>

security-webauthn-reactive-quickstart/src/test/java/org/acme/security/webauthn/test/WebAuthnResourceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ private void invokeCustomEndpoint(String uri, Filter cookieFilter, Consumer<Requ
9696
.then()
9797
.statusCode(200)
9898
.log().ifValidationFails()
99-
.cookie(WebAuthnController.CHALLENGE_COOKIE, Matchers.is(""))
100-
.cookie(WebAuthnController.USERNAME_COOKIE, Matchers.is(""))
101-
.cookie("quarkus-credential", Matchers.notNullValue());
99+
.cookie(WebAuthnEndpointHelper.getChallengeCookie(), Matchers.is(""))
100+
.cookie(WebAuthnEndpointHelper.getChallengeUsernameCookie(), Matchers.is(""))
101+
.cookie(WebAuthnEndpointHelper.getMainCookie(), Matchers.notNullValue());
102102
}
103103

104104
private void verifyLoggedIn(Filter cookieFilter, String userName, User user) {

0 commit comments

Comments
 (0)