/** * Configures OAuth 2.0 Client support. * * @since 5.1 * @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-1.1">OAuth 2.0 Authorization Framework</a> * @return the {@link OAuth2ClientConfigurer} for further customizations * @throws Exception */ public OAuth2ClientConfigurer<HttpSecurity> oauth2Client() throws Exception { OAuth2ClientConfigurer<HttpSecurity> configurer = getOrApply(new OAuth2ClientConfigurer<>()); this.postProcess(configurer); return configurer; }
/** * Sets the service for authorized client(s). * * @param authorizedClientService the authorized client service * @return the {@link OAuth2ClientConfigurer} for further configuration */ public OAuth2ClientConfigurer<B> authorizedClientService(OAuth2AuthorizedClientService authorizedClientService) { Assert.notNull(authorizedClientService, "authorizedClientService cannot be null"); this.authorizedClientRepository(new AuthenticatedPrincipalOAuth2AuthorizedClientRepository(authorizedClientService)); return this; }
@Override public void configure(B builder) throws Exception { this.authorizationCodeGrantConfigurer.configure(builder); } }
/** * Sets the repository of client registrations. * * @param clientRegistrationRepository the repository of client registrations * @return the {@link OAuth2ClientConfigurer} for further configuration */ public OAuth2ClientConfigurer<B> clientRegistrationRepository(ClientRegistrationRepository clientRegistrationRepository) { Assert.notNull(clientRegistrationRepository, "clientRegistrationRepository cannot be null"); this.getBuilder().setSharedObject(ClientRegistrationRepository.class, clientRegistrationRepository); return this; }
@Override public void init(B builder) throws Exception { this.authorizationCodeGrantConfigurer.init(builder); }
@Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().anyRequest().authenticated() .and().oauth2Client() .and().oauth2Login(); } }
@Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .anyRequest().authenticated() .and() .requestCache() .requestCache(requestCache) .and() .oauth2Client() .authorizationCodeGrant() .authorizationRequestResolver(authorizationRequestResolver) .accessTokenResponseClient(accessTokenResponseClient); }
/** * Sets the repository for authorized client(s). * * @param authorizedClientRepository the authorized client repository * @return the {@link OAuth2ClientConfigurer} for further configuration */ public OAuth2ClientConfigurer<B> authorizedClientRepository(OAuth2AuthorizedClientRepository authorizedClientRepository) { Assert.notNull(authorizedClientRepository, "authorizedClientRepository cannot be null"); this.getBuilder().setSharedObject(OAuth2AuthorizedClientRepository.class, authorizedClientRepository); return this; }
@Override public void init(B builder) throws Exception { this.authorizationCodeGrantConfigurer.init(builder); }
@Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers(HttpMethod.GET,"/okta-custom-login", "/css/okta.css").permitAll() .anyRequest().authenticated() .and().oauth2Client() .and().oauth2Login(); } }
/** * Sets the repository of client registrations. * * @param clientRegistrationRepository the repository of client registrations * @return the {@link OAuth2ClientConfigurer} for further configuration */ public OAuth2ClientConfigurer<B> clientRegistrationRepository(ClientRegistrationRepository clientRegistrationRepository) { Assert.notNull(clientRegistrationRepository, "clientRegistrationRepository cannot be null"); this.getBuilder().setSharedObject(ClientRegistrationRepository.class, clientRegistrationRepository); return this; }
@Override public void configure(B builder) throws Exception { this.authorizationCodeGrantConfigurer.configure(builder); } }
@Override public void init(B builder) throws Exception { this.authorizationCodeGrantConfigurer.init(builder); }
/** * Sets the service for authorized client(s). * * @param authorizedClientService the authorized client service * @return the {@link OAuth2ClientConfigurer} for further configuration */ public OAuth2ClientConfigurer<B> authorizedClientService(OAuth2AuthorizedClientService authorizedClientService) { Assert.notNull(authorizedClientService, "authorizedClientService cannot be null"); this.authorizedClientRepository(new AuthenticatedPrincipalOAuth2AuthorizedClientRepository(authorizedClientService)); return this; }
/** * Configures OAuth 2.0 Client support. * * @since 5.1 * @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-1.1">OAuth 2.0 Authorization Framework</a> * @return the {@link OAuth2ClientConfigurer} for further customizations * @throws Exception */ public OAuth2ClientConfigurer<HttpSecurity> oauth2Client() throws Exception { OAuth2ClientConfigurer<HttpSecurity> configurer = getOrApply(new OAuth2ClientConfigurer<>()); this.postProcess(configurer); return configurer; }
@Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().anyRequest().authenticated() .and().oauth2Client() .and().oauth2Login(); } }
/** * Sets the repository for authorized client(s). * * @param authorizedClientRepository the authorized client repository * @return the {@link OAuth2ClientConfigurer} for further configuration */ public OAuth2ClientConfigurer<B> authorizedClientRepository(OAuth2AuthorizedClientRepository authorizedClientRepository) { Assert.notNull(authorizedClientRepository, "authorizedClientRepository cannot be null"); this.getBuilder().setSharedObject(OAuth2AuthorizedClientRepository.class, authorizedClientRepository); return this; }
@Override public void configure(B builder) throws Exception { this.authorizationCodeGrantConfigurer.configure(builder); } }
/** * Sets the service for authorized client(s). * * @param authorizedClientService the authorized client service * @return the {@link OAuth2ClientConfigurer} for further configuration */ public OAuth2ClientConfigurer<B> authorizedClientService(OAuth2AuthorizedClientService authorizedClientService) { Assert.notNull(authorizedClientService, "authorizedClientService cannot be null"); this.authorizedClientRepository(new AuthenticatedPrincipalOAuth2AuthorizedClientRepository(authorizedClientService)); return this; }
/** * Configures OAuth 2.0 Client support. * * @since 5.1 * @see <a target="_blank" href="https://tools.ietf.org/html/rfc6749#section-1.1">OAuth 2.0 Authorization Framework</a> * @return the {@link OAuth2ClientConfigurer} for further customizations * @throws Exception */ public OAuth2ClientConfigurer<HttpSecurity> oauth2Client() throws Exception { OAuth2ClientConfigurer<HttpSecurity> configurer = getOrApply(new OAuth2ClientConfigurer<>()); this.postProcess(configurer); return configurer; }