commit
453ca01338
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.autoconfigure.security.oauth2.client;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -219,6 +220,11 @@ public class OAuth2ClientProperties {
|
|||
*/
|
||||
private String issuerUri;
|
||||
|
||||
/**
|
||||
* Additional metadata describing the provider's configuration.
|
||||
*/
|
||||
private Map<String, Object> configurationMetadata = new LinkedHashMap<>();
|
||||
|
||||
public String getAuthorizationUri() {
|
||||
return this.authorizationUri;
|
||||
}
|
||||
|
@ -275,6 +281,10 @@ public class OAuth2ClientProperties {
|
|||
this.issuerUri = issuerUri;
|
||||
}
|
||||
|
||||
public Map<String, Object> getConfigurationMetadata() {
|
||||
return this.configurationMetadata;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ public final class OAuth2ClientPropertiesRegistrationAdapter {
|
|||
.to(builder::userInfoAuthenticationMethod);
|
||||
map.from(provider::getJwkSetUri).to(builder::jwkSetUri);
|
||||
map.from(provider::getUserNameAttribute).to(builder::userNameAttributeName);
|
||||
map.from(provider::getConfigurationMetadata).to(builder::providerConfigurationMetadata);
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
@ -238,6 +238,20 @@ class OAuth2ClientPropertiesRegistrationAdapterTests {
|
|||
testIssuerConfiguration(login, "okta", 2, 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void configurationMetadataFromProviderIsAdapted() {
|
||||
Provider provider = createProvider();
|
||||
provider.getConfigurationMetadata().put("end_session_endpoint", "https://myendsessionendpoint");
|
||||
OAuth2ClientProperties.Registration registration = createRegistration("my-oauth-provider");
|
||||
OAuth2ClientProperties properties = new OAuth2ClientProperties();
|
||||
properties.getRegistration().put("registration", registration);
|
||||
properties.getProvider().put("my-oauth-provider", provider);
|
||||
Map<String, ClientRegistration> registrations = OAuth2ClientPropertiesRegistrationAdapter
|
||||
.getClientRegistrations(properties);
|
||||
assertThat(registrations.get("registration").getProviderDetails().getConfigurationMetadata()
|
||||
.get("end_session_endpoint")).isEqualTo("https://myendsessionendpoint");
|
||||
}
|
||||
|
||||
@Test
|
||||
void oidcProviderConfigurationWithCustomConfigurationOverridesProviderDefaults() throws Exception {
|
||||
this.server = new MockWebServer();
|
||||
|
|
|
@ -3376,6 +3376,7 @@ You can register multiple OAuth2 clients and providers under the `spring.securit
|
|||
spring.security.oauth2.client.provider.my-oauth-provider.user-info-authentication-method=header
|
||||
spring.security.oauth2.client.provider.my-oauth-provider.jwk-set-uri=https://my-auth-server/token_keys
|
||||
spring.security.oauth2.client.provider.my-oauth-provider.user-name-attribute=name
|
||||
spring.security.oauth2.client.provider.my-oauth-provider.configuration-metadata.end_session_endpoint=https://my-end-session-endpoint
|
||||
----
|
||||
|
||||
For OpenID Connect providers that support https://openid.net/specs/openid-connect-discovery-1_0.html[OpenID Connect discovery], the configuration can be further simplified.
|
||||
|
|
Loading…
Reference in New Issue