【发布时间】:2017-01-19 18:29:24
【问题描述】:
假设我有一个 WAR,它在 JSP 中有一个前端,并包含一个带有 REST API 的 JAR。
我有一个spring-security.xml,其中配置了多个 authenticationProviders。
我面临的问题如下:
- 用户(user1)通过基本认证(localhost/app1)登录到JSP前端
- 在同一浏览器上,不同的用户 (user2) 使用 oauth 令牌 (localhost/app2) 登录到不同的前端
- 只要将此令牌用于 REST 调用 (localhost/rest),来自 JSP 前端 (app1) 的用户 (user1) 就会被 user2 覆盖。
对于 REST API,create-session="never" 已启用。但是无论如何,来自 JSP 会话的用户都会被覆盖。
我正在使用 Spring 3.2.15 和 Spring Security 3.2.9
spring-security.xml的相关部分:
<!-- The configuration for the rest-api -->
<security:http pattern="/rest/**" create-session="never" use-expressions="true"
entry-point-ref="authenticationEntryPoint">
<security:anonymous enabled="false" />
<security:intercept-url pattern="/rest/**" access="permitAll" method="OPTIONS" />
<security:intercept-url pattern="/rest/**" access="isAuthenticated()" />
<security:custom-filter ref="CORSFilter" position="FIRST" />
<security:custom-filter ref="um-rest-resource-server" before="PRE_AUTH_FILTER" />
</security:http>
<!-- Other configration for the other endpoints (not under /rest/) ... -->
<oauth2:resource-server id="um-rest-resource-server" resource-id="um-rest-resource-server" token-services-ref="tokenVerifier" />
<bean id="tokenVerifier" class="be.healthconnect.iam.oauth2.verifier.TokenVerifier"></bean>
【问题讨论】:
标签: spring session spring-security token spring-security-oauth2