Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is behavior of getRequestedSessionId from SessionRepositoryRequestWrapper correct? #1161

Closed
mdenicki opened this issue Aug 19, 2018 · 2 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@mdenicki
Copy link

spring-session 2.0.5.RELEASE
spring-security 5.0.7.RELEASE

Method getRequestedSessionId in SessionRepositoryRequestWrapper (SessionRepositoryFilter.java) returns null if session id from request is not associated with any session from sessionRepository.

@Override
public String getRequestedSessionId() {
	S requestedSession = getRequestedSession();
	return (requestedSession != null ? requestedSession.getId() : null);
}

private S getRequestedSession() {
	if (!this.requestedSessionCached) {
		List<String> sessionIds = SessionRepositoryFilter.this.httpSessionIdResolver
				.resolveSessionIds(this);
		for (String sessionId : sessionIds) {
			S session = SessionRepositoryFilter.this.sessionRepository
					.findById(sessionId);
			if (session != null) {
				this.requestedSession = session;
				break;
			}
		}
		this.requestedSessionCached = true;
	}
	return this.requestedSession;
}

Is this correct behavior?
I'm using spring-session with spring-security and if requested session id is null, invalidSessionStrategy from SessionManagementFilter wont execute.

From SessionManagementFilter:

if (request.getRequestedSessionId() != null
		&& !request.isRequestedSessionIdValid()) {
	if (logger.isDebugEnabled()) {
		logger.debug("Requested session ID "
				+ request.getRequestedSessionId() + " is invalid.");
	}

	if (invalidSessionStrategy != null) {
		invalidSessionStrategy
				.onInvalidSessionDetected(request, response);
		return;
	}
}

Shouldn't getRequestedSessionId just return session id from request without any validation? That was behavior in 1.3.3.RELEASE version.

@vpavic vpavic self-assigned this Nov 27, 2018
@vpavic
Copy link
Contributor

vpavic commented Nov 27, 2018

We have addressed this in 2.1.1.RELEASE and 2.0.8.RELEASE. See #1229 for more details.

@vpavic vpavic closed this as completed Nov 27, 2018
@vpavic
Copy link
Contributor

vpavic commented Nov 27, 2018

Duplicate of #1229

@vpavic vpavic marked this as a duplicate of #1229 Nov 27, 2018
@vpavic vpavic added the status: duplicate A duplicate of another issue label Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants