-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve OAuth2LoginSpec with more configuration options #5598
Comments
The first part was easy so I fixed it in a separate issue. The next pieces are going to need to wait until we get #5610 resolved |
I am writing Service with WebFlux Framework Below are Technologies i am trying to use |
Have the static routes: /oauth2/authorization/{registrationId} Been made overridable or configurable yet? |
@nickbr23 @VijaySidhu The configuration points for overriding the authorization request and authorization response base uri's is not available as of yet. Is anyone interested in submitting a PR for this? At the moment I'm think we need the following:
|
I succeeded getting it working, see following snippet:
Please note
PS: that's on spring boot version |
That would work. For just overriding the uri's, it should be as simple as providing:
So that it mirrors the servlets builder. If you're happy with just providing the uri's then feel free to assign it to me and I'll handle the PR. |
Thanks for the feedback @nickbr23
OAuth2LoginSpec.authorizationRequestBaseUri(String authorizationRequestBaseUri)
OAuth2LoginSpec.loginProcessingUrl(String loginProcessingUrl) This does not actually mirror the DSL in The preference is to use The new configuration API's we would want to introduce are as follows: OAuth2LoginSpec.authorizationRequestResolver(ServerOAuth2AuthorizationRequestResolver authorizationRequestResolver)
OAuth2LoginSpec.authenticationMatcher(ServerWebExchangeMatcher authenticationMatcher) Let me know if you're still interested in submitting a PR for this improvement. |
Sure, I'm happy to do it. If we introduce |
The PR is yours @nickbr23. Let me know if you have any other questions. Thanks for taking this on! |
PR has been created: #6462 |
@jgrandja Is there a way to customize the login page and override the behavior |
I still could'nt figure out how to customize the baseUri in the reactive stack. For the servlet stack I can customize it as follows:
|
@saurabhgour @luqmanulkhair Here is a sample configuration: @EnableWebFluxSecurity
public class SecurityConfig {
@Autowired
private ReactiveClientRegistrationRepository clientRegistrationRepository;
@Bean
SecurityWebFilterChain configure(ServerHttpSecurity http) {
http
.authorizeExchange(exchanges ->
exchanges
.anyExchange().authenticated()
)
.oauth2Login(oauth2Login ->
oauth2Login
.authorizationRequestResolver(getAuthorizationRequestResolver()));
return http.build();
}
private ServerOAuth2AuthorizationRequestResolver getAuthorizationRequestResolver() {
return new DefaultServerOAuth2AuthorizationRequestResolver(
this.clientRegistrationRepository,
new PathPatternParserServerWebExchangeMatcher(
"/auth/custom/sso/{registrationId}"));
}
} Given the above configuration, the |
@jgrandja thanks for your response, Is this code for .authoriationEndpoint().baseurl() or for .redirectionEndpoint() .baseUri(""), my problem is to handle the redirect from authorization-server after login with code, I think I need to use authenticationMatcher(), I have implemented my custom logic but it not standardized. Example: |
@luqmanulkhair The sample code provided is for For
Configure this, with whatever path you require. |
@jgrandja solution doesn't work for me. After copy/paste your Java class I have redirect loop to /auth/custom/sso/{registrationId}
|
Summary
Improve
org.springframework.security.config.web.server.ServerHttpSecurity.OAuth2LoginSpec
for more configuration options.
Actual Behavior
OAuth2LoginSpec
not available, missingpublic ServerHttpSecurity and() { return ServerHttpSecurity.this; }
Expected Behavior
allow chaining
oauthRedirectFilter
(orauthorizationRequestBaseUri
in particular)AuthenticationWebFilter.requiresAuthenticationMatcher
(orPathPatternParserServerWebExchangeMatcher
->pattern
=>requestBaseUri
in particular)Configuration
http.oauth2Login();
Version
Boot 2.1.0.SNAPSHOT
Spring Security 5.1.0.M2
The text was updated successfully, but these errors were encountered: