【问题标题】:StormPath Spring Boot Integration - getting Invalid CORS request errorStormPath Spring Boot Integration - 获取 Invalid CORS request 错误
【发布时间】:2016-12-07 06:19:55
【问题描述】:

尝试将 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".

感谢您的帮助。

【问题讨论】:

    标签: java spring-boot cors stormpath


    【解决方案1】:

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

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

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

    希望这会有所帮助,

    何塞·路易斯

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

    【讨论】:

    • #2 通过升级到 SDK v1.2.2 得到解决,但 #3 仍然出现错误。在 application.properties 文件中添加了stormpath.web.cors.enabled = false 现在登录(POST)抛出“403,禁止,无可用消息”错误。谢谢!
    • 嗨@Faizal,很遗憾听到 403 响应,因为您使用的是 PostMan,响应是由其中存储的 cookie 引起的,当LoginController 看到对已验证请求的登录尝试(存储的 cookie)将拒绝 403 的请求。你可以尝试清理 cookie 和/或使用另一个客户端,如 curl 来确认这是你面临的问题吗?谢谢
    • 使用 curl 我可以点击帖子网址,但不能使用 PostMan(清除 cookie)
    • 嗨@Faizal,很高兴看到它在curl 中工作,关于你删除POSTMan cookie,你是怎么做到的?我假设您使用的是 chrome 扩展程序,默认情况下不显示任何正在发送/接收的 cookie,但是当我在顶部启用 POSTMan 拦截器时,我可以看到正在发送的 cookie,这不是一个简单的方法手动删除它们。但是,我让它工作的方式是调用/logout 端点。这肯定会清除 cookie,然后您可以再次重试/login。 HTH。
    • 很高兴听到@Faizal。
    猜你喜欢
    • 2021-11-09
    • 2015-05-06
    • 2018-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-29
    • 2021-12-11
    • 1970-01-01
    相关资源
    最近更新 更多