Skip to content

Please add a way to add prefix or custom URL mapping for OidcProviderConfigurationEndpointFilter /.well-known/openid-configuration/ #1409

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
FoxNeo opened this issue Oct 17, 2023 · 1 comment
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@FoxNeo
Copy link

FoxNeo commented Oct 17, 2023

Expected Behavior
Hello, I would like to add the following Feature.
I have a web application that has the Server Context URL https://app-server.com/app-context-name/authenticator

The problem is that the OidcProviderConfigurationEndpointFilter class is final and does not allow modifying the filter url endpoint value. In this example the Metadata Endpoint would be
https://app-server.com/app-context-name/.well-known/openid-configuration/
instead of https://app-server.com/app-context-name/authenticator/.well-known/openid-configuration/
after the sub endpoint /authenticator/

It would be possible to modify the ServerSettings class to be able to override the endpoint like in UserInfo, IdToken for example:

OidcProviderConfigurationEndpointFilter.java

		OidcProviderConfiguration.Builder providerConfiguration = OidcProviderConfiguration.builder()
				.metadataPrefix(authorizationServerSettings.getPrefix())
				.issuer(issuer)
				.authorizationEndpoint(asUrl(issuer, authorizationServerSettings.getAuthorizationEndpoint()))
				.tokenEndpoint(asUrl(issuer, authorizationServerSettings.getTokenEndpoint()))`

AuthorizationServerSettings.java

            public static Builder builderWithPrefix(@NonNull String prefix) {
		return new Builder()
				.metadataPrefix(prefix + "/.well-known/openid-configuration")
				.authorizationEndpoint(prefix + "/oauth2/authorize")
				.tokenEndpoint(prefix +"/oauth2/token")
				.jwkSetEndpoint(prefix +"/oauth2/jwks")
				.tokenRevocationEndpoint(prefix +"/oauth2/revoke")
				.tokenIntrospectionEndpoint(prefix +"/oauth2/introspect")
				.oidcClientRegistrationEndpoint(prefix +"/connect/register")
				.oidcUserInfoEndpoint(prefix + "/userinfo");
	}

Current Behavior
it doesn't work, but it could

       public final class OidcProviderConfigurationEndpointFilter extends OncePerRequestFilter {
	/**
	 * The default endpoint {@code URI} for OpenID Provider Configuration requests.
	 */
	private static final String DEFAULT_OIDC_PROVIDER_CONFIGURATION_ENDPOINT_URI = "/.well-known/openid-configuration";

	private final RequestMatcher requestMatcher = new AntPathRequestMatcher(
			PREFIX + DEFAULT_OIDC_PROVIDER_CONFIGURATION_ENDPOINT_URI,
			HttpMethod.GET.name());
	private final OidcProviderConfiguration

Context
You can override the other Endpoints from the configuration: https://docs.spring.io/spring-authorization-server/docs/current/reference/html/configuration-model.html#configuring-authorization-server-settings but the Metadata ( OIDC 1.0 DiscoveyrEndpoint) (/.well-known/openid-configuration) it's not possible.

@FoxNeo FoxNeo added the type: enhancement A general enhancement label Oct 17, 2023
@FoxNeo FoxNeo changed the title Please add a way to add prefix or Custom url mapping for OidcProviderConfigurationEndpointFilter /.well-known/openid-configuration/ Please add a way to add prefix or custom URL mapping for OidcProviderConfigurationEndpointFilter /.well-known/openid-configuration/ Oct 17, 2023
@jgrandja
Copy link
Collaborator

@FoxNeo We already have an open and related issue. Please add your comments to gh-1342 and I'll close this as a duplicate.

@jgrandja jgrandja self-assigned this Oct 20, 2023
@jgrandja jgrandja added status: duplicate A duplicate of another issue and removed type: enhancement A general enhancement labels Oct 20, 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
Projects
None yet
Development

No branches or pull requests

2 participants