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
@@ -1051,7 +1075,7 @@ By default, Resource Server configures a clock skew of 60 seconds.
1051
1075
[[oauth2resourceserver-jwt-validation-custom]]
1052
1076
=== Configuring a Custom Validator
1053
1077
1054
-
Adding a check for the `aud` claim is simple with the `OAuth2TokenValidator` API:
1078
+
Adding a check for <<_supplying_audiences, the `aud` claim>> is simple with the `OAuth2TokenValidator` API:
1055
1079
1056
1080
====
1057
1081
.Java
@@ -1159,6 +1183,9 @@ fun jwtDecoder(): JwtDecoder {
1159
1183
----
1160
1184
====
1161
1185
1186
+
[TIP]
1187
+
As stated earlier, you can instead <<_supplying_audiences, configure `aud` validation in Boot>>.
0 commit comments