-
-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better workaround for cookie max-age
- Loading branch information
Showing
3 changed files
with
38 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...feed-server/src/main/java/com/commafeed/security/FormAuthenticationCookieInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.commafeed.security; | ||
|
||
import io.quarkus.vertx.http.runtime.HttpConfiguration; | ||
import io.quarkus.vertx.http.runtime.security.FormAuthenticationMechanism; | ||
import io.quarkus.vertx.web.RouteFilter; | ||
import io.vertx.core.http.Cookie; | ||
import io.vertx.core.http.impl.ServerCookie; | ||
import io.vertx.ext.web.RoutingContext; | ||
import jakarta.inject.Singleton; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* Intercepts responses and sets a Max-Age on the cookie created by {@link FormAuthenticationMechanism} because it has no value by default. | ||
* | ||
* This is a workaround for https://github.com/quarkusio/quarkus/issues/42463 | ||
*/ | ||
@RequiredArgsConstructor | ||
@Singleton | ||
public class FormAuthenticationCookieInterceptor { | ||
|
||
private final HttpConfiguration config; | ||
|
||
@RouteFilter(Integer.MAX_VALUE) | ||
public void cookieInterceptor(RoutingContext context) { | ||
context.addHeadersEndHandler(v -> { | ||
Cookie cookie = context.request().getCookie(config.auth.form.cookieName); | ||
if (cookie instanceof ServerCookie sc && sc.isChanged()) { | ||
cookie.setMaxAge(config.auth.form.timeout.toSeconds()); | ||
} | ||
}); | ||
|
||
context.next(); | ||
} | ||
} |
90 changes: 0 additions & 90 deletions
90
...c/main/java/com/commafeed/security/mechanism/CookieMaxAgeFormAuthenticationMechanism.java
This file was deleted.
Oops, something went wrong.