Spring security : cannot access permitAll endpoints

Viewed 74

I have this WebSecurityConfigurerAdapter configuration :

@Throws(Exception::class)
override fun configure(http: HttpSecurity) {
    http
            .authorizeRequests()
            .antMatchers("/favicon.ico", "/auth/**", "/oauth2/**").permitAll()
            .anyRequest().authenticated()
            .and()
            .cors()
            .and()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
            .csrf().disable()
            .formLogin().disable()
            .httpBasic().disable()
            .oauth2Login()
            .authorizationEndpoint().baseUri("/oauth2/authorize")
            .authorizationRequestRepository(cookieAuthorizationRequestRepository())
            .and()
            .redirectionEndpoint()
            .baseUri("/oauth2/callback/*")
            .and()
            .userInfoEndpoint()
            .userService(customOAuth2UserService)
            .and()
            .successHandler(oAuth2AuthenticationSuccessHandler)
            .failureHandler(oAuth2AuthenticationFailureHandler)
}

And I don't understand why I got a 401 when I try to access the /favicon.ico or /oauth2/** endpoints.

What am I missing ?

0 Answers
Related