You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before Spring Security 3.0, an `AuthenticationManager` was automatically registered internally.
4
-
Now you must register one explicitly by using the `<authentication-manager>` element.
5
-
Doing so creates an instance of Spring Security's `ProviderManager` class, which needs to be configured with a list of one or more `AuthenticationProvider` instances.
6
-
You can create these instances either by using syntax elements provided by the namespace or by using standard bean definitions, marked for addition to the list by using the `authentication-provider` element.
4
+
Now you must register one explicitly using the `<authentication-manager>` element.
5
+
This creates an instance of Spring Security's `ProviderManager` class, which needs to be configured with a list of one or more `AuthenticationProvider` instances.
6
+
These can either be created using syntax elements provided by the namespace, or they can be standard bean definitions, marked for addition to the list using the `authentication-provider` element.
7
7
8
8
9
9
[[nsa-authentication-manager]]
10
10
== <authentication-manager>
11
-
Every Spring Security application that uses the namespace must include the `<authentication-manager>` element somewhere.
12
-
It is responsible for registering the `AuthenticationManager`, which provides authentication services to the application.
13
-
All elements that create `AuthenticationProvider` instances should be children of this element.
11
+
Every Spring Security application which uses the namespace must have include this element somewhere.
12
+
It is responsible for registering the `AuthenticationManager` which provides authentication services to the application.
13
+
All elements which create `AuthenticationProvider` instances should be children of this element.
14
+
14
15
15
16
[[nsa-authentication-manager-attributes]]
16
17
=== <authentication-manager> Attributes
17
18
18
-
The `<authentication-manager>` element has the following attributes:
19
19
20
20
[[nsa-authentication-manager-alias]]
21
-
`alias`::
22
-
This attribute lets you define an alias name for the internal instance to use in your own configuration.
21
+
* **alias**
22
+
This attribute allows you to define an alias name for the internal instance for use in your own configuration.
23
23
24
24
25
25
[[nsa-authentication-manager-erase-credentials]]
26
-
`erase-credentials`::
27
-
If set to `true`, the `AuthenticationManager` tries to clear any credentials data in the returned `Authentication` object, once the user has been authenticated.
28
-
Literally, it maps to the `eraseCredentialsAfterAuthentication` property of the xref:servlet/authentication/architecture.adoc#servlet-authentication-providermanager[`ProviderManager`].
26
+
* **erase-credentials**
27
+
If set to true, the AuthenticationManager will attempt to clear any credentials data in the returned Authentication object, once the user has been authenticated.
28
+
Literally it maps to the `eraseCredentialsAfterAuthentication` property of the xref:servlet/authentication/architecture.adoc#servlet-authentication-providermanager[`ProviderManager`].
29
29
30
30
31
31
[[nsa-authentication-manager-id]]
32
-
`id`::
33
-
This attribute lets you define an ID for the internal instance to use in your own configuration.
34
-
It is the same as the `alias` element but provides a more consistent experience with elements that use the `id` attribute.
32
+
* **id**
33
+
This attribute allows you to define an id for the internal instance for use in your own configuration.
34
+
It is the same as the alias element, but provides a more consistent experience with elements that use the id attribute.
35
35
36
36
37
37
[[nsa-authentication-manager-children]]
38
38
=== Child Elements of <authentication-manager>
39
39
40
-
The `<authentication-manager>` element has the following child elements:
@@ -46,98 +45,99 @@ The `<authentication-manager>` element has the following child elements:
46
45
47
46
[[nsa-authentication-provider]]
48
47
== <authentication-provider>
49
-
Unless used with a `ref` attribute, the `<authentication-provider>` element is shorthand for configuring a `DaoAuthenticationProvider`.
50
-
A `DaoAuthenticationProvider` loads user information from a `UserDetailsService` and compares the username and password combination with the values supplied at login.
51
-
You can define the `UserDetailsService` instance either by using an available namespace element (`jdbc-user-service`) or by using the `user-service-ref` attribute to point to a bean defined elsewhere in the application context.
48
+
Unless used with a `ref` attribute, this element is shorthand for configuring a `DaoAuthenticationProvider`.
49
+
`DaoAuthenticationProvider` loads user information from a `UserDetailsService` and compares the username/password combination with the values supplied at login.
50
+
The `UserDetailsService` instance can be defined either by using an available namespace element (`jdbc-user-service` or by using the `user-service-ref` attribute to point to a bean defined elsewhere in the application context).
52
51
53
52
54
53
55
54
[[nsa-authentication-provider-parents]]
56
55
=== Parent Elements of <authentication-provider>
57
56
58
57
59
-
The parent element of the `<authentication-provider>` element is the <<nsa-authentication-manager,authentication-manager>> element.
The `<authentication-provider>` element has the following attributes:
67
65
68
66
[[nsa-authentication-provider-ref]]
69
-
ref::
67
+
* **ref**
70
68
Defines a reference to a Spring bean that implements `AuthenticationProvider`.
71
-
+
72
-
If you have written your own `AuthenticationProvider` implementation (or want to configure one of Spring Security's implementations as a traditional bean for some reason), you can use the following syntax to add it to the internal list of `ProviderManager`:
73
-
+
74
-
====
69
+
70
+
If you have written your own `AuthenticationProvider` implementation (or want to configure one of Spring Security's own implementations as a traditional bean for some reason, then you can use the following syntax to add it to the internal list of `ProviderManager`:
A reference to a bean that implements `UserDetailsService`, which may be created by using the standard bean element or the custom user-service element.
86
+
* **user-service-ref**
87
+
A reference to a bean that implements UserDetailsService that may be created using the standard bean element or the custom user-service element.
90
88
91
89
92
90
[[nsa-authentication-provider-children]]
93
91
=== Child Elements of <authentication-provider>
94
92
95
-
The `<authentication-provider>` element has the following child elements:
An SQL statement to query user's group authorities, given a username.
138
-
The default is as follows:
135
+
* **group-authorities-by-username-query**
136
+
An SQL statement to query user's group authorities given a username.
137
+
The default is
138
+
139
139
+
140
-
====
140
+
141
141
[source]
142
142
----
143
143
select
@@ -147,43 +147,45 @@ groups g, group_members gm, group_authorities ga
147
147
where
148
148
gm.username = ? and g.id = ga.group_id and g.id = gm.group_id
149
149
----
150
-
====
150
+
151
+
151
152
152
153
153
154
[[nsa-jdbc-user-service-id]]
154
-
`id`::
155
-
A bean identifier, which is used for referring to the bean elsewhere in the context.
155
+
* **id**
156
+
A bean identifier, used for referring to the bean elsewhere in the context.
156
157
157
158
158
159
[[nsa-jdbc-user-service-role-prefix]]
159
-
`role-prefix`::
160
-
A non-empty string prefix that is added to role strings loaded from persistent storage.
161
-
Default: `ROLE_`
162
-
Use a value of `none` for no prefix in cases where the default should be non-empty.
160
+
* **role-prefix**
161
+
A non-empty string prefix that will be added to role strings loaded from persistent storage (default is "ROLE_").
162
+
Use the value "none" for no prefix in cases where the default is non-empty.
163
163
164
164
165
165
[[nsa-jdbc-user-service-users-by-username-query]]
166
-
`users-by-username-query`::
167
-
An SQL statement to query a username, password, and enabled status, given a username.
168
-
The default is as follows:
166
+
* **users-by-username-query**
167
+
An SQL statement to query a username, password, and enabled status given a username.
168
+
The default is
169
+
169
170
+
170
-
====
171
+
171
172
[source]
172
173
----
173
174
select username, password, enabled from users where username = ?
174
175
----
175
-
====
176
+
177
+
178
+
176
179
177
180
[[nsa-password-encoder]]
178
181
== <password-encoder>
179
-
Injects a bean with the appropriate `PasswordEncoder` instance.
180
-
Authentication providers can optionally be configured to use a password encoder, as described in the xref:features/authentication/password-storage.adoc#authentication-password-storage[Password Storage].
182
+
Authentication providers can optionally be configured to use a password encoder as described in the xref:features/authentication/password-storage.adoc#authentication-password-storage[Password Storage].
183
+
This will result in the bean being injected with the appropriate `PasswordEncoder` instance.
181
184
182
185
183
186
[[nsa-password-encoder-parents]]
184
187
=== Parent Elements of <password-encoder>
185
188
186
-
The `<password-encoder>` element has the following parent elements:
The `<user-service>` element has a single child element: <<nsa-user,user>>.
244
-
Multiple `<user>` elements can be present.
242
+
243
+
* <<nsa-user,user>>
244
+
245
+
245
246
246
247
[[nsa-user]]
247
248
== <user>
248
-
The `<user>` represents a user in the application.
249
+
Represents a user in the application.
249
250
250
251
251
252
[[nsa-user-parents]]
252
253
=== Parent Elements of <user>
253
254
254
-
The parent element of the `<user>` element is the <<nsa-user-service,user-service>> element.
255
+
256
+
* <<nsa-user-service,user-service>>
257
+
258
+
255
259
256
260
[[nsa-user-attributes]]
257
261
=== <user> Attributes
258
262
259
263
260
264
[[nsa-user-authorities]]
261
-
`authorities`::
262
-
One of more authorities to be granted to the user.
263
-
Separate authorities with a comma (but no space) -- for example, `ROLE_USER,ROLE_ADMINISTRATOR`.
265
+
* **authorities**
266
+
One of more authorities granted to the user.
267
+
Separate authorities with a comma (but no space).
268
+
For example, "ROLE_USER,ROLE_ADMINISTRATOR"
264
269
265
270
266
271
[[nsa-user-disabled]]
267
-
`disabled`::
268
-
Set to `true` to mark an account as disabled and unusable.
272
+
* **disabled**
273
+
Can be set to "true" to mark an account as disabled and unusable.
269
274
270
275
271
276
[[nsa-user-locked]]
272
-
`locked`::
273
-
Set to `true` to mark an account as locked and unusable.
277
+
* **locked**
278
+
Can be set to "true" to mark an account as locked and unusable.
274
279
275
280
276
281
[[nsa-user-name]]
277
-
`name`::
282
+
* **name**
278
283
The username assigned to the user.
279
284
280
285
281
286
[[nsa-user-password]]
282
-
`password`::
283
-
This value may be hashed if the corresponding authentication provider supports hashing (remember to set the `hash` attribute of the `user-service` element).
284
-
You can omit this attribute when the data is not used for authentication but only for accessing authorities.
285
-
If omitted, the namespace generates a random value, preventing its accidental use for authentication.
286
-
This attribute cannot be empty.
287
+
* **password**
288
+
The password assigned to the user.
289
+
This may be hashed if the corresponding authentication provider supports hashing (remember to set the "hash" attribute of the "user-service" element).
290
+
This attribute be omitted in the case where the data will not be used for authentication, but only for accessing authorities.
291
+
If omitted, the namespace will generate a random value, preventing its accidental use for authentication.
0 commit comments