StormPath Spring Boot集成 - 获取无效的CORS请求错误

时间:2016-12-06 21:41:03

标签: java spring-boot cors stormpath

尝试将StormPath与Spring Boot集成,接收多个错误。以下是应用程序设置。

使用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".

感谢帮助。

1 个答案:

答案 0 :(得分:5)

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

对于#3,您有两个选项可以禁用CORS过滤器stormpath.web.cors.enabled = false或将PostMap origin标头添加到允许的originUris列表中,即stormpath.web.cors.allowed.originUris = <origin-header-value>。< / p>

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

希望这有帮助,

JoséLuis

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