2016-02-01 47 views
0

我下面Stormpath這裏的例子中遇到的預期CSRF令牌沒有發現錯誤。同時測試Stormpath

但是,當我試圖發出命令:

curl -X POST --data 'grant_type=password&username=ACCOUNT_USERNAME&password=ACCOUNT_PASSWORD' \ 
    -H 'Origin: http://localhost:8080' http://localhost:8080/oauth/token 

我得到這個錯誤:

<body> 
<div class="container-fluid"> 
    <div class="row"> 
     <div class="box col-md-6 col-md-offset-3"> 
      <div class="stormpath-header"> 
       <img src="https://stormpath.com/images/template/logo-nav.png" /> 
      </div> 
      <div class="logo"> 
       <h1>403</h1> 
      </div> 
      <p class="lead text-muted">Expected CSRF token not found. Has your session expired?</p> 
      <a href="/" class="btn btn-primary">Go Home</a> 
     </div> 
    </div> 
</div> 
</body> 

如何解決這個任何線索?

回答

0

您正在使用哪款Stormpath Spring Boot Starter?

stormpath-default-spring-boot-starter(和其他)包括Spring Security。

此時,Spring Security和/oauth/token與Stormpath集成不兼容。

好消息!我們正在本週發佈新的令牌管理集成。它將被釋放1.0.RC8.3。你可以跟蹤它的狀態here。它通過Spring堆棧完美集成,包括Spring Security。它還提供訪問和刷新令牌,並支持爲新的訪問令牌交換刷新令牌。

如果您希望/oauth/token端點在本發行版之前運行,您可以使用不同的Stormpath Starter,也可以禁用Spring Security。可以使用stormpath-spring-boot-starter

對於第二種方法,下面幾行添加到您的application.properties文件:

stormpath.spring.security.enabled = false security.basic.enabled = false

+0

我不包括Spring Security的,但正如你所說,stormpath已經包含了春季安全。我正在使用stormpath-spring-boot-starter。我試圖禁用application.properties中的spring安全性,但是當我啓動服務器時出現了一大堆錯誤。 – dickyj

+0

我爲Stormpath工作。我們切換到[email protected]。請發送您的pom.xml或build.gradle文件。如果有幫助,我們也可以做屏幕分享。當我們弄清楚發生了什麼時,我會在這裏發佈解決方案。 – afitnerd

+0

我也想指出'stormpath-spring-boot-starter'不包括Spring Security。包括Spring Security在內的所有* stormpath-default-spring-boot-starter,'stormpath-spring-security-spring-boot-starter'和'stormpath-spring-security-webmvc-spring-boot-starter'。 – afitnerd