Skip to content

Commit 7171521

Browse files
author
Jay Bryant
committed
Further changes based on feedback
Mostly restoring the formatting of admonitions.
1 parent 93893de commit 7171521

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+712
-183
lines changed

docs/manual/src/docs/asciidoc/_includes/about/authentication/password-storage.adoc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,15 @@ All of the original passwords are `password`.
146146
----
147147
====
148148

149-
<1> The first password has a `PasswordEncoder` id of `bcrypt` and an encoded password value of `$2a$10$dXJ3SW6G7P50lGmMkkmwe.20cQQubK3.HZWzG3YB1tlRy.fqvM/BG`.
149+
<1> The first password has a `PasswordEncoder` id of `bcrypt` and an `encodedPassword` value of `$2a$10$dXJ3SW6G7P50lGmMkkmwe.20cQQubK3.HZWzG3YB1tlRy.fqvM/BG`.
150150
When matching, it would delegate to `BCryptPasswordEncoder`
151-
<2> The second password has a `PasswordEncoder` id of `noop` and encoded password value of `password`.
151+
<2> The second password has a `PasswordEncoder` id of `noop` and `encodedPassword` value of `password`.
152152
When matching, it would delegate to `NoOpPasswordEncoder`
153-
<3> The third password has a `PasswordEncoder` id of `pbkdf2` and encoded password value of `5d923b44a6d129f3ddf3e3c8d29412723dcbde72445e8ef6bf3b508fbf17fa4ed4d6b99ca763d8dc`.
153+
<3> The third password has a `PasswordEncoder` id of `pbkdf2` and `encodedPassword` value of `5d923b44a6d129f3ddf3e3c8d29412723dcbde72445e8ef6bf3b508fbf17fa4ed4d6b99ca763d8dc`.
154154
When matching, it would delegate to `Pbkdf2PasswordEncoder`
155-
<4> The fourth password has a `PasswordEncoder` id of `scrypt` and encoded password value of `$e0801$8bWJaSu2IKSn9Z9kM+TPXfOc/9bdYSrN1oD9qfVThWEwdRTnO7re7Ei+fUZRJ68k9lTyuTeUp4of4g24hHnazw==$OAOec05+bXxvuu/1qZ6NUR+xQYvYv7BeL1QxwRpY5Pc=`
155+
<4> The fourth password has a `PasswordEncoder` id of `scrypt` and `encodedPassword` value of `$e0801$8bWJaSu2IKSn9Z9kM+TPXfOc/9bdYSrN1oD9qfVThWEwdRTnO7re7Ei+fUZRJ68k9lTyuTeUp4of4g24hHnazw==$OAOec05+bXxvuu/1qZ6NUR+xQYvYv7BeL1QxwRpY5Pc=`
156156
When matching, it would delegate to `SCryptPasswordEncoder`
157-
<5> The final password has a `PasswordEncoder` id of `sha256` and encoded password value of `97cde38028ad898ebc02e690819fa220e88c62e0699403e94fff291cfffaf8410849f27605abcbc0`.
157+
<5> The final password has a `PasswordEncoder` id of `sha256` and `encodedPassword` value of `97cde38028ad898ebc02e690819fa220e88c62e0699403e94fff291cfffaf8410849f27605abcbc0`.
158158
When matching, it would delegate to `StandardPasswordEncoder`
159159

