我不知道如何,但会话超时非常短。据我所知,Spring Security会话超时取决于默认服务器的会话配置。我发现GlassFish超时是1800秒(10分钟)。但我认为会话每5分钟删除一次。怎么会发生这种情况? 这是我的Spring Security配置:
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<!-- enable use-expressions -->
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/adminRole/**" access="hasRole('ROLE_ADMIN')" />
<intercept-url pattern="/userRole/**" access="hasRole('ROLE_USER')" />
<!-- access denied page -->
<access-denied-handler error-page="/403" />
<form-login
login-page="/"
default-target-url="/resolveRoles"
authentication-failure-url="/?error"
username-parameter="username"
password-parameter="password" />
<remember-me key="key" token-validity-seconds="2419200" />
<logout logout-success-url="/?logout" />
<!-- enable csrf protection -->
</http>
<!-- Select users and user_roles from database -->
<authentication-manager>
<authentication-provider>
<password-encoder hash="sha"/>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query=
"select username,password, enabled from smsc.users where username=?"
authorities-by-username-query=
"select username, role from smsc.user_roles where username =? " />
</authentication-provider>
</authentication-manager>
</beans:beans>
答案 0 :(得分:7)
只有会话超时,但春季安全性没有额外超时(记住我令牌的除外,但这是另一回事)。
您可以在web.xml
:
<web-app>
<session-config>
<!-- in minutes -->
<session-timeout>60</session-timeout>
</session-config>
</web-app>