I have a J2EE REST-based app using Spring Security 4.0.1.RELEASE. Needless to say, Spring documentation on sessionCreationPolicy
and sessionFixation
is sparse, aside from targeted questions here on StackOverflow.
I'm using a Java-based config for Spring Security like this:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(secureEnabled=true, prePostEnabled=true, jsr250Enabled=true, order=1)
public class DefaultSecurityBeansConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
.sessionFixation().migrateSession()
.and()...; // additional config omitted for brevity
}
}
I'd really just like to know what behavior to expect from Spring, as it relates to JSESSIONID
, given all possible combinations of sessionCreationPolicy
and sessionFixation
.
Possible values in the SessionCreationPolicy
enum are ALWAYS
, NEVER
, IF_REQUIRED
, and STATELESS
.
Possible values for session fixation are newSession
, migrateSession
, changeSessionId
, and none
.
Thank you.
NOTE: What prompted this question is that I am not seeing a new JSESSIONID
on every request when I have sessionCreationPolicy
set to IF_REQUIRED
and sessionFixation
set to changeSessionId
. A JSESSIONID
is correctly created, but is maintained across requests thereafter. I generalized my question about all combinations to hopefully help others in a similar situation with slightly different settings.