Skip to content

Conversation

domdorn
Copy link
Contributor

@domdorn domdorn commented Feb 24, 2015

This allows to customize all parameters of the cookie to be generated and also allows to provide a strategy to manually calculate the contextPath (in case it needs a more complex logic to calculate it then just setting it from the request or setting it to a static value).

It includes test-cases and documentation in form of javadoc

@rwinch rwinch added the status: waiting-for-triage An issue we've not yet triaged label Feb 24, 2015
@cemo
Copy link

cemo commented Feb 26, 2015

I need to customize secure flag of Cookie as well.

+1

@domdorn
Copy link
Contributor Author

domdorn commented Mar 2, 2015

@rwinch is there anything missing preventing this to be merged? I would really like to see this in 1.0.1 as right now, we have to provide our own CookieHttpSessionStrategy just to override how certain things in the cookie are set. Thx

@rwinch
Copy link
Member

rwinch commented Mar 6, 2015

@domdorn Thanks for the quick responses. I am rather busy with getting Security 4.0 GA out right now so haven't had time to look at Spring Session.

After Security 4.0 GA I will be focusing on a 1.0.1 release. We will make sure something gets in 1.0.1 to resolve your issue.

@cbeattie-miovision
Copy link

I needed this as well. I needed to set the context path to a fixed value so I am glad to see that this is now possible in this PR.

The CookiePathCalculationStrategy is a nice touch but I wonder if it could be made a little more broad (and thus more useful). Clearly the purpose of the CookieHttpSessionStrategy class is to manage HTTP sessions via cookies and therefore the createSessionCookie() method is of critical importance. Wouldn't it be better to use the strategy pattern on the creation of the cookie itself rather than on only the path? For example:

public interface CookieCreationStrategy {
    Cookie createSessionCookie(HttpServletRequest, Map<String, String> sessionIds);
}

The default implementation (ie. DefaultCookieCreationStrategy()) could be exactly the same code that is currently in CookieHttpSessionStrategy.createSessionCookie() but using a strategy pattern would allow one to customize the way the cookie is created including things like setting the cookie domain or setting a custom path. One complication would be that createSessionCookie() currently uses some member variables but that isn't insurmountable.

Just a suggestion...but this approach seems a bit more flexible.

OR. Another far simpler approach would be to remove the final qualifier from CookieHttpSessionStrategy and allow for inheritance (noting the somewhat questionable value of doing so it certainly would be pragmatic).

@Youmoo
Copy link

Youmoo commented Oct 18, 2015

👍
I need to customize cookie.domain , to allow all sub domains share same sessions.

@leonty
Copy link

leonty commented Oct 27, 2015

Hi,

Any progress on this PR ? It's 8 months since it's been proposed while this functionality is required by many. I for instance have the same issue as @Youmoo.

@rwinch rwinch removed the status: waiting-for-triage An issue we've not yet triaged label Nov 17, 2015
@rwinch rwinch self-assigned this Nov 17, 2015
@rwinch rwinch added this to the 1.1.0 M1 milestone Nov 17, 2015
@rwinch
Copy link
Member

rwinch commented Nov 17, 2015

Thanks for the great request! I'm trying to aggregate all the feature requests for cookies, so we can solve this problem more holistically. Therefore, I'm closing this in favor of #299 which takes this feature into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants