Fixing CORS issue

This commit is contained in:
Petri Tuomola
2021-11-24 18:53:33 +08:00
committed by Petri Tuomola
parent 2b57bf379e
commit aacb28b131
2 changed files with 8 additions and 2 deletions
@@ -68,8 +68,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/api/**").csrf().disable() // http //
.authorizeRequests() // .csrf().disable() //
.antMatcher("/api/**").authorizeRequests() //
.antMatchers(HttpMethod.OPTIONS, "/api/**").permitAll() //
.antMatchers(HttpMethod.POST, "/api/*/echo").permitAll() // .antMatchers(HttpMethod.POST, "/api/*/echo").permitAll() //
.antMatchers(HttpMethod.POST, "/api/*/authentication").permitAll() // .antMatchers(HttpMethod.POST, "/api/*/authentication").permitAll() //
.antMatchers(HttpMethod.POST, "/api/*/self/authentication").permitAll() // .antMatchers(HttpMethod.POST, "/api/*/self/authentication").permitAll() //
@@ -22,6 +22,8 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter; import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.ext.Provider; import javax.ws.rs.ext.Provider;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@@ -30,6 +32,8 @@ import org.springframework.util.StringUtils;
*/ */
@Provider @Provider
@Component
@Scope("singleton")
public class ResponseCorsFilter implements ContainerResponseFilter { public class ResponseCorsFilter implements ContainerResponseFilter {
@Override @Override