160160
[NOTE]
@@ -487,4 +487,8 @@ fun passwordEncoder(): PasswordEncoder {
487487
----
488488
====
489489

490-
NOTE: XML Configuration requires the `NoOpPasswordEncoder` bean name to be `passwordEncoder`.
490+
491+
[NOTE]
492+
====
493+
XML Configuration requires the `NoOpPasswordEncoder` bean name to be `passwordEncoder`.
494+
====

docs/manual/src/docs/asciidoc/_includes/about/exploits/csrf.adoc

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ In the following sections, we explore:
88
* <<csrf-protection>>
99
* <<csrf-considerations>>
1010

11-
NOTE: This portion of the documentation discusses the general topic of CSRF protection.
11+
[NOTE]
12+
====
13+
This portion of the documentation discusses the general topic of CSRF protection.
1214
See the relevant sections for specific information on CSRF protection for <<servlet-csrf,servlet>>- and <<webflux-csrf,WebFlux>>-based applications.
15+
====
1316

1417
[[csrf-explained]]
1518
== What is a CSRF Attack?
@@ -95,7 +98,10 @@ Spring provides two mechanisms to protect against CSRF attacks:
9598
* The <<Synchronizer Token Pattern>>
9699
* Specifying the <<SameSite Attribute>> on your session cookie
97100

98-
NOTE: Both protections require that <<csrf-protection-idempotent,Safe Methods be Idempotent>>.
101+
[NOTE]
102+
====
103+
Both protections require that <<csrf-protection-idempotent,Safe Methods be Idempotent>>.
104+
====
99105

100106
[[csrf-protection-idempotent]]
101107
=== Safe Methods Must be Idempotent
@@ -172,9 +178,12 @@ The evil website cannot provide the correct value for the `_csrf` parameter (whi
172178
An emerging way to protect against <<csrf,CSRF Attacks>> is to specify the https://tools.ietf.org/html/draft-west-first-party-cookies[SameSite Attribute] on cookies.
173179
A server can specify the `SameSite` attribute when setting a cookie to indicate that the cookie should not be sent when coming from external sites.
174180

175-
NOTE: Spring Security does not directly control the creation of the session cookie, so it does not provide support for the SameSite attribute.
181+
[NOTE]
182+
====
183+
Spring Security does not directly control the creation of the session cookie, so it does not provide support for the SameSite attribute.
176184
https://spring.io/projects/spring-session[Spring Session] provides support for the `SameSite` attribute in servlet-based applications.
177185
Spring Framework's https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/server/session/CookieWebSessionIdResolver.html[`CookieWebSessionIdResolver`] provides support for the `SameSite` attribute in WebFlux-based applications.
186+
====
178187

179188
An example of an HTTP response header with the `SameSite` attribute might look like:
180189

@@ -207,7 +216,10 @@ The user receives an email at https://email.example.org that includes a link to
207216
If the user clicks on the link, they would rightfully expect to be authenticated to the social media site.
208217
However, if the `SameSite` attribute is `Strict`, the cookie would not be sent and the user would not be authenticated.
209218

210-
NOTE: We could improve the protection and usability of `SameSite` protection against CSRF attacks by implementing https://github.com/spring-projects/spring-security/issues/7537[gh-7537].
219+
[NOTE]
220+
====
221+
We could improve the protection and usability of `SameSite` protection against CSRF attacks by implementing https://github.com/spring-projects/spring-security/issues/7537[gh-7537].
222+
====
211223

212224
Another obvious consideration is that, in order for the `SameSite` attribute to protect users, the browser must support the `SameSite` attribute.
213225
Most modern browsers do https://developer.mozilla.org/en-US/docs/Web/HTTP/headers/Set-Cookie#Browser_compatibility[support the SameSite attribute].
@@ -351,8 +363,11 @@ There are two options to using CSRF protection with multipart/form-data:
351363

352364
Each option has its trade-offs.
353365

354-
NOTE: Before you integrate Spring Security's CSRF protection with multipart file upload, you should first ensure that you can upload without the CSRF protection.
366+
[NOTE]
367+
====
368+
Before you integrate Spring Security's CSRF protection with multipart file upload, you should first ensure that you can upload without the CSRF protection.
355369
More information about using multipart forms with Spring, see the https://docs.spring.io/spring/docs/5.2.x/spring-framework-reference/web.html#mvc-multipart[1.1.11. Multipart Resolver] section of the Spring reference and the https://docs.spring.io/spring/docs/5.2.x/javadoc-api/org/springframework/web/multipart/support/MultipartFilter.html[`MultipartFilter` Javadoc].
370+
====
356371

357372
[[csrf-considerations-multipart-body]]
358373
==== Place CSRF Token in the Body

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

Lines changed: 76 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
[[headers]]
22
= Security HTTP Response Headers
33

4-
NOTE: This portion of the documentation discusses the general topic of Security HTTP Response Headers.
4+
[NOTE]
5+
====
6+
This portion of the documentation discusses the general topic of Security HTTP Response Headers.
57
See the relevant sections for specific information on Security HTTP Response Headers in <<servlet-headers,servlet>>- and <<webflux-headers,WebFlux>>-based applications.
8+
====
69

710
You can use https://www.owasp.org/index.php/OWASP_Secure_Headers_Project#tab=Headers[HTTP response headers] in many ways to increase the security of web applications.
811
This section is dedicated to the various HTTP response headers for which Spring Security provides explicit support.
@@ -11,7 +14,10 @@ If necessary, you can also configure Spring Security to provide <<headers-custom
1114
[[headers-default]]
1215
== Default Security Headers
1316

14-
NOTE: See the relevant sections for how to customize the defaults for both <<servlet-headers-default,servlet>>- and <<webflux-headers-default,webflux>>-based applications.
17+
[NOTE]
18+
====
19+
See the relevant sections for how to customize the defaults for both <<servlet-headers-default,servlet>>- and <<webflux-headers-default,webflux>>-based applications.
20+
====
1521

1622
Spring Security provides a default set of security related HTTP response headers to provide secure defaults.
1723

@@ -31,7 +37,10 @@ X-XSS-Protection: 1; mode=block
3137
----
3238
====
3339

34-
NOTE: Strict-Transport-Security is added only on HTTPS requests
40+
[NOTE]
41+
====
42+
Strict-Transport-Security is added only on HTTPS requests
43+
====
3544

3645
If the defaults do not meet your needs, you can easily remove, modify, or add headers from these defaults.
3746
For additional details on each of these headers, see the corresponding sections:
@@ -45,7 +54,10 @@ For additional details on each of these headers, see the corresponding sections:
4554
[[headers-cache-control]]
4655
== Cache Control
4756

48-
NOTE: See the relevant sections for how to customize the defaults for both <<servlet-headers-cache-control,servlet>>- and <<webflux-headers-cache-control,webflux>>-based applications.
57+
[NOTE]
58+
====
59+
See the relevant sections for how to customize the defaults for both <<servlet-headers-cache-control,servlet>>- and <<webflux-headers-cache-control,webflux>>-based applications.
60+
====
4961

5062
Spring Security's default is to disable caching to protect the user's content.
5163

@@ -70,15 +82,21 @@ This allows for applications to ensure that static resources (such as CSS and Ja
7082
[[headers-content-type-options]]
7183
== Content Type Options
7284

73-
NOTE: See the relevant sections for how to customize the defaults for both <<servlet-headers-content-type-options,servlet>>- and <<webflux-headers-content-type-options,webflux>>-based applications.
85+
[NOTE]
86+
====
87+
See the relevant sections for how to customize the defaults for both <<servlet-headers-content-type-options,servlet>>- and <<webflux-headers-content-type-options,webflux>>-based applications.
88+
====
7489

7590
Historically, browsers, including Internet Explorer, would try to guess the content type of a request by using https://en.wikipedia.org/wiki/Content_sniffing[content sniffing].
7691
This let browsers improve the user experience by guessing the content type on resources that had not specified the content type.
7792
For example, if a browser encountered a JavaScript file that did not have the content type specified, it would be able to guess the content type and then run it.
7893

79-
NOTE: There are many additional things one should do (such as only display the document in a distinct domain, ensure Content-Type header is set, sanitize the document, and others) when allowing content to be uploaded.
94+
[NOTE]
95+
====
96+
There are many additional things one should do (such as only display the document in a distinct domain, ensure Content-Type header is set, sanitize the document, and others) when allowing content to be uploaded.
8097
However, these measures are out of the scope of what Spring Security provides.
8198
It is also important to point out that, when disabling content sniffing, you must specify the content type in order for things to work properly.
99+
====
82100

83101
The problem with content sniffing is that this allowed malicious users to use polyglots (that is, a file that is valid as multiple content types) to perform XSS attacks.
84102
For example, some sites may allow users to submit a valid postscript document to a website and view it.
@@ -97,7 +115,10 @@ X-Content-Type-Options: nosniff
97115
[[headers-hsts]]
98116
== HTTP Strict Transport Security (HSTS)
99117

100-
NOTE: Refer to the relevant sections to see how to customize the defaults for both <<servlet-headers-hsts,servlet>> and <<webflux-headers-hsts,webflux>> based applications.
118+
[NOTE]
119+
====
120+
Refer to the relevant sections to see how to customize the defaults for both <<servlet-headers-hsts,servlet>> and <<webflux-headers-hsts,webflux>> based applications.
121+
====
101122

102123
When you type in your bank's website, do you enter `mybank.example.com` or do you enter `https://mybank.example.com`?
103124
If you omit the `https` protocol, you are potentially vulnerable to https://en.wikipedia.org/wiki/Man-in-the-middle_attack[Man-in-the-Middle attacks].
@@ -107,8 +128,11 @@ Many users omit the `https` protocol, and this is why https://tools.ietf.org/htm
107128
Once `mybank.example.com` is added as a https://tools.ietf.org/html/rfc6797#section-5.1[HSTS host], a browser can know ahead of time that any request to mybank.example.com should be interpreted as https://mybank.example.com.
108129
This greatly reduces the possibility of a Man-in-the-Middle attack occurring.
109130

110-
NOTE: In accordance with https://tools.ietf.org/html/rfc6797#section-7.2[RFC6797], the HSTS header is injected only into HTTPS responses.
131+
[NOTE]
132+
====
133+
In accordance with https://tools.ietf.org/html/rfc6797#section-7.2[RFC6797], the HSTS header is injected only into HTTPS responses.
111134
For the browser to acknowledge the header, the browser must first trust the CA that signed the SSL certificate used to make the connection (not just the SSL certificate).
135+
====
112136

113137
One way for a site to be marked as a HSTS host is to have the host preloaded into the browser.
114138
Another way is to add the `Strict-Transport-Security` header to the response.
@@ -131,7 +155,10 @@ For more details on HSTS preload, see https://hstspreload.org.
131155
[[headers-hpkp]]
132156
== HTTP Public Key Pinning (HPKP)
133157

134-
NOTE: To remain passive, Spring Security still provides <<servlet-headers-hpkp,support for HPKP in servlet environments>>. However, for the reasons listed earlier, HPKP is no longer recommended by the Spring Security team.
158+
[NOTE]
159+
====
160+
To remain passive, Spring Security still provides <<servlet-headers-hpkp,support for HPKP in servlet environments>>. However, for the reasons listed earlier, HPKP is no longer recommended by the Spring Security team.
161+
====
135162

136163
https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning[HTTP Public Key Pinning (HPKP)] specifies to a web client which public key to use with a certain web server to prevent Man-in-the-Middle (MITM) attacks with forged certificates.
137164
When used correctly, HPKP could add additional layers of protection against compromised certificates.
@@ -143,14 +170,20 @@ For additional details around why HPKP is no longer recommended, read https://bl
143170
[[headers-frame-options]]
144171
== X-Frame-Options
145172

146-
NOTE: See the relevant sections to see how to customize the defaults for both <<servlet-headers-frame-options,servlet>> and <<webflux-headers-frame-options,webflux>> based applications.
173+
[NOTE]
174+
====
175+
See the relevant sections to see how to customize the defaults for both <<servlet-headers-frame-options,servlet>> and <<webflux-headers-frame-options,webflux>> based applications.
176+
====
147177

148178
Letting your website be added to a frame can be a security issue.
149179
For example, by using clever CSS styling, users could be tricked into clicking on something that they were not intending.
150180
For example, a user that is logged into their bank might click a button that grants access to other users.
151181
This sort of attack is known as https://en.wikipedia.org/wiki/Clickjacking[Clickjacking].
152182

153-
NOTE: Another modern approach to dealing with clickjacking is to use <<headers-csp>>.
183+
[NOTE]
184+
====
185+
Another modern approach to dealing with clickjacking is to use <<headers-csp>>.
186+
====
154187

155188
There are a number ways to mitigate clickjacking attacks.
156189
For example, to protect legacy browsers from clickjacking attacks, you can use https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet#Best-for-now_Legacy_Browser_Frame_Breaking_Script[frame breaking code].
@@ -169,7 +202,10 @@ X-Frame-Options: DENY
169202
[[headers-xss-protection]]
170203
== X-XSS-Protection
171204

172-
NOTE: See the relevant sections to see how to customize the defaults for both <<servlet-headers-xss-protection,servlet>>- and <<webflux-headers-xss-protection,webflux>>-based applications.
205+
[NOTE]
206+
====
207+
See the relevant sections to see how to customize the defaults for both <<servlet-headers-xss-protection,servlet>>- and <<webflux-headers-xss-protection,webflux>>-based applications.
208+
====
173209

174210
Some browsers have built-in support for filtering out https://www.owasp.org/index.php/Testing_for_Reflected_Cross_site_scripting_(OWASP-DV-001)[reflected XSS attacks].
175211
This is by no means foolproof but does assist in XSS protection.
@@ -190,14 +226,20 @@ X-XSS-Protection: 1; mode=block
190226
[[headers-csp]]
191227
== Content Security Policy (CSP)
192228

193-
NOTE: See the relevant sections to see how to configure both <<servlet-headers-csp,servlet>>- and <<webflux-headers-csp,webflux>>-based applications.
229+
[NOTE]
230+
====
231+
See the relevant sections to see how to configure both <<servlet-headers-csp,servlet>>- and <<webflux-headers-csp,webflux>>-based applications.
232+
====
194233

195234
https://www.w3.org/TR/CSP2/[Content Security Policy (CSP)] is a mechanism that web applications can use to mitigate content injection vulnerabilities, such as cross-site scripting (XSS).
196235
CSP is a declarative policy that provides a facility for web application authors to declare and ultimately inform the client (user-agent) about the sources from which the web application expects to load resources.
197236

198-
NOTE: Content Security Policy is not intended to solve all content injection vulnerabilities.
237+
[NOTE]
238+
====
239+
Content Security Policy is not intended to solve all content injection vulnerabilities.
199240
Instead, you can use CSP to help reduce the harm caused by content injection attacks.
200241
As a first line of defense, web application authors should validate their input and encode their output.
242+
====
201243

202244
A web application can use CSP by including one of the following HTTP headers in the response:
203245

@@ -260,7 +302,10 @@ https://www.w3.org/TR/CSP2/[W3C Candidate Recommendation]
260302
[[headers-referrer]]
261303
== Referrer Policy
262304

263-
NOTE: See the relevant sections to see how to configure both <<servlet-headers-referrer,servlet>>- and <<webflux-headers-referrer,webflux>>-based applications.
305+
[NOTE]
306+
====
307+
See the relevant sections to see how to configure both <<servlet-headers-referrer,servlet>>- and <<webflux-headers-referrer,webflux>>-based applications.
308+
====
264309

265310
https://www.w3.org/TR/referrer-policy[Referrer Policy] is a mechanism that web applications can use to manage the referrer field, which contains the last
266311
page the user was on.
@@ -280,7 +325,10 @@ The Referrer-Policy response header instructs the browser to let the destination
280325
[[headers-feature]]
281326
== Feature Policy
282327

283-
NOTE: See the relevant sections to see how to configure both <<servlet-headers-feature,servlet>>- and <<webflux-headers-feature,webflux>>-based applications.
328+
[NOTE]
329+
====
330+
See the relevant sections to see how to configure both <<servlet-headers-feature,servlet>>- and <<webflux-headers-feature,webflux>>-based applications.
331+
====
284332

285333
https://wicg.github.io/feature-policy/[Feature Policy] is a mechanism that lets web developers selectively enable, disable, and modify the behavior of certain APIs and web features in the browser.
286334

@@ -299,7 +347,10 @@ These policies restrict what APIs the site can access or modify the browser's de
299347
[[headers-permissions]]
300348
== Permissions Policy
301349

302-
NOTE: See the relevant sections to see how to configure both <<servlet-headers-permissions,servlet>>- and <<webflux-headers-permissions,webflux>>-based applications.
350+
[NOTE]
351+
====
352+
See the relevant sections to see how to configure both <<servlet-headers-permissions,servlet>>- and <<webflux-headers-permissions,webflux>>-based applications.
353+
====
303354

304355
https://w3c.github.io/webappsec-permissions-policy/[Permissions Policy] is a mechanism that lets web developers selectively enable, disable, and modify the behavior of certain APIs and web features in the browser.
305356

@@ -318,7 +369,10 @@ These policies restrict what APIs the site can access or modify the browser's de
318369
[[headers-clear-site-data]]
319370
== Clear Site Data
320371

321-
NOTE: See the relevant sections to see how to configure both <<servlet-headers-clear-site-data,servlet>> and <<webflux-headers-clear-site-data,webflux>> based applications.
372+
[NOTE]
373+
====
374+
See the relevant sections to see how to configure both <<servlet-headers-clear-site-data,servlet>> and <<webflux-headers-clear-site-data,webflux>> based applications.
375+
====
322376

323377
https://www.w3.org/TR/clear-site-data/[Clear Site Data] is a mechanism by which any browser-side data (cookies, local storage, and the like) can be removed when an HTTP response contains this header:
324378

@@ -335,7 +389,10 @@ This is a nice clean-up action to perform on logout.
335389
[[headers-custom]]
336390
== Custom Headers
337391

338-
NOTE: See the relevant sections to see how to configure both <<servlet-headers-custom,servlet>> based applications.
392+
[NOTE]
393+
====
394+
See the relevant sections to see how to configure both <<servlet-headers-custom,servlet>> based applications.
395+
====
339396

340397
Spring Security has mechanisms to make it convenient to add the more common security headers to your application.
341398
However, it also provides hooks to enable adding custom headers.

0 commit comments

Comments
 (0)