Merge pull request #10207 from eugenp/BAEL-3714

add missing bean
This commit is contained in:
Loredana Crusoveanu 2020-10-26 16:33:47 +02:00 committed by GitHub
commit dc6004266b
1 changed files with 9 additions and 3 deletions

View File

@ -12,6 +12,8 @@ import org.springframework.core.env.Environment;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.oauth2.client.CommonOAuth2Provider;
import org.springframework.security.oauth2.client.InMemoryOAuth2AuthorizedClientService;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
import org.springframework.security.oauth2.client.endpoint.DefaultAuthorizationCodeTokenResponseClient;
import org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient;
import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest;
@ -46,7 +48,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.defaultSuccessUrl("/loginSuccess")
.failureUrl("/loginFailure");
}
@Bean
public AuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository() {
return new HttpSessionOAuth2AuthorizationRequestRepository();
@ -58,11 +60,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
return accessTokenResponseClient;
}
// additional configuration for non-Spring Boot projects
private static List<String> clients = Arrays.asList("google", "facebook");
//@Bean
// @Bean
public ClientRegistrationRepository clientRegistrationRepository() {
List<ClientRegistration> registrations = clients.stream()
.map(c -> getRegistration(c))
@ -72,6 +73,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
return new InMemoryClientRegistrationRepository(registrations);
}
// @Bean
public OAuth2AuthorizedClientService authorizedClientService() {
return new InMemoryOAuth2AuthorizedClientService(clientRegistrationRepository());
}
private static String CLIENT_PROPERTY_KEY = "spring.security.oauth2.client.registration.";
@Autowired