简体   繁体   中英

StormPath Spring Boot Integration - getting Invalid CORS request error

Trying to integrate the StormPath with Spring Boot receiving multiple errors. Following here is the application setup.

Using stormpath-default-spring-boot-starter version 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".

Appreciate the help.

For your problem #2 we released the SDK v1.2.2 and fixed the issue you're facing now. When organizations and/or groups were mapped to an application this problem occurred. Updating the library version will allow you to render the login page.

As for #3 you have two options either to disable the CORS filter stormpath.web.cors.enabled = false or add the PostMap origin header to the list of allowed originUris ie stormpath.web.cors.allowed.originUris = <origin-header-value> .

In case you want to dig in more about CORS you might be interested in checking the blog Tips and Tricks for AngularJS and Spring Boot with Stormpath article from one of Stormpath Evangelists.

Hope this helps,

José Luis

Full disclosure: I am one of Stormpath's Engineers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM