Skip to content

Commit c4e9cdb

Browse files
author
Steve Riesenberg
committed
Add Spring Boot integrations
Issue spring-projectsgh-673
1 parent ecda4e0 commit c4e9cdb

File tree

8 files changed

+612
-1
lines changed

8 files changed

+612
-1
lines changed

docs/src/docs/asciidoc/examples/spring-authorization-server-docs-examples.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111
}
1212

1313
dependencies {
14-
implementation platform("org.springframework.boot:spring-boot-dependencies:2.6.7")
14+
implementation platform("org.springframework.boot:spring-boot-dependencies:$springBootVersion")
1515
implementation "org.springframework.boot:spring-boot-starter-web"
1616
implementation "org.springframework.boot:spring-boot-starter-thymeleaf"
1717
implementation "org.springframework.boot:spring-boot-starter-security"

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version=0.3.0-SNAPSHOT
22
org.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError
33
org.gradle.parallel=true
44
org.gradle.caching=true
5+
springBootVersion=2.6.7
56
springFrameworkVersion=5.3.19
67
springSecurityVersion=5.6.3
78
springJavaformatVersion=0.0.31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
id "io.spring.convention.spring-module"
3+
}
4+
5+
description = "Spring Boot AutoConfigure for Spring Authorization Server"
6+
7+
configurations {
8+
compileOnly {
9+
extendsFrom annotationProcessor
10+
}
11+
}
12+
13+
dependencies {
14+
management platform(project(":spring-authorization-server-dependencies"))
15+
management platform("org.springframework.boot:spring-boot-dependencies:$springBootVersion")
16+
annotationProcessor platform("org.springframework.boot:spring-boot-dependencies:$springBootVersion")
17+
18+
api "org.springframework.boot:spring-boot-autoconfigure"
19+
optional project(":spring-security-oauth2-authorization-server")
20+
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
21+
testImplementation "org.springframework.boot:spring-boot-starter-test"
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
/*
2+
* Copyright 2020-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.boot.autoconfigure.security.oauth2.server;
17+
18+
import java.time.Duration;
19+
import java.util.HashMap;
20+
import java.util.HashSet;
21+
import java.util.Map;
22+
import java.util.Set;
23+
24+
import org.springframework.boot.context.properties.ConfigurationProperties;
25+
26+
/**
27+
* OAuth 2.0 authorization server properties.
28+
*
29+
* @author Steve Riesenberg
30+
*/
31+
@ConfigurationProperties(prefix = "spring.security.oauth2.authorizationserver")
32+
public class OAuth2AuthorizationServerProperties {
33+
34+
private final Map<String, Registration> registration = new HashMap<>();
35+
36+
public Map<String, Registration> getRegistration() {
37+
return this.registration;
38+
}
39+
40+
/**
41+
* A registered client.
42+
*/
43+
public static class Registration {
44+
45+
/**
46+
* Client ID for the registration.
47+
*/
48+
private String clientId;
49+
50+
/**
51+
* Client secret of the registration. May be left blank for a public client.
52+
*/
53+
private String clientSecret;
54+
55+
/**
56+
* Client authentication method(s) that the client may use.
57+
*/
58+
private Set<String> clientAuthenticationMethod = new HashSet<>();
59+
60+
/**
61+
* Authorization grant type(s) that the client may use.
62+
*/
63+
private Set<String> authorizationGrantType = new HashSet<>();
64+
65+
/**
66+
* Redirect URI(s) that the client may use in redirect-based flows.
67+
*/
68+
private Set<String> redirectUri = new HashSet<>();
69+
70+
/**
71+
* Scope(s) that the client may use.
72+
*/
73+
private Set<String> scope = new HashSet<>();
74+
75+
/**
76+
* Client configuration settings.
77+
*/
78+
private ClientSettings clientSettings = new ClientSettings();
79+
80+
/**
81+
* Token configuration settings.
82+
*/
83+
private TokenSettings tokenSettings = new TokenSettings();
84+
85+
public String getClientId() {
86+
return this.clientId;
87+
}
88+
89+
public void setClientId(String clientId) {
90+
this.clientId = clientId;
91+
}
92+
93+
public String getClientSecret() {
94+
return this.clientSecret;
95+
}
96+
97+
public void setClientSecret(String clientSecret) {
98+
this.clientSecret = clientSecret;
99+
}
100+
101+
public Set<String> getClientAuthenticationMethod() {
102+
return this.clientAuthenticationMethod;
103+
}
104+
105+
public void setClientAuthenticationMethod(Set<String> clientAuthenticationMethod) {
106+
this.clientAuthenticationMethod = clientAuthenticationMethod;
107+
}
108+
109+
public Set<String> getAuthorizationGrantType() {
110+
return this.authorizationGrantType;
111+
}
112+
113+
public void setAuthorizationGrantType(Set<String> authorizationGrantType) {
114+
this.authorizationGrantType = authorizationGrantType;
115+
}
116+
117+
public Set<String> getRedirectUri() {
118+
return this.redirectUri;
119+
}
120+
121+
public void setRedirectUri(Set<String> redirectUri) {
122+
this.redirectUri = redirectUri;
123+
}
124+
125+
public Set<String> getScope() {
126+
return this.scope;
127+
}
128+
129+
public void setScope(Set<String> scope) {
130+
this.scope = scope;
131+
}
132+
133+
public ClientSettings getClientSettings() {
134+
return this.clientSettings;
135+
}
136+
137+
public void setClientSettings(ClientSettings clientSettings) {
138+
this.clientSettings = clientSettings;
139+
}
140+
141+
public TokenSettings getTokenSettings() {
142+
return this.tokenSettings;
143+
}
144+
145+
public void setTokenSettings(TokenSettings tokenSettings) {
146+
this.tokenSettings = tokenSettings;
147+
}
148+
}
149+
150+
/**
151+
* Client configuration settings.
152+
*/
153+
public static class ClientSettings {
154+
155+
/**
156+
* Whether the client is required to provide a proof key challenge and verifier when performing the
157+
* Authorization Code Grant flow.
158+
*/
159+
private boolean requireProofKey;
160+
161+
/**
162+
* Whether authorization consent is required when the client requests access.
163+
*/
164+
private boolean requireAuthorizationConsent;
165+
166+
/**
167+
* The URL for the client's JSON Web Key Set.
168+
*/
169+
private String jwkSetUrl;
170+
171+
/**
172+
* The JWS algorithm that must be used for signing the JWT used to authenticate the client at the Token Endpoint
173+
* for the {@code private_key_jwt} and {@code client_secret_jwt} authentication methods.
174+
*/
175+
private String tokenEndpointAuthenticationSigningAlgorithm;
176+
177+
/**
178+
* Additional settings.
179+
*/
180+
private Map<String, Object> additionalSettings = new HashMap<>();
181+
182+
public boolean isRequireProofKey() {
183+
return this.requireProofKey;
184+
}
185+
186+
public void setRequireProofKey(boolean requireProofKey) {
187+
this.requireProofKey = requireProofKey;
188+
}
189+
190+
public boolean isRequireAuthorizationConsent() {
191+
return this.requireAuthorizationConsent;
192+
}
193+
194+
public void setRequireAuthorizationConsent(boolean requireAuthorizationConsent) {
195+
this.requireAuthorizationConsent = requireAuthorizationConsent;
196+
}
197+
198+
public String getJwkSetUrl() {
199+
return this.jwkSetUrl;
200+
}
201+
202+
public void setJwkSetUrl(String jwkSetUrl) {
203+
this.jwkSetUrl = jwkSetUrl;
204+
}
205+
206+
public String getTokenEndpointAuthenticationSigningAlgorithm() {
207+
return this.tokenEndpointAuthenticationSigningAlgorithm;
208+
}
209+
210+
public void setTokenEndpointAuthenticationSigningAlgorithm(String tokenEndpointAuthenticationSigningAlgorithm) {
211+
this.tokenEndpointAuthenticationSigningAlgorithm = tokenEndpointAuthenticationSigningAlgorithm;
212+
}
213+
214+
public Map<String, Object> getAdditionalSettings() {
215+
return this.additionalSettings;
216+
}
217+
218+
public void setAdditionalSettings(Map<String, Object> additionalSettings) {
219+
this.additionalSettings = additionalSettings;
220+
}
221+
}
222+
223+
/**
224+
* Token configuration settings.
225+
*/
226+
public static class TokenSettings {
227+
228+
/**
229+
* The time-to-live for an access token.
230+
*/
231+
private Duration accessTokenTimeToLive;
232+
233+
/**
234+
* The token format for an access token.
235+
*/
236+
private String accessTokenFormat;
237+
238+
/**
239+
* Whether refresh tokens are reused or a new refresh token is issued when returning the access token response.
240+
*/
241+
private boolean reuseRefreshTokens;
242+
243+
/**
244+
* The time-to-live for a refresh token.
245+
*/
246+
private Duration refreshTokenTimeToLive;
247+
248+
/**
249+
* The JWS algorithm for signing the ID Token.
250+
*/
251+
private String idTokenSignatureAlgorithm;
252+
253+
/**
254+
* Additional settings.
255+
*/
256+
private Map<String, Object> additionalSettings = new HashMap<>();
257+
258+
public Duration getAccessTokenTimeToLive() {
259+
return this.accessTokenTimeToLive;
260+
}
261+
262+
public void setAccessTokenTimeToLive(Duration accessTokenTimeToLive) {
263+
this.accessTokenTimeToLive = accessTokenTimeToLive;
264+
}
265+
266+
public String getAccessTokenFormat() {
267+
return this.accessTokenFormat;
268+
}
269+
270+
public void setAccessTokenFormat(String accessTokenFormat) {
271+
this.accessTokenFormat = accessTokenFormat;
272+
}
273+
274+
public boolean isReuseRefreshTokens() {
275+
return this.reuseRefreshTokens;
276+
}
277+
278+
public void setReuseRefreshTokens(boolean reuseRefreshTokens) {
279+
this.reuseRefreshTokens = reuseRefreshTokens;
280+
}
281+
282+
public Duration getRefreshTokenTimeToLive() {
283+
return this.refreshTokenTimeToLive;
284+
}
285+
286+
public void setRefreshTokenTimeToLive(Duration refreshTokenTimeToLive) {
287+
this.refreshTokenTimeToLive = refreshTokenTimeToLive;
288+
}
289+
290+
public String getIdTokenSignatureAlgorithm() {
291+
return this.idTokenSignatureAlgorithm;
292+
}
293+
294+
public void setIdTokenSignatureAlgorithm(String idTokenSignatureAlgorithm) {
295+
this.idTokenSignatureAlgorithm = idTokenSignatureAlgorithm;
296+
}
297+
298+
public Map<String, Object> getAdditionalSettings() {
299+
return this.additionalSettings;
300+
}
301+
302+
public void setAdditionalSettings(Map<String, Object> additionalSettings) {
303+
this.additionalSettings = additionalSettings;
304+
}
305+
}
306+
307+
}

0 commit comments

Comments
 (0)