mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Update Principal check in TransportHandlingSockJsService
Closes gh-35753
This commit is contained in:
+9
-4
@@ -303,10 +303,15 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
|
||||
}
|
||||
else {
|
||||
Principal principal = session.getPrincipal();
|
||||
if (principal != null && !principal.equals(request.getPrincipal())) {
|
||||
logger.debug("The user for the session does not match the user for the request.");
|
||||
response.setStatusCode(HttpStatus.NOT_FOUND);
|
||||
return;
|
||||
if (principal != null) {
|
||||
// Compare usernames, not full equality (different login timestamps)
|
||||
Principal currentPrincipal = request.getPrincipal();
|
||||
if (!principal.equals(currentPrincipal) &&
|
||||
(currentPrincipal == null || !principal.getName().equals(currentPrincipal.getName()))) {
|
||||
logger.debug("The user for the session does not match the user for the request.");
|
||||
response.setStatusCode(HttpStatus.NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!transportHandler.checkSessionType(session)) {
|
||||
logger.debug("Session type does not match the transport type for the request.");
|
||||
|
||||
Reference in New Issue
Block a user