Я пытаюсь настроить Spring Security для моего приложения, которое находится за google OAuth2.
Проблема в том, что я хочу внести в белый список определенные вызовы API, поступающие из Github и Bitbucket через webhooks, для которых я написалпользовательские провайдеры аутентификации. Я добавил этих провайдеров аутентификации в цепочку безопасности Spring, но, похоже, они не вызываются для этих вызовов.
Запросы для Google OAuth2 работают нормально, и я могу войти в систему. Однако все запросы, поступающие от Github и Bitbucket, приводят к 401 без попадания в провайдеры аутентификации.
Здесь действительно нужна помощь.
Заранее спасибо!
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private OAuth2UserServiceImpl oAuth2UserService;
@Autowired
private GithubIpAuthenticationProvider githubIpAuthenticationProvider;
@Autowired
private BitbucketIpAuthenticationProvider bitbucketIpAuthenticationProvider;
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/api/*/applications/*/webhooks/github")
.authenticated()
.and()
.authenticationProvider(githubIpAuthenticationProvider)
.authorizeRequests()
.antMatchers("/api/*/applications/*/webhooks/bitbucket")
.authenticated()
.and()
.authenticationProvider(bitbucketIpAuthenticationProvider)
.authorizeRequests()
.antMatchers("/api/**")
.authenticated()
.and()
.oauth2Login()
.userInfoEndpoint()
.userService(oAuth2UserService)
.and()
.and()
.csrf().disable()
.exceptionHandling()
.authenticationEntryPoint(
(a,b,c) -> {b.sendError(HttpServletResponse.SC_UNAUTHORIZED);}
)
.and()
.cors();
}
}