Skip to content

Commit 0849907

Browse files
committed
Move Opaque Token Migration Steps
1 parent c6bba38 commit 0849907

File tree

2 files changed

+67
-66
lines changed

2 files changed

+67
-66
lines changed
Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,2 @@
11
= Authentication Changes
22

3-
== Opaque Token Credentials Will Be Encoded For You
4-
5-
In order to comply more closely with the Introspection RFC, Spring Security's opaque token support will encode the client id and secret before creating the authorization header.
6-
This change means you will no longer have to encode the client id and secret yourself.
7-
8-
If your client id or secret contain URL-unsafe characters, then you can prepare yourself for this change by doing the following:
9-
10-
=== Replace Usage of `introspectionClientCredentials`
11-
12-
Since Spring Security can now do the encoding for you, replace xref:servlet/oauth2/resource-server/opaque-token.adoc#oauth2resourceserver-opaque-introspectionuri-dsl[using `introspectionClientCredentials`] with publishing the following `@Bean`:
13-
14-
[tabs]
15-
======
16-
Java::
17-
+
18-
[source,java,role="primary"]
19-
----
20-
@Bean
21-
OpaqueTokenIntrospector introspector() {
22-
return SpringOpaqueTokenIntrospector.withIntrospectionUri(introspectionUri)
23-
.clientId(unencodedClientId).clientSecret(unencodedClientSecret).build();
24-
}
25-
----
26-
27-
Kotlin::
28-
+
29-
[source,kotlin,role="secondary"]
30-
----
31-
@Bean
32-
fun introspector(): OpaqueTokenIntrospector {
33-
return SpringOpaqueTokenIntrospector.withIntrospectionUri(introspectionUri)
34-
.clientId(unencodedClientId).clientSecret(unencodedClientSecret).build()
35-
}
36-
----
37-
======
38-
39-
The above will be the default in 7.0.
40-
41-
If this setting gives you trouble or you cannot apply it for now, you can use the `RestOperations` constructor instead:
42-
43-
[tabs]
44-
======
45-
Java::
46-
+
47-
[source,java,role="primary"]
48-
----
49-
@Bean
50-
OpaqueTokenIntrospector introspector() {
51-
RestTemplate rest = new RestTemplate();
52-
rest.addInterceptor(new BasicAuthenticationInterceptor(encodedClientId, encodedClientSecret));
53-
return new SpringOpaqueTokenIntrospector(introspectionUri, rest);
54-
}
55-
----
56-
57-
Kotlin::
58-
+
59-
[source,kotlin,role="secondary"]
60-
----
61-
@Bean
62-
fun introspector(): OpaqueTokenIntrospector {
63-
val rest = RestTemplate()
64-
rest.addInterceptor(BasicAuthenticationInterceptor(encodedClientId, encodedClientSecret))
65-
return SpringOpaqueTokenIntrospector(introspectionUri, rest)
66-
}
67-
----
68-
======

docs/modules/ROOT/pages/migration-7/oauth2.adoc

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,70 @@ fun jwtDecoder(): JwtDecoder {
170170
<2> - specify the list of validators you need, excluding `JwtTypeValidator`
171171

172172
For additional guidance, please see the xref:servlet/oauth2/resource-server/jwt.adoc#oauth2resourceserver-jwt-validation[JwtDecoder Validators] section in the reference.
173+
174+
== Opaque Token Credentials Will Be Encoded For You
175+
176+
In order to comply more closely with the Introspection RFC, Spring Security's opaque token support will encode the client id and secret before creating the authorization header.
177+
This change means you will no longer have to encode the client id and secret yourself.
178+
179+
If your client id or secret contain URL-unsafe characters, then you can prepare yourself for this change by doing the following:
180+
181+
=== Replace Usage of `introspectionClientCredentials`
182+
183+
Since Spring Security can now do the encoding for you, replace xref:servlet/oauth2/resource-server/opaque-token.adoc#oauth2resourceserver-opaque-introspectionuri-dsl[using `introspectionClientCredentials`] with publishing the following `@Bean`:
184+
185+
[tabs]
186+
======
187+
Java::
188+
+
189+
[source,java,role="primary"]
190+
----
191+
@Bean
192+
OpaqueTokenIntrospector introspector() {
193+
return SpringOpaqueTokenIntrospector.withIntrospectionUri(introspectionUri)
194+
.clientId(unencodedClientId).clientSecret(unencodedClientSecret).build();
195+
}
196+
----
197+
198+
Kotlin::
199+
+
200+
[source,kotlin,role="secondary"]
201+
----
202+
@Bean
203+
fun introspector(): OpaqueTokenIntrospector {
204+
return SpringOpaqueTokenIntrospector.withIntrospectionUri(introspectionUri)
205+
.clientId(unencodedClientId).clientSecret(unencodedClientSecret).build()
206+
}
207+
----
208+
======
209+
210+
The above will be the default in 7.0.
211+
212+
If this setting gives you trouble or you cannot apply it for now, you can use the `RestOperations` constructor instead:
213+
214+
[tabs]
215+
======
216+
Java::
217+
+
218+
[source,java,role="primary"]
219+
----
220+
@Bean
221+
OpaqueTokenIntrospector introspector() {
222+
RestTemplate rest = new RestTemplate();
223+
rest.addInterceptor(new BasicAuthenticationInterceptor(encodedClientId, encodedClientSecret));
224+
return new SpringOpaqueTokenIntrospector(introspectionUri, rest);
225+
}
226+
----
227+
228+
Kotlin::
229+
+
230+
[source,kotlin,role="secondary"]
231+
----
232+
@Bean
233+
fun introspector(): OpaqueTokenIntrospector {
234+
val rest = RestTemplate()
235+
rest.addInterceptor(BasicAuthenticationInterceptor(encodedClientId, encodedClientSecret))
236+
return SpringOpaqueTokenIntrospector(introspectionUri, rest)
237+
}
238+
----
239+
======

0 commit comments

Comments
 (0)