Cannot send Authorization Bearer Token using Springfox

后端 未结 7 837
无人及你
无人及你 2021-02-08 05:59

I\'m having trouble understanding why \"Authorization: Bearer __\" is not being sent in my api using Springfox 2.5.0. I have the following configuration:

private         


        
相关标签:
7条回答
  • 2021-02-08 06:30

    Solution given by Jorge Santos Neill worked for me.

    Only variation is my SecurityConfig.java as mentioned below

    import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.security.config.annotation.web.builders.HttpSecurity;
    import org.springframework.security.config.annotation.web.builders.WebSecurity;
    import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
    import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
    import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
    
    @EnableWebSecurity
    @EnableResourceServer
    @EnableOAuth2Sso
    @Configuration
    
    public class SecurityConfig extends WebSecurityConfigurerAdapter {
    
        @Override
        protected void configure(final HttpSecurity http) throws Exception {
            http.authorizeRequests().anyRequest().authenticated().and().csrf().disable();
        }
    
        @Override
        public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/v2/api-docs", "/configuration/**", "/configuration/ui/**", "/swagger-resources/**",
                "/configuration/security/**", "/swagger-ui.html", "/webjars/**", "/health", "/csrf");
    
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题