Skip to content

Commit 9b7e79f

Browse files
author
Steve Riesenberg
committed
Polish ref doc
Issue spring-projectsgh-499
1 parent 25cce19 commit 9b7e79f

10 files changed

+82
-54
lines changed

docs/spring-authorization-server-docs.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ plugins {
55
asciidoctor {
66
attributes([
77
"spring-authorization-server-version": project.version,
8+
"spring-security-reference-base-url": "https://docs.spring.io/spring-security/reference",
9+
"spring-security-api-base-url": "https://docs.spring.io/spring-security/site/docs/current/api",
810
"examples-dir": "examples",
911
"docs-java": "$sourceDir/examples/src/main/java",
1012
"chomp": "default headers packages",

docs/src/docs/asciidoc/configuration-model.adoc

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
[[configuration-model]]
22
= Configuration Model
3-
:toc: left
4-
:toclevels: 1
53

64
[[default-configuration]]
75
== Default configuration
@@ -28,7 +26,7 @@ The OAuth2 authorization server `SecurityFilterChain` `@Bean` is configured with
2826
The JWK Set endpoint is configured *only* if a `JWKSource<SecurityContext>` `@Bean` is registered.
2927

3028
[NOTE]
31-
The xref:protocol-endpoints.adoc#oidc-client-registration-endpoint[OpenID Connect 1.0 Client Registration endpoint] is disabled by default.
29+
The xref:protocol-endpoints.adoc#oidc-client-registration-endpoint[OpenID Connect 1.0 Client Registration endpoint] is disabled by default because many deployments do not require dynamic client registration.
3230

3331
The following example shows how to use `OAuth2AuthorizationServerConfiguration` to apply the minimal default configuration:
3432

@@ -108,11 +106,11 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
108106
return http.build();
109107
}
110108
----
111-
<1> `registeredClientRepository()`: The xref:core-model-components.adoc#registered-client-repository[`RegisteredClientRepository`] to use.
112-
<2> `authorizationService()`: The xref:core-model-components.adoc#oauth2-authorization-service[`OAuth2AuthorizationService`] to use.
113-
<3> `authorizationConsentService()`: The xref:core-model-components.adoc#oauth2-authorization-consent-service[`OAuth2AuthorizationConsentService`] to use.
114-
<4> `providerSettings()`: The <<configuring-provider-settings, `ProviderSettings`>> to use.
115-
<5> `tokenGenerator()`: The xref:core-model-components.adoc#oauth2-token-generator[`OAuth2TokenGenerator`] to use.
109+
<1> `registeredClientRepository()`: The xref:core-model-components.adoc#registered-client-repository[`RegisteredClientRepository`] (*REQUIRED*) for managing new and existing clients.
110+
<2> `authorizationService()`: The xref:core-model-components.adoc#oauth2-authorization-service[`OAuth2AuthorizationService`] for managing new and existing authorizations.
111+
<3> `authorizationConsentService()`: The xref:core-model-components.adoc#oauth2-authorization-consent-service[`OAuth2AuthorizationConsentService`] for managing new and existing authorization consents.
112+
<4> `providerSettings()`: The <<configuring-provider-settings, `ProviderSettings`>> (*REQUIRED*) for customizing configuration settings for the OAuth2 authorization server.
113+
<5> `tokenGenerator()`: The xref:core-model-components.adoc#oauth2-token-generator[`OAuth2TokenGenerator`] for generating tokens supported by the OAuth2 authorization server.
116114
<6> `clientAuthentication()`: The configurer for <<configuring-client-authentication, OAuth2 Client Authentication>>.
117115
<7> `authorizationEndpoint()`: The configurer for the xref:protocol-endpoints.adoc#oauth2-authorization-endpoint[OAuth2 Authorization endpoint].
118116
<8> `tokenEndpoint()`: The configurer for the xref:protocol-endpoints.adoc#oauth2-token-endpoint[OAuth2 Token endpoint].
@@ -181,6 +179,7 @@ It provides access to the `ProviderSettings` and the "`current`" issuer identifi
181179
[NOTE]
182180
If the issuer identifier is not configured in `ProviderSettings.builder().issuer(String)`, it is resolved from the current request.
183181

182+
[NOTE]
184183
The `ProviderContext` is accessible through the `ProviderContextHolder`, which associates it with the current request thread by using a `ThreadLocal`.
185184

186185
[NOTE]

docs/src/docs/asciidoc/core-model-components.adoc

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[[core-model-components]]
22
= Core Model / Components
3-
:toc: left
4-
:toclevels: 1
5-
:spring-security-reference-base-url: https://docs.spring.io/spring-security/reference
63

74
[[registered-client]]
85
== RegisteredClient
@@ -136,6 +133,9 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
136133
}
137134
----
138135

136+
[NOTE]
137+
The `OAuth2AuthorizationServerConfigurer` is useful when applying multiple configuration options simultaneously.
138+
139139
[[oauth2-authorization]]
140140
== OAuth2Authorization
141141

@@ -144,13 +144,13 @@ An `OAuth2Authorization` is a representation of an OAuth2 authorization, which h
144144
[TIP]
145145
The corresponding authorization model in Spring Security's OAuth2 Client support is {spring-security-reference-base-url}/servlet/oauth2/client/core.html#oauth2Client-authorized-client[OAuth2AuthorizedClient].
146146

147-
After the successful completion of an authorization grant flow, an `OAuth2Authorization` is created and associates an `OAuth2AccessToken`, an (optional) `OAuth2RefreshToken`, and additional state specific to the executed authorization grant type.
147+
After the successful completion of an authorization grant flow, an `OAuth2Authorization` is created and associates an {spring-security-api-base-url}/org/springframework/security/oauth2/core/OAuth2AccessToken.html[`OAuth2AccessToken`], an (optional) {spring-security-api-base-url}/org/springframework/security/oauth2/core/OAuth2RefreshToken.html[`OAuth2RefreshToken`], and additional state specific to the executed authorization grant type.
148148

149-
The `OAuth2Token` instances associated with an `OAuth2Authorization` vary, depending on the authorization grant type.
149+
The {spring-security-api-base-url}/org/springframework/security/oauth2/core/OAuth2Token.html[`OAuth2Token`] instances associated with an `OAuth2Authorization` vary, depending on the authorization grant type.
150150

151151
For the OAuth2 https://datatracker.ietf.org/doc/html/rfc6749#section-4.1[authorization_code grant], an `OAuth2AuthorizationCode`, an `OAuth2AccessToken`, and an (optional) `OAuth2RefreshToken` are associated.
152152

153-
For the OpenID Connect 1.0 https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth[authorization_code grant], an `OAuth2AuthorizationCode`, an `OidcIdToken`, an `OAuth2AccessToken`, and an (optional) `OAuth2RefreshToken` are associated.
153+
For the OpenID Connect 1.0 https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth[authorization_code grant], an `OAuth2AuthorizationCode`, an {spring-security-api-base-url}/org/springframework/security/oauth2/core/oidc/OidcIdToken.html[`OidcIdToken`], an `OAuth2AccessToken`, and an (optional) `OAuth2RefreshToken` are associated.
154154

155155
For the OAuth2 https://datatracker.ietf.org/doc/html/rfc6749#section-4.4[client_credentials grant], only an `OAuth2AccessToken` is associated.
156156

@@ -226,6 +226,9 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
226226
}
227227
----
228228

229+
[NOTE]
230+
The `OAuth2AuthorizationServerConfigurer` is useful when applying multiple configuration options simultaneously.
231+
229232
[[oauth2-authorization-consent]]
230233
== OAuth2AuthorizationConsent
231234

@@ -295,6 +298,9 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
295298
}
296299
----
297300

