use of org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter in project spring-boot by spring-projects.
the class SsoSecurityConfigurer method oauth2SsoFilter.
private OAuth2ClientAuthenticationProcessingFilter oauth2SsoFilter(OAuth2SsoProperties sso) {
OAuth2RestOperations restTemplate = this.applicationContext.getBean(UserInfoRestTemplateFactory.class).getUserInfoRestTemplate();
ResourceServerTokenServices tokenServices = this.applicationContext.getBean(ResourceServerTokenServices.class);
OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(sso.getLoginPath());
filter.setRestTemplate(restTemplate);
filter.setTokenServices(tokenServices);
filter.setApplicationEventPublisher(this.applicationContext);
return filter;
}
use of org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter in project service-authorization by reportportal.
the class OAuthSecurityConfig method configure.
@Override
protected final void configure(HttpSecurity http) throws Exception {
// @formatter:off
http.antMatcher("/**").authorizeRequests().antMatchers(SSO_LOGIN_PATH + "/**", "/webjars/**", "/index.html", "/epam/**", "/info", "/health", "/api-docs/**").permitAll().anyRequest().authenticated().and().csrf().disable().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
CompositeFilter authCompositeFilter = new CompositeFilter();
List<OAuth2ClientAuthenticationProcessingFilter> additionalFilters = ImmutableList.<OAuth2ClientAuthenticationProcessingFilter>builder().addAll(getDefaultFilters(oauth2ClientContext)).addAll(getAdditionalFilters(oauth2ClientContext)).build();
/* make sure filters have correct exception handler */
additionalFilters.forEach(filter -> filter.setAuthenticationFailureHandler(OAUTH_ERROR_HANDLER));
authCompositeFilter.setFilters(additionalFilters);
// install additional OAuth Authentication filters
http.addFilterAfter(authCompositeFilter, BasicAuthenticationFilter.class);
// @formatter:on
}
use of org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter in project vorto by eclipse.
the class SecurityConfiguration method newSsoFilter.
private Filter newSsoFilter(String defaultFilterProcessesUrl, UserInfoTokenServices tokenService, AccessTokenProvider accessTokenProvider, OAuth2RestTemplate restTemplate) {
restTemplate.setAccessTokenProvider(accessTokenProvider);
OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(defaultFilterProcessesUrl);
filter.setAuthenticationSuccessHandler(successHandler);
tokenService.setRestTemplate(restTemplate);
filter.setRestTemplate(restTemplate);
filter.setTokenServices(tokenService);
return filter;
}
use of org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter in project spring-boot-quick by vector4wang.
the class WebSecurityConfig method sso.
private Filter sso() {
OAuth2ClientAuthenticationProcessingFilter githubFilter = new OAuth2ClientAuthenticationProcessingFilter("/login/github");
OAuth2RestTemplate githubTemplate = new OAuth2RestTemplate(github(), oauth2ClientContext);
githubFilter.setRestTemplate(githubTemplate);
githubFilter.setTokenServices(new UserInfoTokenServices(githubResource().getUserInfoUri(), github().getClientId()));
return githubFilter;
}
Aggregations