Skip to content

Commit 1e33627

Browse files
committed
Use standard lambda syntax in documentation
Fixes: gh-7774
1 parent a35ce77 commit 1e33627

File tree

22 files changed

+423
-599
lines changed

22 files changed

+423
-599
lines changed

docs/manual/src/docs/asciidoc/_includes/reactive/exploits/headers.adoc

Lines changed: 36 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ You can easily do this with the following Java Configuration:
2323
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
2424
http
2525
// ...
26-
.headers(headers ->
27-
headers
28-
.frameOptions(frameOptions ->
29-
frameOptions
30-
.mode(Mode.SAMEORIGIN)
31-
)
26+
.headers(headers -> headers
27+
.frameOptions(frameOptions -> frameOptions
28+
.mode(Mode.SAMEORIGIN)
29+
)
3230
);
3331
return http.build();
3432
}
@@ -46,10 +44,7 @@ An example for both Java configuration is provided below:
4644
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
4745
http
4846
// ...
49-
.headers(headers ->
50-
headers
51-
.disable()
52-
);
47+
.headers(headers -> headers.disable());
5348
return http.build();
5449
}
5550
----
@@ -76,9 +71,8 @@ If necessary, you can also disable Spring Security's cache control HTTP response
7671
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
7772
http
7873
// ...
79-
.headers(headers ->
80-
headers
81-
.cache(cache -> cache.disable())
74+
.headers(headers -> headers
75+
.cache(cache -> cache.disable())
8276
);
8377
return http.build();
8478
}
@@ -99,9 +93,8 @@ However, you can disable it in Java Configuration with:
9993
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
10094
http
10195
// ...
102-
.headers(headers ->
103-
headers
104-
.contentTypeOptions(contentTypeOptions -> contentTypeOptions.disable())
96+
.headers(headers -> headers
97+
.contentTypeOptions(contentTypeOptions -> contentTypeOptions.disable())
10598
);
10699
return http.build();
107100
}
@@ -122,14 +115,12 @@ For example, the following is an example of explicitly providing HSTS with Java
122115
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
123116
http
124117
// ...
125-
.headers(headers ->
126-
headers
127-
.hsts(hsts ->
128-
hsts
129-
.includeSubdomains(true)
130-
.preload(true)
131-
.maxAge(Duration.ofDays(365))
132-
)
118+
.headers(headers -> headers
119+
.hsts(hsts -> hsts
120+
.includeSubdomains(true)
121+
.preload(true)
122+
.maxAge(Duration.ofDays(365))
123+
)
133124
);
134125
return http.build();
135126
}
@@ -150,12 +141,10 @@ You can customize frame options to use the same origin within Java Configuration
150141
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
151142
http
152143
// ...
153-
.headers(headers ->
154-
headers
155-
.frameOptions(frameOptions ->
156-
frameOptions
157-
.mode(SAMEORIGIN)
158-
)
144+
.headers(headers -> headers
145+
.frameOptions(frameOptions -> frameOptions
146+
.mode(SAMEORIGIN)
147+
)
159148
);
160149
return http.build();
161150
}
@@ -175,9 +164,8 @@ You can disable `X-XSS-Protection` with the following Java Configuration:
175164
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
176165
http
177166
// ...
178-
.headers(headers ->
179-
headers
180-
.xssProtection(xssProtection -> xssProtection.disable())
167+
.headers(headers -> headers
168+
.xssProtection(xssProtection -> xssProtection.disable())
181169
);
182170
return http.build();
183171
}
@@ -209,12 +197,10 @@ You can enable the CSP header using Java configuration as shown below:
209197
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
210198
http
211199
// ...
212-
.headers(headers ->
213-
headers
214-
.contentSecurityPolicy(contentSecurityPolicy ->
215-
contentSecurityPolicy
216-
.policyDirectives("script-src 'self' https://trustedscripts.example.com; object-src https://trustedplugins.example.com; report-uri /csp-report-endpoint/")
217-
)
200+
.headers(headers -> headers
201+
.contentSecurityPolicy(policy -> policy
202+
.policyDirectives("script-src 'self' https://trustedscripts.example.com; object-src https://trustedplugins.example.com; report-uri /csp-report-endpoint/")
203+
)
218204
);
219205
return http.build();
220206
}
@@ -231,13 +217,11 @@ To enable the CSP `report-only` header, provide the following Java configuration
231217
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
232218
http
233219
// ...
234-
.headers(headers ->
235-
headers
236-
.contentSecurityPolicy(contentSecurityPolicy ->
237-
contentSecurityPolicy
238-
.policyDirectives("script-src 'self' https://trustedscripts.example.com; object-src https://trustedplugins.example.com; report-uri /csp-report-endpoint/")
239-
.reportOnly()
240-
)
220+
.headers(headers -> headers
221+
.contentSecurityPolicy(policy -> policy
222+
.policyDirectives("script-src 'self' https://trustedscripts.example.com; object-src https://trustedplugins.example.com; report-uri /csp-report-endpoint/")
223+
.reportOnly()
224+
)
241225
);
242226
return http.build();
243227
}
@@ -258,12 +242,10 @@ You can enable the Referrer Policy header using Java configuration as shown belo
258242
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
259243
http
260244
// ...
261-
.headers(headers ->
262-
headers
263-
.referrerPolicy(referrerPolicy ->
264-
referrerPolicy
265-
.policy(ReferrerPolicy.SAME_ORIGIN)
266-
)
245+
.headers(headers -> headers
246+
.referrerPolicy(referrer -> referrer
247+
.policy(ReferrerPolicy.SAME_ORIGIN)
248+
)
267249
);
268250
return http.build();
269251
}
@@ -295,9 +277,8 @@ can enable the Feature Policy header using Java configuration as shown below:
295277
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
296278
http
297279
// ...
298-
.headers(headers ->
299-
headers
300-
.featurePolicy("geolocation 'self'")
280+
.headers(headers -> headers
281+
.featurePolicy("geolocation 'self'")
301282
);
302283
return http.build();
303284
}

