私は、JSPでフロントエンドを持ち、REST APIを持つJARを含むWARを持っているとしましょう。同じ戦争で春のセッションオーバーライドを防ぐ
複数の認証プロバイダが設定されているspring-security.xml
があります。
次のように私が直面してる問題は次のとおりです。
- ユーザー(USER1)は、基本認証(ローカルホスト/ APP1)を介して、JSPフロントエンドにログインしている
- 同じブラウザで(localhost/app2)
- このトークンがREST呼び出し(localhost/rest)に使用されるときはいつでも、JSPトークンからのユーザー(user1)は、フロントエンド(app1)はuser2によってオーバーライドされます。
REST APIの場合、create-session="never"
が有効です。しかし、JSPのセッションからのユーザーは、とにかくオーバーライドされます。
私はspring-security.xml
の3.2.9
Relevants部品春3.2.15を使用し、春のセキュリティだ:
<!-- 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>