Polish Authorization Server auto-configuration
parent
94b091d311
commit
f06536f642
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2023 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.security.oauth2.server;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.PropertyMapper;
|
|
||||||
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapter class to convert {@link OAuth2AuthorizationServerProperties.Endpoint} to a
|
|
||||||
* {@link AuthorizationServerSettings}.
|
|
||||||
*
|
|
||||||
* @author Steve Riesenberg
|
|
||||||
* @since 3.1.0
|
|
||||||
*/
|
|
||||||
public final class OAuth2AuthorizationServerPropertiesSettingsAdapter {
|
|
||||||
|
|
||||||
private OAuth2AuthorizationServerPropertiesSettingsAdapter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AuthorizationServerSettings getAuthorizationServerSettings(
|
|
||||||
OAuth2AuthorizationServerProperties properties) {
|
|
||||||
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
|
||||||
OAuth2AuthorizationServerProperties.Endpoint endpoint = properties.getEndpoint();
|
|
||||||
OAuth2AuthorizationServerProperties.OidcEndpoint oidc = endpoint.getOidc();
|
|
||||||
AuthorizationServerSettings.Builder builder = AuthorizationServerSettings.builder();
|
|
||||||
map.from(properties::getIssuer).to(builder::issuer);
|
|
||||||
map.from(endpoint::getAuthorizationUri).to(builder::authorizationEndpoint);
|
|
||||||
map.from(endpoint::getTokenUri).to(builder::tokenEndpoint);
|
|
||||||
map.from(endpoint::getJwkSetUri).to(builder::jwkSetEndpoint);
|
|
||||||
map.from(endpoint::getTokenRevocationUri).to(builder::tokenRevocationEndpoint);
|
|
||||||
map.from(endpoint::getTokenIntrospectionUri).to(builder::tokenIntrospectionEndpoint);
|
|
||||||
map.from(oidc::getLogoutUri).to(builder::oidcLogoutEndpoint);
|
|
||||||
map.from(oidc::getClientRegistrationUri).to(builder::oidcClientRegistrationEndpoint);
|
|
||||||
map.from(oidc::getUserInfoUri).to(builder::oidcUserInfoEndpoint);
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2023 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Support for Spring Security's OAuth2 authorization server.
|
|
||||||
*/
|
|
||||||
package org.springframework.boot.autoconfigure.security.oauth2.server;
|
|
2
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/OAuth2AuthorizationServerProperties.java → spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerProperties.java
2
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/OAuth2AuthorizationServerProperties.java → spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerProperties.java
52
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/OAuth2AuthorizationServerPropertiesRegistrationAdapter.java → spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerPropertiesMapper.java
52
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/OAuth2AuthorizationServerPropertiesRegistrationAdapter.java → spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerPropertiesMapper.java
5
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/RegisteredClientsConfiguredCondition.java → spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/RegisteredClientsConfiguredCondition.java
5
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/RegisteredClientsConfiguredCondition.java → spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/RegisteredClientsConfiguredCondition.java
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2023 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.security.oauth2.server;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link OAuth2AuthorizationServerPropertiesRegistrationAdapter}.
|
|
||||||
*
|
|
||||||
* @author Steve Riesenberg
|
|
||||||
*/
|
|
||||||
class OAuth2AuthorizationServerPropertiesSettingsAdapterTests {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getAuthorizationServerSettingsWhenValidParametersShouldAdapt() {
|
|
||||||
OAuth2AuthorizationServerProperties properties = createAuthorizationServerProperties();
|
|
||||||
AuthorizationServerSettings settings = OAuth2AuthorizationServerPropertiesSettingsAdapter
|
|
||||||
.getAuthorizationServerSettings(properties);
|
|
||||||
assertThat(settings.getIssuer()).isEqualTo("https://example.com");
|
|
||||||
assertThat(settings.getAuthorizationEndpoint()).isEqualTo("/authorize");
|
|
||||||
assertThat(settings.getTokenEndpoint()).isEqualTo("/token");
|
|
||||||
assertThat(settings.getJwkSetEndpoint()).isEqualTo("/jwks");
|
|
||||||
assertThat(settings.getTokenRevocationEndpoint()).isEqualTo("/revoke");
|
|
||||||
assertThat(settings.getTokenIntrospectionEndpoint()).isEqualTo("/introspect");
|
|
||||||
assertThat(settings.getOidcLogoutEndpoint()).isEqualTo("/logout");
|
|
||||||
assertThat(settings.getOidcClientRegistrationEndpoint()).isEqualTo("/register");
|
|
||||||
assertThat(settings.getOidcUserInfoEndpoint()).isEqualTo("/user");
|
|
||||||
}
|
|
||||||
|
|
||||||
private OAuth2AuthorizationServerProperties createAuthorizationServerProperties() {
|
|
||||||
OAuth2AuthorizationServerProperties properties = new OAuth2AuthorizationServerProperties();
|
|
||||||
properties.setIssuer("https://example.com");
|
|
||||||
OAuth2AuthorizationServerProperties.Endpoint endpoints = properties.getEndpoint();
|
|
||||||
endpoints.setAuthorizationUri("/authorize");
|
|
||||||
endpoints.setTokenUri("/token");
|
|
||||||
endpoints.setJwkSetUri("/jwks");
|
|
||||||
endpoints.setTokenRevocationUri("/revoke");
|
|
||||||
endpoints.setTokenIntrospectionUri("/introspect");
|
|
||||||
OAuth2AuthorizationServerProperties.OidcEndpoint oidc = endpoints.getOidc();
|
|
||||||
oidc.setLogoutUri("/logout");
|
|
||||||
oidc.setClientRegistrationUri("/register");
|
|
||||||
oidc.setUserInfoUri("/user");
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
43
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/server/OAuth2AuthorizationServerPropertiesRegistrationAdapterTests.java → spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerPropertiesMapperTests.java
43
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/server/OAuth2AuthorizationServerPropertiesRegistrationAdapterTests.java → spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerPropertiesMapperTests.java
2
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/server/OAuth2AuthorizationServerPropertiesTests.java → spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerPropertiesTests.java
2
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/server/OAuth2AuthorizationServerPropertiesTests.java → spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/server/servlet/OAuth2AuthorizationServerPropertiesTests.java
Loading…
Reference in New Issue