SEC-2361: Java Config Sampels use @Autowired AuthenticationManagerBuilder
This commit is contained in:
@@ -4,7 +4,7 @@ Before securing your application, it is important to ensure that the existing ap
|
||||
|
||||
=== Updating your dependencies
|
||||
|
||||
You will need to ensure you have added the dependencies. Spring Security milestones and release canidates are available in the https://github.com/SpringSource/spring-framework/wiki/SpringSource-repository-FAQ[Spring Milestone Repository]. In short, if you are using Maven and using a milestone or release canidate ensure you have the following repository in your pom.xml:
|
||||
You will need to ensure you have added the dependencies. Spring Security milestones and release candidates are available in the https://github.com/SpringSource/spring-framework/wiki/SpringSource-repository-FAQ[Spring Milestone Repository]. In short, if you are using Maven and using a milestone or release candidates ensure you have the following repository in your pom.xml:
|
||||
|
||||
.pom.xml
|
||||
[source,xml]
|
||||
@@ -63,6 +63,8 @@ The next step is to create a Spring Security configuration.
|
||||
----
|
||||
package org.springframework.security.samples.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.security.config.annotation.authentication.builders.*;
|
||||
import org.springframework.security.config.annotation.web.configuration.*;
|
||||
@@ -71,8 +73,8 @@ import org.springframework.security.config.annotation.web.configuration.*;
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception {
|
||||
@Autowired
|
||||
public void registerGlobalAuthentication(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
.withUser("user").password("password").roles("USER");
|
||||
@@ -80,14 +82,12 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
[[servlet-api-integration]]
|
||||
The <<security-config-java,`SecurityConfig`>> will:
|
||||
|
||||
* Require authentication to every URL in your application
|
||||
* Generate a login form for you
|
||||
* Allow the user with the *Username* _user_ and the *Password* _password_ to authenticate with form based authentication
|
||||
* Allow the user with the *Username* _user_ and the *Password* _password_ to authenticate with HTTP basic authentication
|
||||
* Allow the user to logout
|
||||
* http://en.wikipedia.org/wiki/Cross-site_request_forgery[CSRF attack] prevention
|
||||
* http://en.wikipedia.org/wiki/Session_fixation[Session Fixation] protection
|
||||
|
||||
Reference in New Issue
Block a user