You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/servlet/oauth2/resource-server/jwt.adoc
+28-1Lines changed: 28 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -132,6 +132,30 @@ We still specify the `issuer-uri` so that Resource Server still validates the `i
132
132
[NOTE]
133
133
This property can also be supplied directly on the <<oauth2resourceserver-jwt-jwkseturi-dsl,DSL>>.
134
134
135
+
== Supplying Audiences
136
+
137
+
As already seen, the <<_specifying_the_authorization_server, `issuer-uri` property validates the `iss` claim>>; this is who sent the JWT.
138
+
139
+
Boot also has the `audiences` property for validating the `aud` claim; this is who the JWT was sent to.
140
+
141
+
A resource server's audience can be indicated like so:
142
+
143
+
[source,yaml]
144
+
----
145
+
spring:
146
+
security:
147
+
oauth2:
148
+
resourceserver:
149
+
jwt:
150
+
issuer-uri: https://idp.example.com
151
+
audiences: https://my-resource-server.example.com
152
+
----
153
+
154
+
[NOTE]
155
+
You can also add <<oauth2resourceserver-jwt-validation-custom, the `aud` validation programmatically>>, if needed.
156
+
157
+
The result will be that if the JWT's `iss` claim is not `https://idp.example.com`, and its `aud` claim does not contain `https://my-resource-server.example.com` in its list, then validation will fail.
158
+
135
159
[[oauth2resourceserver-jwt-sansboot]]
136
160
== Overriding or Replacing Boot Auto Configuration
137
161
@@ -1106,7 +1130,7 @@ By default, Resource Server configures a clock skew of 60 seconds.
1106
1130
[[oauth2resourceserver-jwt-validation-custom]]
1107
1131
=== Configuring a Custom Validator
1108
1132
1109
-
Adding a check for the `aud` claim is simple with the `OAuth2TokenValidator` API:
1133
+
Adding a check for <<_supplying_audiences, the `aud` claim>> is simple with the `OAuth2TokenValidator` API:
1110
1134
1111
1135
====
1112
1136
.Java
@@ -1214,6 +1238,9 @@ fun jwtDecoder(): JwtDecoder {
1214
1238
----
1215
1239
====
1216
1240
1241
+
[TIP]
1242
+
As stated earlier, you can instead <<_supplying_audiences, configure `aud` validation in Boot>>.
0 commit comments