Skip to content

Commit 243bf2a

Browse files
committed
Sync documentation of main branch
1 parent ffe806c commit 243bf2a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

_versions/main/guides/security-authentication-mechanisms.adoc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff 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
201203
CurrentIdentityAssociation 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

218216
The following properties can be used to configure form-based authentication:
219217

0 commit comments

Comments
 (0)