Is there any way to set default registration for openid connect when you have multiple registration/provider? There is one way to achieve this in spring boot (https://stackoverflow.com/a/60675436)
This is exactly what i want, but could'nt find proper way in webflux security.
For example, i can set default for webclient like this (oauth.setDefaultClientRegistrationId("webclient"););
@Bean
public WebClient oauth2SupportedWebClient() {
ServerOAuth2AuthorizedClientExchangeFilterFunction oauth =
new ServerOAuth2AuthorizedClientExchangeFilterFunction(
clientRegistrations,
authorizedClients);
oauth.setDefaultClientRegistrationId("webclient");
return WebClient.builder()
.filter(oauth)
.build();
}
spring
security:
oauth2:
client:
registration:
login-client:
provider: uaa
...
webclient:
provider: m2m
...
provider:
uaa:
...
m2m:
...
Comment From: jgrandja
Thanks for getting in touch @dgempiuc.
Questions are better suited to Stack Overflow. We prefer to use GitHub issues only for bugs and enhancements.
Either way, try this it should work:
@Bean
SecurityWebFilterChain configure(ServerHttpSecurity http) {
http
.authorizeExchange((exchanges) ->
exchanges
.anyExchange().authenticated()
)
.oauth2Login(withDefaults())
.exceptionHandling()
.authenticationEntryPoint(new RedirectServerAuthenticationEntryPoint("/oauth2/authorization/github"));
return http.build();
}