Skip to content

Commit 5b2fd4d

Browse files
author
eugenp
committed
new session work
1 parent a72cec5 commit 5b2fd4d

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎spring-security-mvc-session/src/main/java/org/baeldung/spring/MvcConfig.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public void addViewControllers(final ViewControllerRegistry registry) {
2727

2828
registry.addViewController("/login.html");
2929
registry.addViewController("/homepage.html");
30+
registry.addViewController("/sessionExpired.html");
31+
registry.addViewController("/invalidExpired.html");
3032
registry.addViewController("/console.html");
3133
}
3234

‎spring-security-mvc-session/src/main/resources/webSecurityConfig.xml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@
66
http://www.springframework.org/schema/beans
77
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
88

9-
<http use-expressions="true">
9+
<http create-session="always" use-expressions="true">
1010
<intercept-url pattern="/anonymous*" access="isAnonymous()" />
1111
<intercept-url pattern="/login*" access="permitAll" />
1212
<intercept-url pattern="/**" access="isAuthenticated()" />
1313

1414
<form-login login-page='/login.html' authentication-success-handler-ref="myAuthenticationSuccessHandler" authentication-failure-url="/login.html?error=true" />
1515

1616
<logout delete-cookies="JSESSIONID" />
17-
18-
<remember-me key="uniqueAndSecret" token-validity-seconds="86400"/>
19-
17+
18+
<remember-me key="uniqueAndSecret" token-validity-seconds="86400" />
19+
20+
<session-management>
21+
<concurrency-control max-sessions="2" />
22+
</session-management>
23+
2024
</http>
2125

2226
<beans:bean id="myAuthenticationSuccessHandler" class="org.baeldung.security.MySimpleUrlAuthenticationSuccessHandler" />

‎spring-security-mvc-session/src/main/webapp/WEB-INF/web.xml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<listener>
1313
<listener-class>org.baeldung.web.SessionListenerWithMetrics</listener-class>
1414
</listener>
15+
<listener>
16+
<listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
17+
</listener>
1518

1619
<!-- Spring root -->
1720
<context-param>

0 commit comments

Comments
 (0)