It’s just a simple username/password login
<form name="login" method ="POST" role="form" action="j_security_check">
<div class="login">
<label> Username</label>
<input formControlName="username" name="j_username" autofocus required>
</div>
<div class="login">
<label> Password</label>
<input type="password" formControlName="password" name="j_password" required>
</div>
<button class="submit" type="submit"> Sing In</button>
</form>
In my application, I have a button that calls “logoutUser”
protected logoutUser() {
this.http.post('/foo/logout', {}).subscribe ({
next: () => {
location.reload(); //reloads the page after the post call invalidates the session
}});}
the Java backend i have:
@jakarta.ws.rs.POST
@operation(responses = {@ApiResponse(responseCode="200", content=@Content(schema =
@Schema(implementation = Void.class))),})
public Response signout(@Context final HttpServletRequest request, @Context final
SecurityContext securityContext) {
request.getSession().invalidate();
return Response.ok().build();
}
}
I can login and logout and log back in FINE.
However, if I do the following:
1. Login
2. logout
3. wait ~5 mins
4. login
5. I receive 408 on my POST to …/j_security_check which is a Request Timeout.
I notice that when I login, i have 2 cookies - JSESSIONIDSSO and JSESSIONID. the JSESSIONIDSSO is set to "REMOVE" when I logout. I also noticed that the console has a warning that cookie "JSESSIONIDSSO" has been rejected because it is already expired. However, if I login within the 5 minutes or so, i still can.
From the login action, i see a POST (return 303) j_security_check where it sends JSESSIONID cookie and the response has the cookies JESSIONID and JSESSIONIDSSO
If I logout and the page refreshes, I see a GET on my current login page and I see the Response with set-cookie on JSESSIONIDSSO=REMOVE, Expires =Thu,01 jan 1970... and JSESSIONID = 123531....
I want the "path of least resistance" to get the login to work. If I can refresh cookie or clear cookie/cache when I logout that would be great. or if I can fix in backend that be great too. I think for now I just need to be able to 1. login. 2.logout. 3. after periods of time 4. login success.
Thanks