|
@@ -26,6 +26,7 @@ import org.springframework.context.ApplicationListener;
|
|
import org.springframework.context.event.GenericApplicationListenerAdapter;
|
|
import org.springframework.context.event.GenericApplicationListenerAdapter;
|
|
import org.springframework.context.event.SmartApplicationListener;
|
|
import org.springframework.context.event.SmartApplicationListener;
|
|
import org.springframework.security.authentication.AuthenticationTrustResolver;
|
|
import org.springframework.security.authentication.AuthenticationTrustResolver;
|
|
|
|
+import org.springframework.security.config.Customizer;
|
|
import org.springframework.security.config.annotation.web.HttpSecurityBuilder;
|
|
import org.springframework.security.config.annotation.web.HttpSecurityBuilder;
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
|
@@ -249,6 +250,19 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
|
|
return new SessionFixationConfigurer();
|
|
return new SessionFixationConfigurer();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Allows configuring session fixation protection.
|
|
|
|
+ *
|
|
|
|
+ * @param sessionFixationCustomizer the {@link Customizer} to provide more options for
|
|
|
|
+ * the {@link SessionFixationConfigurer}
|
|
|
|
+ * @return the {@link SessionManagementConfigurer} for further customizations
|
|
|
|
+ */
|
|
|
|
+ public SessionManagementConfigurer<H> sessionFixation(Customizer<SessionFixationConfigurer> sessionFixationCustomizer)
|
|
|
|
+ throws Exception {
|
|
|
|
+ sessionFixationCustomizer.customize(new SessionFixationConfigurer());
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Controls the maximum number of sessions for a user. The default is to allow any
|
|
* Controls the maximum number of sessions for a user. The default is to allow any
|
|
* number of users.
|
|
* number of users.
|
|
@@ -260,6 +274,20 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
|
|
return new ConcurrencyControlConfigurer();
|
|
return new ConcurrencyControlConfigurer();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Controls the maximum number of sessions for a user. The default is to allow any
|
|
|
|
+ * number of users.
|
|
|
|
+ *
|
|
|
|
+ * @param sessionConcurrencyCustomizer the {@link Customizer} to provide more options for
|
|
|
|
+ * the {@link ConcurrencyControlConfigurer}
|
|
|
|
+ * @return the {@link SessionManagementConfigurer} for further customizations
|
|
|
|
+ */
|
|
|
|
+ public SessionManagementConfigurer<H> sessionConcurrency(Customizer<ConcurrencyControlConfigurer> sessionConcurrencyCustomizer)
|
|
|
|
+ throws Exception {
|
|
|
|
+ sessionConcurrencyCustomizer.customize(new ConcurrencyControlConfigurer());
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Invokes {@link #postProcess(Object)} and sets the
|
|
* Invokes {@link #postProcess(Object)} and sets the
|
|
* {@link SessionAuthenticationStrategy} for session fixation.
|
|
* {@link SessionAuthenticationStrategy} for session fixation.
|
|
@@ -338,6 +366,18 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
|
|
*/
|
|
*/
|
|
public final class ConcurrencyControlConfigurer {
|
|
public final class ConcurrencyControlConfigurer {
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Controls the maximum number of sessions for a user. The default is to allow any
|
|
|
|
+ * number of users.
|
|
|
|
+ *
|
|
|
|
+ * @param maximumSessions the maximum number of sessions for a user
|
|
|
|
+ * @return the {@link ConcurrencyControlConfigurer} for further customizations
|
|
|
|
+ */
|
|
|
|
+ public ConcurrencyControlConfigurer maximumSessions(int maximumSessions) {
|
|
|
|
+ SessionManagementConfigurer.this.maximumSessions = maximumSessions;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* The URL to redirect to if a user tries to access a resource and their session
|
|
* The URL to redirect to if a user tries to access a resource and their session
|
|
* has been expired due to too many sessions for the current user. The default is
|
|
* has been expired due to too many sessions for the current user. The default is
|