You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We login using POST http://localhost:8080/j_security_check - this sets the quarkus-credential cookie.
After successful login we access the protected page.
On the protected page we click on "logout", which destroys the cookie and redirects us back to the /login page.
Logout response headers look like this:
HTTP/1.1 303 See OtherLocation: http://localhost:8080/auth/loginSet-Cookie: quarkus-credential=;Version=1;Path=/;Max-Age=0;Expires=Thu, 01-Jan-1970 00:00:00 GMTcontent-length: 0
Everything is fine and dandy, we're logged out.
Now let's take the quarkus.http.auth.form.new-cookie-interval into consideration, which by default is 1 minute:
We login using POST http://localhost:8080/j_security_check - this sets the quarkus-credential cookie.
After successful login we access the protected page.
We wait more than 1 minute.
On the protected page we click on "logout", which should destroy the cookie and redirects us back to the /login page.
Logout response headers look like this:
We see the login screen, job well done, we implemented the logout? Nope, the user is still logged in and protected resources are still accessible (and stays logged in for the duration of quarkus.http.auth.form.timeout).
You see the issue in the headers - "destroy" cookie is overwritten by the "new-cookie-interval-cookie", or whatever is its name (at least I guess that it's new-cookie-interval functionality).
It looks like using default Quarkus configuration (new-cookie-interval equal to 1 minute) and example from documentation (logout code) we can easily arrive at a not-obviously non-working logout.
Expected behavior
Auth cookie is destroyed during logout.
Actual behavior
Auth cookie is not destroyed during logout if request was made after new-cookie-interval time.
ksdev-pl
changed the title
Conflict between form-base auth logout and quarkus.http.auth.form.new-cookie-interval
Conflict between form-based auth logout and quarkus.http.auth.form.new-cookie-interval
Aug 18, 2024
the issue here is that Quarkus REST adds cookies as Set-Cookie header, but io.vertx.core.http.impl.Http1xServerResponse "overrides it" (for lack of better word) as cookies are set after headers. so first it looks like this (headers added by Quarkus REST):
So even though technically authentication refreshes cookie first, it overrides the header response added after that.
I have actually wasted many hours today on trying to adjust Quarkus REST by adding org.jboss.resteasy.reactive.server.spi.ServerHttpResponse#addResponseCookie and it works, but I don't think I want to introduce that. Problem is that io.vertx.core.http.Cookie doesn't support Expires, Partitioned and Version attributes. So fixing it this way would require encoding stuff ourselves and introducing own equals, dealing with quoting etc. It is easier for servlets.
Maybe @geoand will decide to fix that discrepancy, but as for login, I think I'll just introduce utility method and rewrite docs.
@ksdev-pl thanks for reporting this and apologies for waiting
Describe the bug
Hello. Maybe I'm missing something, but have a look (example project at https://github.com/ksdev-pl/quarkus-logout-conflict):
Let's say we have a simple form-based authentication with logout method implemented according to the documentation (https://quarkus.io/guides/security-authentication-mechanisms#form-auth):
Let's test it:
POST http://localhost:8080/j_security_check
- this sets thequarkus-credential
cookie./login
page.Logout response headers look like this:
Everything is fine and dandy, we're logged out.
Now let's take the
quarkus.http.auth.form.new-cookie-interval
into consideration, which by default is 1 minute:POST http://localhost:8080/j_security_check
- this sets thequarkus-credential
cookie./login
page.Logout response headers look like this:
We see the login screen, job well done, we implemented the logout? Nope, the user is still logged in and protected resources are still accessible (and stays logged in for the duration of
quarkus.http.auth.form.timeout
).You see the issue in the headers - "destroy" cookie is overwritten by the "new-cookie-interval-cookie", or whatever is its name (at least I guess that it's new-cookie-interval functionality).
It looks like using default Quarkus configuration (new-cookie-interval equal to 1 minute) and example from documentation (logout code) we can easily arrive at a not-obviously non-working logout.
Expected behavior
Auth cookie is destroyed during logout.
Actual behavior
Auth cookie is not destroyed during logout if request was made after
new-cookie-interval
time.How to Reproduce?
Steps in description above. Basic example project: https://github.com/ksdev-pl/quarkus-logout-conflict
Output of
uname -a
orver
Linux fedora 6.10.4-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Aug 11 15:32:50 UTC 2024 x86_64 GNU/Linux
Output of
java -version
openjdk 21.0.1 2023-10-17 LTS
Quarkus version or git rev
Quarkus 3.13.2
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.6 (Red Hat 3.9.6-6)
Additional information
No response
The text was updated successfully, but these errors were encountered: