Skip to content

Commit ad7c44f

Browse files
committed
Add More role=primary/secondary
Issue gh-7801
1 parent 729da64 commit ad7c44f

File tree

6 files changed

+45
-69
lines changed

6 files changed

+45
-69
lines changed

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,32 +342,33 @@ However, this can be customized by exposing a `PasswordEncoder` as a Spring bean
342342

343343

344344
If you are migrating from Spring Security 4.2.x you can revert to the previous behavior by exposing a `NoOpPasswordEncoder` bean.
345-
For example, if you are using Java Configuration, you can create a configuration that looks like:
346345

347346
[WARNING]
348347
====
349348
Reverting to `NoOpPasswordEncoder` is not considered to be secure.
350349
You should instead migrate to using `DelegatingPasswordEncoder` to support secure password encoding.
351350
====
352351

353-
.NoOpPasswordEncoder with Java Configuration
352+
.NoOpPasswordEncoder
354353
====
355-
[source,java]
354+
.Java
355+
[source,java,role="primary"]
356356
----
357357
@Bean
358358
public static NoOpPasswordEncoder passwordEncoder() {
359359
return NoOpPasswordEncoder.getInstance();
360360
}
361361
----
362-
====
363362
364-
if you are using XML configuration, you can expose a `PasswordEncoder` with the id `passwordEncoder`:
365-
366-
.NoPasswordEncoder with XML
367-
====
368-
[source,xml]
363+
.XML
364+
[source,xml,role="secondary"]
369365
----
370366
<b:bean id="passwordEncoder"
371367
class="org.springframework.security.crypto.password.NoOpPasswordEncoder" factory-method="getInstance"/>
372368
----
373369
====
370+
371+
[NOTE]
372+
====
373+
XML Configuration requires the `NoOpPasswordEncoder` bean name to be `passwordEncoder`.
374+
====

docs/manual/src/docs/asciidoc/_includes/servlet/authentication/unpwd/input/digest.adoc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ key: A private key to prevent modification of the nonce token
3737
You will need to ensure you <<authentication-password-storage-configuration,configure>> insecure plain text <<authentication-password-storage,Password Storage>> using NoOpPasswordEncoder`.
3838
The following provides an example of configuring Digest Authentication with Java Configuration:
3939

40-
.Digest Authentication with Java Configuration
40+
.Digest Authentication
4141
====
42-
[source,java]
42+
.Java
43+
[source,java,role="primary"]
4344
----
4445
@Autowired
4546
UserDetailsService userDetailsService;
@@ -63,13 +64,9 @@ protected void configure(HttpSecurity http) throws Exception {
6364
.addFilterBefore(digestFilter());
6465
}
6566
----
66-
====
67-
68-
The following provides an example of configuring Digest Authentication with XML Configuration:
6967
70-
.Digest Authentication with XML Configuration
71-
====
72-
[source,xml]
68+
.XML
69+
[source,xml,role="secondary"]
7370
----
7471
<b:bean id="digestFilter"
7572
class="org.springframework.security.web.authentication.www.DigestAuthenticationFilter"

docs/manual/src/docs/asciidoc/_includes/servlet/authentication/unpwd/input/form.adoc

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,20 @@ Spring Security form log in is enabled by default.
1212
However, as soon as any servlet based configuration is provided, form based log in must be explicitly provided.
1313
A minimal, explicit Java configuration can be found below:
1414

15-
.Form Log In Java Configuration
15+
.Form Log
1616
====
17-
[source,java]
17+
.Java
18+
[source,java,role="primary"]
1819
----
1920
protected void configure(HttpSecurity http) {
2021
http
2122
// ...
2223
.formLogin(withDefaults());
2324
}
2425
----
25-
====
26-
27-
A minimal XML configuration can be found below:
2826
29-
.Form Log In XML Configuration
30-
====
31-
[source,xml]
27+
.XML
28+
[source,xml,role="secondary"]
3229
----
3330
<http>
3431
<!-- ... -->
@@ -45,9 +42,10 @@ Most production applications will require a custom log in form.
4542

4643
The configuration below demonstrates how to provide a custom log in form.
4744

48-
.Custom Log In Form with Java Configuration
45+
.Custom Log In Form Configuration
4946
====
50-
[source,java]
47+
.Java
48+
[source,java,role="primary"]
5149
----
5250
protected void configure(HttpSecurity http) throws Exception {
5351
http
@@ -58,13 +56,9 @@ protected void configure(HttpSecurity http) throws Exception {
5856
);
5957
}
6058
----
61-
====
62-
63-
A minimal XML configuration can be found below:
6459
65-
.Custom Log In Form with XML Configuration
66-
====
67-
[source,xml]
60+
.XML
61+
[source,xml,role="secondary"]
6862
----
6963
<http>
7064
<!-- ... -->
@@ -75,13 +69,12 @@ A minimal XML configuration can be found below:
7569
====
7670

7771
[[servlet-authentication-form-custom-html]]
78-
=== HTML Form
79-
8072
When the login page is specified in the Spring Security configuration, you are responsible for rendering the page.
8173
Below is a https://www.thymeleaf.org/[Thymeleaf] template that produces an HTML login form that complies with a login page of `/login`.:
8274

83-
.Log In Form src/main/resources/templates/login.html
75+
.Log In Form
8476
====
77+
.src/main/resources/templates/login.html
8578
[source,xml]
8679
----
8780
<!DOCTYPE html>
@@ -122,13 +115,12 @@ Many users will not need much more than to customize the log in page.
122115
However, if needed everything above can be customized with additional configuration.
123116

124117
[[servlet-authentication-form-custom-controller]]
125-
== LoginController
126-
127118
If you are using Spring MVC, you will need a controller that maps `GET /login` to the login template we created.
128119
A minimal sample `LoginController` can be see below:
129120

130121
.LoginController
131122
====
123+
.src/main/java/example/LoginController.java
132124
[source,java]
133125
----
134126
@Controller

docs/manual/src/docs/asciidoc/_includes/servlet/authentication/unpwd/storage/in-memory.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ In this sample we use <<authentication-password-storage-boot-cli,Spring Boot CLI
99

1010
.InMemoryUserDetailsManager Java Configuration
1111
====
12-
[source,java]
12+
.Java
13+
[source,java,role="primary"]
1314
----
1415
@Bean
1516
public UserDetailsService users() {
@@ -26,13 +27,9 @@ public UserDetailsService users() {
2627
return new InMemoryUserDetailsManager(user, admin);
2728
}
2829
----
29-
====
30-
31-
The same configuration in XML looks like:
3230
33-
.<user-service> XML Configuration
34-
====
35-
[source,xml]
31+
.XML
32+
[source,xml,role="secondary"]
3633
----
3734
<user-service>
3835
<user name="user"

docs/manual/src/docs/asciidoc/_includes/servlet/authentication/unpwd/storage/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[[servlet-authentication-unpwd-storage]]
22
= User Storage
33

4-
Spring Security's <<servlet-authentication-userdetailsservice,`UserDetailsService`>> allows for storing user information including a username and password.
4+
Spring Security's <<servlet-authentication-userdetailsservice,`UserDetailsService`>> allows for storing user information when authenticating with a username/password.
55
`UserDetailsService` is used by Spring Security when it is configured to <<servlet-authentication-unpwd-input,accept a username/password>> for authentication.
66

77
// FIXME: Once it is retrieved it is validated using DaoAuthenticationProvider

docs/manual/src/docs/asciidoc/_includes/servlet/authentication/unpwd/storage/jdbc.adoc

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,14 @@
33

44
Spring Security's `JdbcDaoImpl` implements <<servlet-authentication-userdetailsservice,UserDetailsService>> to provide support for username/password based authentication that is retrieved using JDBC.
55
`JdbcUserDetailsManager` extends `JdbcDaoImpl` to provide management of `UserDetails` through the `UserDetailsManager` interface.
6+
`UserDetails` based authentication is used by Spring Security when it is configured to <<servlet-authentication-unpwd-input,accept a username/password>> for authentication.
67

78
In the following sections we will discuss:
89

910
* The <<servlet-authentication-jdbc-schema>> used by Spring Security JDBC Authentication
1011
* <<servlet-authentication-jdbc-datasource>>
1112
* <<servlet-authentication-jdbc-bean>>
1213

13-
[[servlet-authentication-jdbc-when]]
14-
== When is it Used?
15-
16-
JDBC authentication is used for authenticating a username and password.
17-
Spring Security leverages username/password based authentication when any of the following are enabled:
18-
19-
* <<servlet-authentication-form>>
20-
* <<servlet-authentication-basic>>
21-
2214
[[servlet-authentication-jdbc-schema]]
2315
== Default Schema
2416

@@ -115,9 +107,10 @@ create table group_members (
115107
Before we configure `JdbcUserDetailsManager`, we must create a `DataSource`.
116108
In our example, we will setup an https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/data-access.html#jdbc-embedded-database-support[embedded DataSource] that is initialized with the <<servlet-authentication-jdbc-schema,default user schema>>.
117109

118-
.Embedded Data Source with Java Configuration
110+
.Embedded Data Source
119111
====
120-
[source,java]
112+
.Java
113+
[source,java,role="primary"]
121114
----
122115
@Bean
123116
DataSource dataSource() {
@@ -127,11 +120,9 @@ DataSource dataSource() {
127120
.build();
128121
}
129122
----
130-
====
131123
132-
.Embedded Data Source with XML Configuration
133-
====
134-
[source,xml]
124+
.XML
125+
[source,xml,role="secondary"]
135126
----
136127
<jdbc:embedded-database>
137128
<jdbc:script location="classpath:org/springframework/security/core/userdetails/jdbc/users.ddl"/>
@@ -147,9 +138,11 @@ In a production environment, you will want to ensure you setup a connection to a
147138
In this sample we use <<authentication-password-storage-boot-cli,Spring Boot CLI>> to encode the password of `password` and get the encoded password of `{bcrypt}$2a$10$GRLdNijSQMUvl/au9ofL.eDwmoohzzS7.rmNSJZ.0FxO/BTk76klW`.
148139
See the <<authentication-password-storage,PasswordEncoder>> section for more details about how to store passwords.
149140

150-
.JdbcUserDetailsManager with Java Configuration
141+
.JdbcUserDetailsManager
151142
====
152-
[source,java]
143+
144+
.Java
145+
[source,java,role="primary"]
153146
----
154147
@Bean
155148
UserDetailsManager users(DataSource dataSource) {
@@ -167,13 +160,9 @@ UserDetailsManager users(DataSource dataSource) {
167160
users.createUser()
168161
}
169162
----
170-
====
171163
172-
The same configuration in XML looks like:
173-
174-
.<jdbc-user-service> XML Configuration
175-
====
176-
[source,xml]
164+
.XML
165+
[source,xml,role="secondary"]
177166
----
178167
<jdbc-user-service>
179168
<user name="user"

0 commit comments

Comments
 (0)