Polish
See gh-12326
This commit is contained in:
committed by
Stephane Nicoll
parent
1c27a8e6e2
commit
751c444166
@@ -2335,8 +2335,8 @@ If you define a `@Configuration` with a `WebSecurityConfigurerAdapter` in your a
|
||||
it switches off the default webapp security settings in Spring Boot.
|
||||
|
||||
|
||||
[[howto-change-the-authenticationmanager-and-add-user-accounts]]
|
||||
=== Change the AuthenticationManager and Add User Accounts
|
||||
[[howto-change-the-user-details-service-and-add-user-accounts]]
|
||||
=== Change the UserDetailsService and Add User Accounts
|
||||
If you provide a `@Bean` of type `AuthenticationManager`, `AuthenticationProvider`,
|
||||
or `UserDetailsService`, the default `@Bean` for `InMemoryUserDetailsManager` is not
|
||||
created, so you have the full feature set of Spring Security available (such as
|
||||
|
||||
@@ -643,7 +643,7 @@ NOTE: Range requests are not supported when using Jersey.
|
||||
An operation on a web endpoint or a web-specific endpoint extension can receive the
|
||||
current `java.security.Principal` or
|
||||
`org.springframework.boot.actuate.endpoint.SecurityContext` as a method parameter. The
|
||||
former is typically used in conjuction with `@Nullable` to provide different behaviour for
|
||||
former is typically used in conjunction with `@Nullable` to provide different behaviour for
|
||||
authenticated and unauthenticated users. The latter is typically used to perform
|
||||
authorization checks using its `isUserInRole(String)` method.
|
||||
|
||||
@@ -664,7 +664,7 @@ possible.
|
||||
==== Controller endpoints
|
||||
`@ControllerEndpoint` and `@RestControllerEndpoint` can be used to implement an endpoint
|
||||
that is only exposed by Spring MVC or Spring WebFlux. Methods are mapped using the
|
||||
standard annotations Spring MVC and Spring WevFlux annotations such as `@RequestMapping`
|
||||
standard annotations Spring MVC and Spring WebFlux annotations such as `@RequestMapping`
|
||||
and `@GetMapping`, with the endpoint's ID being used as a prefix for the path. Controller
|
||||
endpoints provide deeper integration with Spring's web frameworks but at the expense of
|
||||
portability. The `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever
|
||||
|
||||
@@ -2034,8 +2034,8 @@ for Webjars.
|
||||
|
||||
To use version agnostic URLs for Webjars, add the `webjars-locator-core` dependency.
|
||||
Then declare your Webjar. Using jQuery as an example, adding
|
||||
`"/webjars/jquery/dist/jquery.min.js"` results in
|
||||
`"/webjars/jquery/x.y.z/dist/jquery.min.js"`. where `x.y.z` is the Webjar version.
|
||||
`"/webjars/jquery/jquery.min.js"` results in
|
||||
`"/webjars/jquery/x.y.z/jquery.min.js"`. where `x.y.z` is the Webjar version.
|
||||
|
||||
NOTE: If you use JBoss, you need to declare the `webjars-locator-jboss-vfs`
|
||||
dependency instead of the `webjars-locator-core`. Otherwise, all Webjars resolve as a
|
||||
@@ -3012,13 +3012,13 @@ that you can see how to set things up.
|
||||
[[boot-features-security]]
|
||||
== Security
|
||||
If {spring-security}[Spring Security] is on the classpath, then web applications are
|
||||
secure by default. Spring Boot relies on Spring Security’s content-negotiation strategy to
|
||||
secured by default. Spring Boot relies on Spring Security’s content-negotiation strategy to
|
||||
determine whether to use `httpBasic` or `formLogin`. To add method-level security to a web
|
||||
application, you can also add `@EnableGlobalMethodSecurity` with your desired settings.
|
||||
Additional information can be found in the {spring-security-reference}#jc-method[Spring
|
||||
Security Reference Guide].
|
||||
|
||||
The default `AuthenticationManager` has a single user. The user name is `user`, and the
|
||||
The default `UserDetailsService` has a single user. The user name is `user`, and the
|
||||
password is random and is printed at INFO level when the application starts, as shown in
|
||||
the following example:
|
||||
|
||||
@@ -3049,14 +3049,15 @@ You can provide a different `AuthenticationEventPublisher` by adding a bean for
|
||||
|
||||
[[boot-features-security-mvc]]
|
||||
=== MVC Security
|
||||
The default security configuration is implemented in `SecurityAutoConfiguration` and in
|
||||
the classes imported from there (`SpringBootWebSecurityConfiguration` for web security
|
||||
and `AuthenticationManagerConfiguration` for authentication configuration, which is also
|
||||
relevant in non-web applications). To switch off the default web application security
|
||||
The default security configuration is implemented in `SecurityAutoConfiguration` and
|
||||
`UserDetailsServiceAutoConfiguration`. `SecurityAutoConfiguration` imports
|
||||
`SpringBootWebSecurityConfiguration` for web security and
|
||||
`UserDetailsServiceAutoConfiguration` configures authentication, which is also
|
||||
relevant in non-web applications. To switch off the default web application security
|
||||
configuration completely, you can add a bean of type `WebSecurityConfigurerAdapter` (doing
|
||||
so does not disable the authentication manager configuration or Actuator's security).
|
||||
so does not disable the `UserDetailsService` configuration or Actuator's security).
|
||||
|
||||
To also switch off the authentication manager configuration, you can add a bean of type
|
||||
To also switch off the `UserDetailsService` configuration, you can add a bean of type
|
||||
`UserDetailsService`, `AuthenticationProvider`, or `AuthenticationManager`.
|
||||
There are several secure applications in the {github-code}/spring-boot-samples/[Spring
|
||||
Boot samples] to get you started with common use cases.
|
||||
@@ -3074,14 +3075,14 @@ commonly used locations.
|
||||
=== WebFlux Security
|
||||
Similar to Spring MVC applications, you can secure your WebFlux applications by adding
|
||||
the `spring-boot-starter-security` dependency. The default security configuration is
|
||||
implemented in `ReactiveSecurityAutoConfiguration` and in the classes imported from there
|
||||
(`WebFluxSecurityConfiguration` for web security and
|
||||
`ReactiveAuthenticationManagerConfiguration` for authentication configuration, which is
|
||||
also relevant in non-web applications). To switch off the default web application security
|
||||
implemented in `ReactiveSecurityAutoConfiguration` and
|
||||
`UserDetailsServiceAutoConfiguration`. `ReactiveSecurityAutoConfiguration` imports
|
||||
`WebFluxSecurityConfiguration` for web security and `UserDetailsServiceAutoConfiguration`
|
||||
configures authentication, which is also relevant in non-web applications. To switch off the default web application security
|
||||
configuration completely, you can add a bean of type `WebFilterChainProxy` (doing so does
|
||||
not disable the authentication manager configuration or Actuator's security).
|
||||
not disable the `UserDetailsService` configuration or Actuator's security).
|
||||
|
||||
To also switch off the authentication manager configuration, you can add a bean of type
|
||||
To also switch off the `UserDetailsService` configuration, you can add a bean of type
|
||||
`ReactiveUserDetailsService` or `ReactiveAuthenticationManager`.
|
||||
|
||||
Access rules can be configured by adding a custom `SecurityWebFilterChain`. Spring
|
||||
|
||||
Reference in New Issue
Block a user