in streampipes-service-core/src/main/java/org/apache/streampipes/service/core/WebSecurityConfig.java [103:157]
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.cors()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.csrf().disable()
.formLogin().disable()
.httpBasic().disable()
.exceptionHandling()
.authenticationEntryPoint(new UnauthorizedRequestEntryPoint())
.and()
.authorizeHttpRequests((authz) -> {
try {
authz
.requestMatchers(UnauthenticatedInterfaces
.get()
.stream()
.map(AntPathRequestMatcher::new)
.toList()
.toArray(new AntPathRequestMatcher[0]))
.permitAll()
.anyRequest()
.authenticated();
if (env.getOAuthEnabled().getValueOrDefault()) {
LOG.info("Configuring OAuth authentication from environment variables");
authz
.and()
.oauth2Login()
.authorizationEndpoint()
.authorizationRequestRepository(cookieOAuth2AuthorizationRequestRepository())
.and()
.redirectionEndpoint()
.and()
.userInfoEndpoint()
.oidcUserService(customOidcUserService)
.userService(customOAuth2UserService)
.and()
.tokenEndpoint()
.accessTokenResponseClient(authorizationCodeTokenResponseClient())
.and()
.successHandler(oAuth2AuthenticationSuccessHandler)
.failureHandler(oAuth2AuthenticationFailureHandler);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
});
http.addFilterBefore(tokenAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
return http.build();
}