From 5cfe8dbee950dbf3a8de3ece2f6f3363f13d904a Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 7 Aug 2018 17:52:47 +0200 Subject: [PATCH] Polish --- .../resource/OAuth2ResourceServerProperties.java | 15 ++++----------- .../asciidoc/appendix-application-properties.adoc | 2 +- .../src/main/asciidoc/spring-boot-features.adoc | 12 ++++++------ spring-boot-samples/README.adoc | 3 +++ 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java index 3758be17ed..bf02b208f5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java @@ -21,38 +21,31 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * OAuth 2.0 resource server properties. * * @author Madhura Bhave + * @since 2.1.0 */ @ConfigurationProperties(prefix = "spring.security.oauth2.resource") public class OAuth2ResourceServerProperties { - private Jwt jwt = new Jwt(); + private final Jwt jwt = new Jwt(); public Jwt getJwt() { return this.jwt; } - public void setJwt(Jwt jwt) { - this.jwt = jwt; - } - public static class Jwt { - private Jwk jwk = new Jwk(); + private final Jwk jwk = new Jwk(); public Jwk getJwk() { return this.jwk; } - public void setJwk(Jwk jwk) { - this.jwk = jwk; - } - } public static class Jwk { /** - * The URI to get verification keys to verify the JWT token. + * JSON Web Key URI to use to verify the JWT token. */ private String setUri; diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 22c461b96d..6f14d951f2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -530,7 +530,7 @@ content into your application. Rather, pick only the properties that you need. spring.security.oauth2.client.registration.*= # OAuth client registrations. # SECURITY OAUTH2 RESOURCE SERVER ({sc-spring-boot-autoconfigure}/security/oauth2/resource/OAuth2ResourceServerProperties.{sc-ext}[OAuth2ResourceServerProperties]) - spring.security.oauth2.resource.jwt.jwk.set-uri.*= # JWK Set URI + spring.security.oauth2.resource.jwt.jwk.set-uri= # JSON Web Key URI to use to verify the JWT token. # ---------------------------------------- # DATA PROPERTIES diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index e0284ba337..130cedd55e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -3277,18 +3277,18 @@ Provider can be configured with the `issuer-uri`: [[boot-features-security-oauth2-server]] ==== Resource Server -If you have `spring-security-oauth2-resource-server` on your classpath, you can take advantage of -some auto-configuration to make it easy to set up an OAuth2 Resource Server. This configuration -makes use of the properties under `OAuth2ResourceServerProperties`. - -For the OAuth2 Resource Server auto-configuration to kick in, you can -provide a bean of type `JwtDecoder` yourself or configure a JWK Set URI as follows: +If you have `spring-security-oauth2-resource-server` on your classpath, Spring Boot can +set up an OAuth2 Resource Server as long as a JWK Set URI is specified, as shown in the +following example: [source,properties,indent=0] ---- spring.security.oauth2.resource.jwt.jwk.set-uri=https://example.com/oauth2/default/v1/keys ---- +Alternatively, you can define your own `JwtDecoder` bean. + + ==== Authorization Server Currently, Spring Security does not provide support for implementing an OAuth 2.0 diff --git a/spring-boot-samples/README.adoc b/spring-boot-samples/README.adoc index 7e71a3c53f..8a7378508c 100644 --- a/spring-boot-samples/README.adoc +++ b/spring-boot-samples/README.adoc @@ -134,6 +134,9 @@ The following sample applications are provided: | link:spring-boot-sample-metrics-redis[spring-boot-sample-metrics-redis] | Exports metrics to Redis +| link:spring-boot-sample-oauth2-resource-server[spring-boot-sample-oauth2-resource-server] +| Configure an OAuth2 resource server + | link:spring-boot-sample-parent-context[spring-boot-sample-parent-context] | Application that uses an `ApplicationContext` with a parent