我重新启动服务器,这基本上清除了会话的所有内容。由于会话已被清除,用户不能再被视为已登录。(JSESSIONID cookie 保留在浏览器中)
但是除非我从浏览器中删除 JESSIONID cookie,否则 spring 不会重定向到登录。我的问题是 - 为什么 Spring Security 依赖于 JESSIONID cookie 而不是会话?
这是我的 spring-security.xml 配置 -
<security:global-method-security
secured-annotations="enabled" />
<security:http auto-config="true">
<!-- Restrict URLs based on role -->
<security:intercept-url pattern="/portal/login*"
access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/logoutSuccess*"
access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/**/*.css"
access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/**/*.js"
access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:intercept-url pattern="/portal/**"
access="ROLE_USER, ROLE_ADMIN" />
<security:form-login login-page="/portal/login.action"
login-processing-url="/portal/loginProcess" default-target-url="/portal/index"
authentication-failure-url="/portal/login.action?login_error=1" />
<security:logout logout-url="/portal/logout"
logout-success-url="/portal/login.action" />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service
data-source-ref="dataSource"
users-by-username-query="SELECT emailid AS username, password, IF(active = 'Y', true, false) AS enabled FROM users WHERE emailid = ?"
authorities-by-username-query="SELECT username, authority from authorities where username = ?" />
</security:authentication-provider>
</security:authentication-manager>