Skip to content

Commit d45a1fb

Browse files
author
Steve Riesenberg
committed
Use direct code import
Issue gh-1231
1 parent 2f7c4f6 commit d45a1fb

File tree

3 files changed

+61
-15
lines changed

3 files changed

+61
-15
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ If you want to customize the default configuration (regardless of whether you're
8080
These components can be defined as follows:
8181

8282
[[sample.gettingStarted]]
83-
include::code:SecurityConfig[]
83+
.SecurityConfig.java
84+
[source,java]
85+
----
86+
include::{docs-java}/sample/gettingStarted/SecurityConfig.java[]
87+
----
8488

8589
This is a minimal configuration for getting started quickly. To understand what each component is used for, see the following descriptions:
8690

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

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ The following listing shows the `Client` entity, which is used to persist inform
146146

147147
[[sample.jpa.entity.client]]
148148
.Client Entity
149-
include::code:Client[]
149+
[source,java]
150+
----
151+
include::{examples-dir}/src/main/java/sample/jpa/entity/client/Client.java[]
152+
----
150153

151154
[[authorization-entity]]
152155
=== Authorization Entity
@@ -155,7 +158,10 @@ The following listing shows the `Authorization` entity, which is used to persist
155158

156159
[[sample.jpa.entity.authorization]]
157160
.Authorization Entity
158-
include::code:Authorization[]
161+
[source,java]
162+
----
163+
include::{examples-dir}/src/main/java/sample/jpa/entity/authorization/Authorization.java[]
164+
----
159165

160166
[[authorization-consent-entity]]
161167
=== Authorization Consent Entity
@@ -164,7 +170,10 @@ The following listing shows the `AuthorizationConsent` entity, which is used to
164170

165171
[[sample.jpa.entity.authorizationConsent]]
166172
.Authorization Consent Entity
167-
include::code:AuthorizationConsent[]
173+
[source,java]
174+
----
175+
include::{examples-dir}/src/main/java/sample/jpa/entity/authorizationConsent/AuthorizationConsent.java[]
176+
----
168177

169178
[[create-spring-data-repositories]]
170179
== Create Spring Data repositories
@@ -182,7 +191,10 @@ The following listing shows the `ClientRepository`, which is able to find a <<cl
182191

183192
[[sample.jpa.repository.client]]
184193
.Client Repository
185-
include::code:ClientRepository[]
194+
[source,java]
195+
----
196+
include::{examples-dir}/src/main/java/sample/jpa/repository/client/ClientRepository.java[]
197+
----
186198

187199
[[authorization-repository]]
188200
=== Authorization Repository
@@ -192,7 +204,10 @@ It also allows querying a combination of token fields.
192204

193205
[[sample.jpa.repository.authorization]]
194206
.Authorization Repository
195-
include::code:AuthorizationRepository[]
207+
[source,java]
208+
----
209+
include::{examples-dir}/src/main/java/sample/jpa/repository/authorization/AuthorizationRepository.java[]
210+
----
196211

197212
[[authorization-consent-repository]]
198213
=== Authorization Consent Repository
@@ -201,7 +216,10 @@ The following listing shows the `AuthorizationConsentRepository`, which is able
201216

202217
[[sample.jpa.repository.authorizationConsent]]
203218
.Authorization Consent Repository
204-
include::code:AuthorizationConsentRepository[]
219+
[source,java]
220+
----
221+
include::{examples-dir}/src/main/java/sample/jpa/repository/authorizationConsent/AuthorizationConsentRepository.java[]
222+
----
205223

206224
[[implement-core-services]]
207225
== Implement core services
@@ -224,7 +242,10 @@ The following listing shows the `JpaRegisteredClientRepository`, which uses a <<
224242

225243
[[sample.jpa.service.client]]
226244
.`RegisteredClientRepository` Implementation
227-
include::code:JpaRegisteredClientRepository[]
245+
[source,java]
246+
----
247+
include::{examples-dir}/src/main/java/sample/jpa/service/client/JpaRegisteredClientRepository.java[]
248+
----
228249

229250
[[authorization-service]]
230251
=== Authorization Service
@@ -233,7 +254,10 @@ The following listing shows the `JpaOAuth2AuthorizationService`, which uses an <
233254

234255
[[sample.jpa.service.authorization]]
235256
.`OAuth2AuthorizationService` Implementation
236-
include::code:JpaOAuth2AuthorizationService[]
257+
[source,java]
258+
----
259+
include::{examples-dir}/src/main/java/sample/jpa/service/authorization/JpaOAuth2AuthorizationService.java[]
260+
----
237261

238262
[[authorization-consent-service]]
239263
=== Authorization Consent Service
@@ -242,4 +266,7 @@ The following listing shows the `JpaOAuth2AuthorizationConsentService`, which us
242266

243267
[[sample.jpa.service.authorizationConsent]]
244268
.`OAuth2AuthorizationConsentService` Implementation
245-
include::code:JpaOAuth2AuthorizationConsentService[]
269+
[source,java]
270+
----
271+
include::{examples-dir}/src/main/java/sample/jpa/service/authorizationConsent/JpaOAuth2AuthorizationConsentService.java[]
272+
----

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ Before customizing the response, you need to enable the UserInfo endpoint.
2222
The following listing shows how to enable the {spring-security-reference-base-url}/servlet/oauth2/resource-server/jwt.html[OAuth2 resource server configuration].
2323

2424
[[sample.userinfo]]
25-
include::code:EnableUserInfoSecurityConfig[]
25+
[source,java]
26+
----
27+
include::{examples-dir}/src/main/java/sample/userinfo/EnableUserInfoSecurityConfig.java[]
28+
----
2629

2730
TIP: Click on the "Expand folded text" icon in the code sample above to display the full example.
2831

@@ -50,7 +53,10 @@ The preferred way to customize the user info response is to add standard claims
5053
The following listing shows how to add claims to the `id_token`.
5154

5255
[[sample.userinfo.idtoken]]
53-
include::code:IdTokenCustomizerConfig[]
56+
[source,java]
57+
----
58+
include::{examples-dir}/src/main/java/sample/userinfo/idtoken/IdTokenCustomizerConfig.java[]
59+
----
5460

5561
This configuration provides the following:
5662

@@ -59,7 +65,10 @@ This configuration provides the following:
5965

6066
The following listing shows a custom service for looking up user info in a domain-specific way:
6167

62-
include::code:OidcUserInfoService[]
68+
[source,java]
69+
----
70+
include::{examples-dir}/src/main/java/sample/userinfo/idtoken/OidcUserInfoService.java[]
71+
----
6372

6473
[[customize-user-info-mapper]]
6574
=== Customize the User Info Mapper
@@ -70,7 +79,10 @@ The mapper implementation receives an instance of `OidcUserInfoAuthenticationCon
7079
The following listing shows how to use the customization option that is available while working directly with the `OAuth2AuthorizationServerConfigurer`.
7180

7281
[[sample.userinfo.jwt]]
73-
include::code:JwtUserInfoMapperSecurityConfig[]
82+
[source,java]
83+
----
84+
include::{examples-dir}/src/main/java/sample/userinfo/jwt/JwtUserInfoMapperSecurityConfig.java[]
85+
----
7486

7587
This configuration maps claims from the access token (which is a JWT when using the xref:{docs-dir}/getting-started.adoc#sample.gettingStarted[Getting Started config]) to populate the user info response and provides the following:
7688

@@ -83,6 +95,9 @@ This configuration maps claims from the access token (which is a JWT when using
8395
The user info mapper is not limited to mapping claims from a JWT, but this is a simple example that demonstrates the customization option.
8496
Similar to the <<customize-id-token,example shown earlier>> where we customize claims of the ID token, you can customize claims of the access token itself ahead of time, as in the following example:
8597

86-
include::code:JwtTokenCustomizerConfig[]
98+
[source,java]
99+
----
100+
include::{examples-dir}/src/main/java/sample/userinfo/jwt/JwtTokenCustomizerConfig.java[]
101+
----
87102

88103
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.

0 commit comments

Comments
 (0)