docs/manual/src/docs/asciidoc/_includes/reactive/exploits/http.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ For example, if the production environment adds a header named `X-Forwarded-Prot
3838
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
3939
http
4040
// ...
41-
.redirectToHttps(redirectToHttps ->
42-
redirectToHttps
43-
.httpsRedirectWhen(e -> e.getRequest().getHeaders().containsKey("X-Forwarded-Proto"))
41+
.redirectToHttps(redirect -> redirect
42+
.httpsRedirectWhen(e -> e.getRequest().getHeaders().containsKey("X-Forwarded-Proto"))
4443
);
4544
return http.build();
4645
}

docs/manual/src/docs/asciidoc/_includes/reactive/method.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ public class SecurityConfig {
8888
return http
8989
// Demonstrate that method security works
9090
// Best practice to use both for defense in depth
91-
.authorizeExchange(exchanges ->
92-
exchanges
93-
.anyExchange().permitAll()
91+
.authorizeExchange(exchanges -> exchanges
92+
.anyExchange().permitAll()
9493
)
9594
.httpBasic(withDefaults())
9695
.build();

docs/manual/src/docs/asciidoc/_includes/reactive/oauth2/login.adoc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,11 @@ Additional configuration options can be seen below:
151151
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
152152
http
153153
// ...
154-
.oauth2Login(oauth2Login ->
155-
oauth2Login
156-
.authenticationConverter(converter)
157-
.authenticationManager(manager)
158-
.authorizedClientRepository(authorizedClients)
159-
.clientRegistrationRepository(clientRegistrations)
154+
.oauth2Login(oauth2 -> oauth2
155+
.authenticationConverter(converter)
156+
.authenticationManager(manager)
157+
.authorizedClientRepository(authorizedClients)
158+
.clientRegistrationRepository(clientRegistrations)
160159
);
161160
return http.build();
162161
}

0 commit comments

Comments
 (0)