301+
[NOTE]
302+
The `OAuth2AuthorizationServerConfigurer` is useful when applying multiple configuration options simultaneously.
303+
298304
[[oauth2-token-context]]
299305
== OAuth2TokenContext
300306

@@ -333,7 +339,7 @@ public interface OAuth2TokenContext extends Context {
333339
<4> `getAuthorization()`: The <<oauth2-authorization, OAuth2Authorization>> associated with the authorization grant.
334340
<5> `getAuthorizedScopes()`: The scope(s) authorized for the client.
335341
<6> `getTokenType()`: The `OAuth2TokenType` to generate. The supported values are `code`, `access_token`, `refresh_token`, and `id_token`.
336-
<7> `getAuthorizationGrantType()`: The `AuthorizationGrantType`.
342+
<7> `getAuthorizationGrantType()`: The `AuthorizationGrantType` associated with the authorization grant.
337343
<8> `getAuthorizationGrant()`: The `Authentication` instance used by the `AuthenticationProvider` that processes the authorization grant.
338344

339345
[[oauth2-token-generator]]
@@ -363,7 +369,9 @@ The `OAuth2AccessTokenGenerator` generates an "opaque" (`OAuth2TokenFormat.REFER
363369

364370
[NOTE]
365371
The `OAuth2TokenGenerator` is an *OPTIONAL* component and defaults to a `DelegatingOAuth2TokenGenerator` composed of an `OAuth2AccessTokenGenerator` and `OAuth2RefreshTokenGenerator`.
366-
As well, if a `JwtEncoder` `@Bean` or `JWKSource<SecurityContext>` `@Bean` is registered, then a `JwtGenerator` is additionally composed in the `DelegatingOAuth2TokenGenerator`.
372+
373+
[NOTE]
374+
If a `JwtEncoder` `@Bean` or `JWKSource<SecurityContext>` `@Bean` is registered, then a `JwtGenerator` is additionally composed in the `DelegatingOAuth2TokenGenerator`.
367375

368376
The `OAuth2TokenGenerator` provides great flexibility, as it can support any custom token format for `access_token` and `refresh_token`.
369377

@@ -401,6 +409,9 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
401409
}
402410
----
403411

412+
[NOTE]
413+
The `OAuth2AuthorizationServerConfigurer` is useful when applying multiple configuration options simultaneously.
414+
404415
[[oauth2-token-customizer]]
405416
== OAuth2TokenCustomizer
406417

@@ -435,7 +446,7 @@ public OAuth2TokenCustomizer<OAuth2TokenClaimsContext> accessTokenCustomizer() {
435446
}
436447
----
437448

438-
[TIP]
449+
[NOTE]
439450
If the `OAuth2TokenGenerator` is not provided as a `@Bean` or is not configured through the `OAuth2AuthorizationServerConfigurer`, an `OAuth2TokenCustomizer<OAuth2TokenClaimsContext>` `@Bean` will automatically be configured with an `OAuth2AccessTokenGenerator`.
440451

441452
An `OAuth2TokenCustomizer<JwtEncodingContext>` declared with a generic type of `JwtEncodingContext` (`implements OAuth2TokenContext`) provides the ability to customize the headers and claims of a `Jwt`.
@@ -473,5 +484,8 @@ public OAuth2TokenCustomizer<JwtEncodingContext> jwtCustomizer() {
473484
}
474485
----
475486

476-
[TIP]
487+
[NOTE]
477488
If the `OAuth2TokenGenerator` is not provided as a `@Bean` or is not configured through the `OAuth2AuthorizationServerConfigurer`, an `OAuth2TokenCustomizer<JwtEncodingContext>` `@Bean` will automatically be configured with a `JwtGenerator`.
489+
490+
[TIP]
491+
For an example showing how you can xref:guides/how-to-userinfo.adoc#customize-id-token[customize the ID token], see the guide xref:guides/how-to-userinfo.adoc#how-to-userinfo[How-to: Customize the OpenID Connect 1.0 UserInfo response].

docs/src/docs/asciidoc/examples/src/main/java/sample/gettingStarted/SecurityConfig.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ public class SecurityConfig {
5353

5454
@Bean // <1>
5555
@Order(1)
56-
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception {
56+
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http)
57+
throws Exception {
5758
OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http);
5859
// @formatter:off
5960
http
61+
// Redirect to the login page when not authenticated from the
62+
// authorization endpoint
6063
.exceptionHandling((exceptions) -> exceptions
61-
.authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/login"))
64+
.authenticationEntryPoint(
65+
new LoginUrlAuthenticationEntryPoint("/login"))
6266
);
6367
// @formatter:on
6468

@@ -67,12 +71,15 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
6771

6872
@Bean // <2>
6973
@Order(2)
70-
public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
74+
public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http)
75+
throws Exception {
7176
// @formatter:off
7277
http
7378
.authorizeHttpRequests((authorize) -> authorize
7479
.anyRequest().authenticated()
7580
)
81+
// Form login handles the redirect to the login page from the
82+
// authorization server filter chain
7683
.formLogin(Customizer.withDefaults());
7784
// @formatter:on
7885

docs/src/docs/asciidoc/getting-started.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ This is a minimal configuration for getting started quickly. To understand what
5151

5252
<1> A Spring Security filter chain for the xref:protocol-endpoints.adoc[Protocol Endpoints].
5353
<2> A Spring Security filter chain for https://docs.spring.io/spring-security/reference/servlet/authentication/index.html[authentication].
54-
<3> An instance of `UserDetailsService` for retrieving users to authenticate.
54+
<3> An instance of {spring-security-api-base-url}/org/springframework/security/core/userdetails/UserDetailsService.html[`UserDetailsService`] for retrieving users to authenticate.
5555
<4> An instance of xref:core-components.adoc#registered-client-repository[`RegisteredClientRepository`] for managing clients.
5656
<5> An instance of `com.nimbusds.jose.jwk.source.JWKSource` for signing access tokens.
5757
<6> An instance of `java.security.KeyPair` with keys generated on startup used to create the `JWKSource` above.

docs/src/docs/asciidoc/guides/how-to-jpa.adoc

+21-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
:docs-dir: ..
55
:examples-dir: ../examples
66

7-
[[getting-started]]
8-
== Getting Started
9-
107
This guide shows how to implement the xref:{docs-dir}/core-model-components.adoc#core-model-components[core services] of xref:{docs-dir}/index.adoc#top[Spring Authorization Server] with JPA.
118
The purpose of this guide is to provide a starting point for implementing these services yourself, with the intention that you can make modifications to suit your needs.
129

10+
* <<define-data-model>>
11+
* <<create-jpa-entities>>
12+
* <<create-spring-data-repositories>>
13+
* <<implement-core-services>>
14+
1315
[[define-data-model]]
1416
== Define the data model
1517

@@ -20,6 +22,10 @@ NOTE: Except for token, state, metadata, settings, and claims values, we use the
2022
In reality, the length and even type of columns you use may need to be customized.
2123
You are encouraged to experiment and test before deploying to production.
2224

25+
* <<client-schema>>
26+
* <<authorization-schema>>
27+
* <<authorization-consent-schema>>
28+
2329
[[client-schema]]
2430
=== Client Schema
2531

@@ -69,6 +75,10 @@ The preceding schema examples provide a reference for the structure of the entit
6975
NOTE: The following entities are minimally annotated and are just examples.
7076
They allow the schema to be created dynamically and therefore do not require the above sql scripts to be executed manually.
7177

78+
* <<client-entity>>
79+
* <<authorization-entity>>
80+
* <<authorization-consent-entity>>
81+
7282
[[client-entity]]
7383
=== Client Entity
7484

@@ -107,6 +117,10 @@ include::{examples-dir}/src/main/java/sample/jpa/AuthorizationConsent.java[tag=c
107117

108118
By closely examining the interfaces of each core service and reviewing the `Jdbc` implementations, we can derive a minimal set of queries needed for supporting a JPA version of each interface.
109119

120+
* <<client-repository>>
121+
* <<authorization-repository>>
122+
* <<authorization-consent-repository>>
123+
110124
[[client-repository]]
111125
=== Client Repository
112126

@@ -150,6 +164,10 @@ By reviewing the `Jdbc` implementations, we can derive a minimal set of internal
150164
CAUTION: Keep in mind that writing JSON data to text columns with a fixed length has proven problematic with the `Jdbc` implementations.
151165
While these examples continue to do so, you may need to split these fields out into a separate table or data store that supports arbitrarily long data values.
152166

167+
* <<registered-client-repository>>
168+
* <<authorization-service>>
169+
* <<authorization-consent-service>>
170+
153171
[[registered-client-repository]]
154172
=== Registered Client Repository
155173

docs/src/docs/asciidoc/guides/how-to-userinfo.adoc

+10-13
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@
33
:index-link: ../how-to.html
44
:docs-dir: ..
55

6-
[[getting-started]]
7-
== Getting Started
8-
96
This guide shows how to customize the xref:{docs-dir}/protocol-endpoints.adoc#oidc-user-info-endpoint[User Info endpoint] of the xref:{docs-dir}/index.adoc#top[Spring Authorization Server].
107
The purpose of this guide is to demonstrate how to enable the endpoint and use the available customization options to produce a custom response.
118

9+
* <<enable-user-info>>
10+
* <<customize-user-info>>
11+
1212
[[enable-user-info]]
1313
== Enable the User Info Endpoint
1414

15-
Before customizing the response, you need to enable the User Info endpoint.
16-
In https://openid.net/specs/openid-connect-core-1_0.html#UserInfoRequest[Section 5.3.1], the OpenID Connect 1.0 Core specification states:
15+
The xref:{docs-dir}/protocol-endpoints.adoc#oidc-user-info-endpoint[OpenID Connect 1.0 UserInfo endpoint] is an OAuth2 protected resource, which *REQUIRES* an access token to be sent as a bearer token in the https://openid.net/specs/openid-connect-core-1_0.html#UserInfoRequest[UserInfo request].
1716

1817
> The Access Token obtained from an OpenID Connect Authentication Request MUST be sent as a Bearer Token, per Section 2 of https://openid.net/specs/openid-connect-core-1_0.html#RFC6750[OAuth 2.0 Bearer Token Usage] [RFC6750].
1918

20-
The User Info endpoint requires an authenticated request using the access token (which is a JWT when using the xref:{docs-dir}/getting-started.adoc#sample.gettingStarted[Getting Started config]).
21-
22-
The following listing shows how to configure https://docs.spring.io/spring-security/reference/servlet/oauth2/resource-server/jwt.html[Resource Server support] and provide a `JwtDecoder` that can validate the access token to allow authenticated requests to the User Info endpoint.
19+
Before customizing the response, you need to enable the User Info endpoint.
20+
The following listing shows how to enable the {spring-security-reference-base-url}/servlet/oauth2/resource-server/jwt.html[OAuth2 resource server configuration].
2321

2422
[[sample.userinfo]]
2523
include::code:EnableUserInfoSecurityConfig[]
@@ -37,14 +35,17 @@ This configuration provides the following:
3735

3836
The following sections describe some options for customizing the user info response.
3937

38+
* <<customize-id-token>>
39+
* <<customize-user-info-mapper>>
40+
4041
[[customize-id-token]]
4142
=== Customize the ID Token
4243

4344
By default, the user info response is generated by using claims from the `id_token` that are returned with the xref:{docs-dir}/protocol-endpoints.adoc#oauth2-token-endpoint[token response].
4445
Using the default strategy, https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims[standard claims] are returned only with the user info response based on the https://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims[requested scopes] during authorization.
4546

4647
The preferred way to customize the user info response is to add standard claims to the `id_token`.
47-
The following listing shows how add claims to the `id_token`.
48+
The following listing shows how to add claims to the `id_token`.
4849

4950
[[sample.userinfo.idtoken]]
5051
include::code:IdTokenCustomizerConfig[]
@@ -83,7 +84,3 @@ Similar to the <<customize-id-token,example shown earlier>> where we customize c
8384
include::code:JwtTokenCustomizerConfig[]
8485

8586
Whether you customize the user info response directly or use this example and customize the access token, you can look up information in a database, perform an LDAP query, make a request to another service, or use any other means of obtaining the information you want to be presented in the user info response.
86-
87-
== Conclusion
88-
89-
In this guide, you have learned how to <<enable-user-info,enable>> the xref:{docs-dir}/protocol-endpoints.adoc#oidc-user-info-endpoint[User Info endpoint] and explored various ways of customizing the response, including <<customize-id-token,customizing the ID token>> while continuing to use the built-in response and <<customize-user-info-mapper,customizing the response directly>> using a custom user info mapper.

docs/src/docs/asciidoc/how-to.adoc

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,7 @@
22
= "How-to" Guides
33

44
[[how-to-overview]]
5-
== Overview
5+
== List of Guides
66

77
* xref:guides/how-to-userinfo.adoc[Customize the OpenID Connect 1.0 UserInfo response]
88
* xref:guides/how-to-jpa.adoc[Implement core services with JPA]
9-
10-
[[how-to-coming-soon]]
11-
== Coming Soon
12-
13-
* Authenticate using social login, e.g. Google (https://github.com/spring-projects/spring-authorization-server/issues/538[#538])
14-
* Authenticate a user in a Single Page Application with PKCE (https://github.com/spring-projects/spring-authorization-server/issues/539[#539])
15-
* Deny access for a revoked JWT access token (https://github.com/spring-projects/spring-authorization-server/issues/543[#543])
16-
* Provide a JWK source backed by a key rotation strategy (https://github.com/spring-projects/spring-authorization-server/issues/544[#544])
17-
* Customize form based login (https://github.com/spring-projects/spring-authorization-server/issues/533[#533])
18-
* Add a custom grant type (https://github.com/spring-projects/spring-authorization-server/issues/686[#686])
19-
* Authenticate a user with two-factor authentication (https://github.com/spring-projects/spring-authorization-server/issues/534[#534])

docs/src/docs/asciidoc/overview.adoc

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
[[overview]]
22
= Overview
3-
:toc: left
4-
:toclevels: 1
53

64
This site contains reference documentation and how-to guides for Spring Authorization Server.
75

0 commit comments

Comments
 (0)