Skip to content

Commit f452a86

Browse files
committed
Polish "Document audience support in Oauth2 resource server"
See gh-35286
1 parent 13c5c6e commit f452a86

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/spring-security.adoc

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,21 @@ For JWT configuration, a JWK Set URI or OIDC Issuer URI needs to be specified, a
201201
NOTE: If the authorization server does not support a JWK Set URI, you can configure the resource server with the Public Key used for verifying the signature of the JWT.
202202
This can be done using the configprop:spring.security.oauth2.resourceserver.jwt.public-key-location[] property, where the value needs to point to a file containing the public key in the PEM-encoded x509 format.
203203

204-
The same properties are applicable for both servlet and reactive applications.
204+
The configprop:spring.security.oauth2.resourceserver.jwt.audiences[] property can be used to specifify the expected values of the aud claim in JWTs.
205+
For example, to require JWTs to contain an aud claim with the value `my-audience`:
205206

207+
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
208+
----
209+
spring:
210+
security:
211+
oauth2:
212+
resourceserver:
213+
jwt:
214+
audiences:
215+
- "my-audience"
216+
----
217+
218+
The same properties are applicable for both servlet and reactive applications.
206219
Alternatively, you can define your own `JwtDecoder` bean for servlet applications or a `ReactiveJwtDecoder` for reactive applications.
207220

208221
In cases where opaque tokens are used instead of JWTs, you can configure the following properties to validate tokens through introspection:
@@ -220,25 +233,9 @@ In cases where opaque tokens are used instead of JWTs, you can configure the fol
220233
----
221234

222235
Again, the same properties are applicable for both servlet and reactive applications.
223-
224236
Alternatively, you can define your own `OpaqueTokenIntrospector` bean for servlet applications or a `ReactiveOpaqueTokenIntrospector` for reactive applications.
225237

226-
To enable audience validation, set the `configprop:spring.security.oauth2.resourceserver.jwt.audiences[]` property in your Spring Boot application
227-
configuration file. This property specifies the expected value(s) of the aud claim in JWTs.
228-
229-
For example, to expect the JWTs to contain an aud claim with the value `my-audience`, you can add the following line to your
230-
application.properties file:
231238

232-
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
233-
----
234-
spring:
235-
security:
236-
oauth2:
237-
resourceserver:
238-
jwt:
239-
audiences:
240-
- "my-audience"
241-
----
242239

243240
[[web.security.oauth2.authorization-server]]
244241
==== Authorization Server

0 commit comments

Comments
 (0)