25
25
import org .springframework .security .authentication .AuthenticationManager ;
26
26
import org .springframework .security .authentication .AuthenticationManagerResolver ;
27
27
import org .springframework .security .authentication .AuthenticationProvider ;
28
+ import org .springframework .security .config .Customizer ;
28
29
import org .springframework .security .config .annotation .web .HttpSecurityBuilder ;
29
30
import org .springframework .security .config .annotation .web .configurers .AbstractHttpConfigurer ;
30
31
import org .springframework .security .config .annotation .web .configurers .CsrfConfigurer ;
65
66
* <li>{@link #accessDeniedHandler(AccessDeniedHandler)}</li> - customizes how access denied errors are handled
66
67
* <li>{@link #authenticationEntryPoint(AuthenticationEntryPoint)}</li> - customizes how authentication failures are handled
67
68
* <li>{@link #bearerTokenResolver(BearerTokenResolver)} - customizes how to resolve a bearer token from the request</li>
68
- * <li>{@link #jwt()} - enables Jwt-encoded bearer token support</li>
69
+ * <li>{@link #jwt(Customizer)} - enables Jwt-encoded bearer token support</li>
70
+ * <li>{@link #opaqueToken(Customizer)} - enables opaque bearer token support</li>
69
71
* </ul>
70
72
*
71
73
* <p>
72
- * When using {@link #jwt()}, either
74
+ * When using {@link #jwt(Customizer )}, either
73
75
*
74
76
* <ul>
75
77
* <li>
83
85
* </li>
84
86
* </ul>
85
87
*
86
- * Also with {@link #jwt()} consider
88
+ * Also with {@link #jwt(Customizer )} consider
87
89
*
88
90
* <ul>
89
91
* <li>
93
95
* </ul>
94
96
*
95
97
* <p>
96
- * When using {@link #opaque( )}, supply an introspection endpoint and its authentication configuration
98
+ * When using {@link #opaqueToken(Customizer )}, supply an introspection endpoint and its authentication configuration
97
99
* </p>
98
100
*
99
101
* <h2>Security Filters</h2>
100
102
*
101
- * The following {@code Filter}s are populated when {@link #jwt()} is configured:
103
+ * The following {@code Filter}s are populated when {@link #jwt(Customizer )} is configured:
102
104
*
103
105
* <ul>
104
106
* <li>{@link BearerTokenAuthenticationFilter}</li>
@@ -180,6 +182,22 @@ public JwtConfigurer jwt() {
180
182
return this .jwtConfigurer ;
181
183
}
182
184
185
+ /**
186
+ * Enables Jwt-encoded bearer token support.
187
+ *
188
+ * @param jwtCustomizer the {@link Customizer} to provide more options for
189
+ * the {@link JwtConfigurer}
190
+ * @return the {@link OAuth2ResourceServerConfigurer} for further customizations
191
+ * @throws Exception
192
+ */
193
+ public OAuth2ResourceServerConfigurer <H > jwt (Customizer <JwtConfigurer > jwtCustomizer ) throws Exception {
194
+ if ( this .jwtConfigurer == null ) {
195
+ this .jwtConfigurer = new JwtConfigurer (this .context );
196
+ }
197
+ jwtCustomizer .customize (this .jwtConfigurer );
198
+ return this ;
199
+ }
200
+
183
201
public OpaqueTokenConfigurer opaqueToken () {
184
202
if (this .opaqueTokenConfigurer == null ) {
185
203
this .opaqueTokenConfigurer = new OpaqueTokenConfigurer (this .context );
@@ -188,6 +206,23 @@ public OpaqueTokenConfigurer opaqueToken() {
188
206
return this .opaqueTokenConfigurer ;
189
207
}
190
208
209
+ /**
210
+ * Enables opaque bearer token support.
211
+ *
212
+ * @param opaqueTokenCustomizer the {@link Customizer} to provide more options for
213
+ * the {@link OpaqueTokenConfigurer}
214
+ * @return the {@link OAuth2ResourceServerConfigurer} for further customizations
215
+ * @throws Exception
216
+ */
217
+ public OAuth2ResourceServerConfigurer <H > opaqueToken (Customizer <OpaqueTokenConfigurer > opaqueTokenCustomizer )
218
+ throws Exception {
219
+ if (this .opaqueTokenConfigurer == null ) {
220
+ this .opaqueTokenConfigurer = new OpaqueTokenConfigurer (this .context );
221
+ }
222
+ opaqueTokenCustomizer .customize (this .opaqueTokenConfigurer );
223
+ return this ;
224
+ }
225
+
191
226
@ Override
192
227
public void init (H http ) throws Exception {
193
228
registerDefaultAccessDeniedHandler (http );
0 commit comments