私はこの問題について調査していましたが、それでも回避できません。 問題は、私がajaxに電話をかけようとしているときに来るだけです。 「セッションが見つかりませんでしたので、提供されたCSRFトークンを確認できませんでした
@RestController
public class CsrfController {
@RequestMapping("/csrf")
public CsrfToken csrf(CsrfToken token) {
return token;
}
}
と私:システムはエラーSpring MVC and CSRF Integrationから基づいCould not verify the provided CSRF token because your session was not found.
を返します、私はこれを使用する必要があり、私はJavaのコンフィグを使用している場合は、これを解決するために@EnableWebSecurityを含めるする必要がありますが、XMLを使用している場合上記のクラスの使い方が分かりません。
本当に解決策があるのか、それとも私が使用できる解決策があるのかという疑問がありますか?
これはセキュリティ設定のxmlファイルです。
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<!-- Global Security Settings -->
<global-method-security pre-post-annotations="enabled" />
<context:component-scan base-package="com.my.web" />
<!-- Reads WEB Configuration file to resolve ${} and read @Value for Security-->
<context:property-placeholder location="classpath:cfg/web.cfg" />
<context:annotation-config />
<!-- Security Access Configuration -->
<http auto-config="false" use-expressions="true" authentication-manager-ref="CAP" disable-url-rewriting="true" entry-point-ref="IAE">
<session-management session-fixation-protection="newSession" session-authentication-error-url="/logout?timeout" >
<concurrency-control max-sessions="1" expired-url="/logout?expired" />
</session-management>
<custom-filter position="PRE_AUTH_FILTER" ref="entryFilter" />
<intercept-url pattern="/resources/**" access="permitAll()" requires-channel="https" />
<intercept-url pattern="/clearcache" access="permitAll()" requires-channel="https" />
<intercept-url pattern="/logout" access="permitAll()" requires-channel="https" />
<intercept-url pattern="/**" access="isFullyAuthenticated()" requires-channel="https" />
<port-mappings >
<port-mapping http="7001" https="7002" />
</port-mappings>
<headers>
<frame-options policy="SAMEORIGIN" />
<hsts />
<cache-control />
<xss-protection />
<content-type-options />
</headers>
</http>
<beans:bean id="entryFilter" class="com.my.web.security.HeaderFilter" >
<beans:property name="authenticationManager" ref="CAP"/>
</beans:bean>
<beans:bean id="IAE" class="com.my.web.security.CustomAuthenticationEntryPoint" />
<beans:bean id="CAP" class="com.my.web.security.CustomAuthenticationManager" />
<beans:import resource="../aop/aspect-security.xml" />
</beans:beans>
さらに、私はCA Siteminderと同様のシステムを使用しており、ログインフォームのないヘッダー情報に基づいてユーザーを検証します。
どのようにAJAX呼び出しがセッションを表示していますか? – Raedwald
は、ajaxの 'POST'呼び出しのためです。それはcsrfトークンを必要とし、それはセッショントークンと一致します – FreezY
あなたはAJAX呼び出しのコードを提供する必要があると思います。 – Raedwald