Skip to content

How-to: Customize client metadata during dynamic client registration #1044

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

Closed
jgrandja opened this issue Jan 16, 2023 · 3 comments
Closed

How-to: Customize client metadata during dynamic client registration #1044

jgrandja opened this issue Jan 16, 2023 · 3 comments
Assignees
Labels
status: duplicate A duplicate of another issue type: documentation A documentation update
Milestone

Comments

@jgrandja
Copy link
Collaborator

jgrandja commented Jan 16, 2023

We should provide a guide that demonstrates how to customize the client metadata in OidcClientRegistration when it's provided to the OpenID Connect 1.0 Dynamic Client Registration Endpoint OidcClientRegistrationAuthenticationProvider.

Related gh-647

@jgrandja jgrandja added the type: enhancement A general enhancement label Jan 16, 2023
@jgrandja
Copy link
Collaborator Author

jgrandja commented Jan 16, 2023

The extension point for customizing client metadata before it's saved to RegisteredClientRepository is OidcClientRegistrationAuthenticationProvider.setRegisteredClientConverter().

Here is a sample configuration:

@Bean
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception {
	OAuth2AuthorizationServerConfigurer authorizationServerConfigurer =
			new OAuth2AuthorizationServerConfigurer();
	authorizationServerConfigurer
		.oidc(oidc ->
			oidc
				.clientRegistrationEndpoint(clientRegistration ->
					clientRegistration
						.authenticationProviders(configureRegisteredClientConverter())
				)
			);

	...

}

private Consumer<List<AuthenticationProvider>> configureRegisteredClientConverter() {
	return (authenticationProviders) ->
		authenticationProviders.forEach(authenticationProvider -> {
			if (authenticationProvider instanceof OidcClientRegistrationAuthenticationProvider) {
				OidcClientRegistrationAuthenticationProvider clientRegistrationAuthenticationProvider =
						(OidcClientRegistrationAuthenticationProvider) authenticationProvider;
				clientRegistrationAuthenticationProvider.setRegisteredClientConverter(
						new CustomRegisteredClientConverter());
			}
		});
}

private static final class CustomRegisteredClientConverter implements Converter<OidcClientRegistration, RegisteredClient> {

	@Override
	public RegisteredClient convert(OidcClientRegistration clientRegistration) {
		// TODO Implement conversion from OidcClientRegistration to RegisteredClient
		// See default implementation OidcClientRegistrationAuthenticationProvider.OidcClientRegistrationRegisteredClientConverter
	}

}

@ddubson
Copy link
Contributor

ddubson commented Sep 20, 2023

@jgrandja can I be assigned this issue?

Should the contents of this how-to be appended to the existing "Register a client dynamically" guide? or should it be a follow-up standalone how-to guide?

@jgrandja
Copy link
Collaborator Author

@ddubson

Should the contents of this how-to be appended to the existing "Register a client dynamically" guide?

Yes. Please add it to the existing guide.

@jgrandja jgrandja added this to the 1.2.0-RC1 milestone Sep 20, 2023
ddubson added a commit to ddubson/spring-authorization-server that referenced this issue Sep 28, 2023
ddubson added a commit to ddubson/spring-authorization-server that referenced this issue Sep 28, 2023
ddubson added a commit to ddubson/spring-authorization-server that referenced this issue Sep 28, 2023
ddubson added a commit to ddubson/spring-authorization-server that referenced this issue Sep 28, 2023
ddubson added a commit to ddubson/spring-authorization-server that referenced this issue Sep 28, 2023
ddubson added a commit to ddubson/spring-authorization-server that referenced this issue Sep 29, 2023
ddubson added a commit to ddubson/spring-authorization-server that referenced this issue Sep 29, 2023
@jgrandja jgrandja modified the milestones: 1.2.0-RC1, 1.2.0 Oct 16, 2023
ddubson pushed a commit to ddubson/spring-authorization-server that referenced this issue Nov 9, 2023
@jgrandja jgrandja added the status: duplicate A duplicate of another issue label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue type: documentation A documentation update
Projects
None yet
2 participants