2016-12-06 69 views
2

试图将StormPath与Spring Boot集成,接收多个错误。以下是应用程序设置。StormPath Spring Boot集成 - 获取无效的CORS请求错误

使用stormpath-default-spring-boot-starter版本1.2.1。

1) application.properties contains only stormpath id, secret and href as follows, 

stormpath.client.apiKey.id = <id> 
stormpath.client.apiKey.secret = <secret> 
stormpath.application.href = <href> 

2) SpringSecurityWebAppConfig.Java (Override spring security) 

@Configuration 
public class SpringSecurityWebAppConfig extends WebSecurityConfigurerAdapter { 
    @Override 
    protected void configure(HttpSecurity http) throws Exception { 
     http.apply(stormpath()); 
    } 
} 

When application is run, 
------------------------ 
1) http://localhost:8080/register renders register screen. 

2) http://localhost:8080/login (GET) throws error "Unable to invoke StormPath controller: Resolved account store cannot be an Organization". 

3) http://localhost:8080/login (POST) (from PostMan) throws error "Invalid CORS request". 

欣赏帮助。

回答

5

对于您的问题#2,我们发布了SDK v1.2.2并解决了您现在面临的问题。当组织和/或组织映射到应用程序时,发生此问题。更新库版本将允许您呈现login页面。

至于#3有两个选项或者禁用CORS过滤stormpath.web.cors.enabled = false或PostMap origin头添加到所允许originUrisstormpath.web.cors.allowed.originUris = <origin-header-value>列表。

如果您想深入了解CORS,您可能有兴趣查看博客Tips and Tricks for AngularJS and Spring Boot with Stormpath来自Stormpath Evangelists之一的文章。

希望这有助于

何塞·路易斯·

全面披露:我Stormpath的工程师之一。

+0

#2通过升级到SDK v1.2.2得到解决,但#3仍然看到错误。在application.properties文件中添加了stormpath.web.cors.enabled = false,现在登录(POST)正在抛出“403,禁止,无消息”错误。谢谢! – Faizal

+0

Hi @Faizal,很抱歉听说403响应,因为你使用PostMan响应是由存储的Cookie引起的,当LoginController看到已经通过认证的请求(存储的cookie)的登录尝试将拒绝请求与403.你可以尝试清理饼干和/或使用另一个客户端,如'curl'来确认这是你面临的问题?谢谢 – jbarrueta

+0

curl我可以打Post URL但是不能用PostMan(清除cookies) – Faizal