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
@@ -1061,7 +1085,7 @@ By default, Resource Server configures a clock skew of 60 seconds.
1061
1085
[[oauth2resourceserver-jwt-validation-custom]]
1062
1086
=== Configuring a Custom Validator
1063
1087
1064
-
Adding a check for the `aud` claim is simple with the `OAuth2TokenValidator` API:
1088
+
Adding a check for <<_supplying_audiences, the `aud` claim>> is simple with the `OAuth2TokenValidator` API:
1065
1089
1066
1090
====
1067
1091
.Java
@@ -1169,6 +1193,9 @@ fun jwtDecoder(): JwtDecoder {
1169
1193
----
1170
1194
====
1171
1195
1196
+
[TIP]
1197
+
As stated earlier, you can instead <<_supplying_audiences, configure `aud` validation in Boot>>.
0 commit comments