org.springframework.security.oauth2.client.ReactiveOAuth2AuthorizedClientService Java Examples
The following examples show how to use
org.springframework.security.oauth2.client.ReactiveOAuth2AuthorizedClientService.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestApplication.java From spring-credhub with Apache License 2.0 | 5 votes |
@Bean AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager reactiveClientManager( ReactiveClientRegistrationRepository clientRegistrationRepository, ReactiveOAuth2AuthorizedClientService authorizedClientService) { AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager clientManager = new AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager( clientRegistrationRepository, authorizedClientService); clientManager.setAuthorizedClientProvider(new ClientCredentialsReactiveOAuth2AuthorizedClientProvider()); return clientManager; }
Example #2
Source File: CredHubReactiveSecurityConfiguration.java From spring-credhub with Apache License 2.0 | 5 votes |
@Bean public AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager reactiveClientManager( ReactiveClientRegistrationRepository clientRegistrationRepository, ReactiveOAuth2AuthorizedClientService authorizedClientService) { AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager clientManager = new AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager( clientRegistrationRepository, authorizedClientService); clientManager.setAuthorizedClientProvider(new ClientCredentialsReactiveOAuth2AuthorizedClientProvider()); return clientManager; }
Example #3
Source File: CredHubTemplateAutoConfigurationTests.java From spring-credhub with Apache License 2.0 | 5 votes |
@Bean AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager reactiveClientManager( OAuth2ClientProperties properties) { List<ClientRegistration> registrations = new ArrayList<>( OAuth2ClientPropertiesRegistrationAdapter.getClientRegistrations(properties).values()); ReactiveClientRegistrationRepository clientRegistrationRepository = new InMemoryReactiveClientRegistrationRepository( registrations); ReactiveOAuth2AuthorizedClientService authorizedClientService = new InMemoryReactiveOAuth2AuthorizedClientService( clientRegistrationRepository); return new AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager(clientRegistrationRepository, authorizedClientService); }
Example #4
Source File: OAuth2SecurityConfigUtils.java From syncope with Apache License 2.0 | 5 votes |
public static void forLogin( final ServerHttpSecurity http, final AMType amType, final ApplicationContext ctx) { ReactiveClientRegistrationRepository clientRegistrationRepository = ctx.getBean(ReactiveClientRegistrationRepository.class); ReactiveOAuth2AuthorizedClientService authorizedClientService = new InMemoryReactiveOAuth2AuthorizedClientService(clientRegistrationRepository); ServerOAuth2AuthorizedClientRepository authorizedClientRepository = new AuthenticatedPrincipalServerOAuth2AuthorizedClientRepository(authorizedClientService); OAuth2AuthorizationRequestRedirectWebFilter authRequestRedirectFilter = new OAuth2AuthorizationRequestRedirectWebFilter(clientRegistrationRepository); AuthenticationWebFilter authenticationFilter = new OAuth2LoginAuthenticationWebFilter(authenticationManager(amType), authorizedClientRepository); authenticationFilter.setRequiresAuthenticationMatcher( new PathPatternParserServerWebExchangeMatcher("/login/oauth2/code/{registrationId}")); authenticationFilter.setServerAuthenticationConverter( new ServerOAuth2AuthorizationCodeAuthenticationTokenConverter(clientRegistrationRepository)); authenticationFilter.setAuthenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler()); authenticationFilter.setAuthenticationFailureHandler((exchange, ex) -> Mono.error(ex)); authenticationFilter.setSecurityContextRepository(new WebSessionServerSecurityContextRepository()); MediaTypeServerWebExchangeMatcher htmlMatcher = new MediaTypeServerWebExchangeMatcher(MediaType.TEXT_HTML); htmlMatcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL)); ServerAuthenticationEntryPoint entrypoint = new RedirectServerAuthenticationEntryPoint("/oauth2/authorization/" + amType.name()); http.exceptionHandling().authenticationEntryPoint(new DelegateEntry(htmlMatcher, entrypoint).getEntryPoint()); http.addFilterAt(authRequestRedirectFilter, SecurityWebFiltersOrder.HTTP_BASIC); http.addFilterAt(authenticationFilter, SecurityWebFiltersOrder.AUTHENTICATION); }
Example #5
Source File: ProxyConfig.java From spring-security-samples with MIT License | 4 votes |
public ProxyConfig(final ReactiveOAuth2AuthorizedClientService authorizedClientService, final GatewayConfig config) { this.authorizedClientService = authorizedClientService; this.config = config; }