File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -194,8 +194,10 @@ code to destroy the cookie.
194194
195195[source,java]
196196----
197- @ConfigProperty(name = "quarkus.http.auth.form.cookie-name")
198- String cookieName;
197+ import io.quarkus.security.identity.CurrentIdentityAssociation;
198+ import io.quarkus.vertx.http.runtime.security.FormAuthenticationMechanism;
199+ import jakarta.ws.rs.core.Response;
200+ import jakarta.ws.rs.POST;
199201
200202@Inject
201203CurrentIdentityAssociation identity;
@@ -205,15 +207,11 @@ public Response logout() {
205207 if (identity.getIdentity().isAnonymous()) {
206208 throw new UnauthorizedException("Not authenticated");
207209 }
208- final NewCookie removeCookie = new NewCookie.Builder(cookieName)
209- .maxAge(0)
210- .expiry(Date.from(Instant.EPOCH))
211- .path("/")
212- .build();
213- return Response.noContent().cookie(removeCookie).build();
210+ FormAuthenticationMechanism.logout(identity.getIdentity()); <1>
211+ return Response.noContent().build();
214212}
215-
216213----
214+ <1> Perform the logout by removing the session cookie.
217215
218216The following properties can be used to configure form-based authentication:
219217
You can’t perform that action at this time.
0 commit comments