Merge pull request #3916 from steinhauer-software/BAEL-1489
BAEL-1489: Password storage in Spring Security 5
This commit is contained in:
		
						commit
						30eeb09828
					
				| @ -1,22 +1,22 @@ | |||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||
| 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||||
| 	<modelVersion>4.0.0</modelVersion> |     <modelVersion>4.0.0</modelVersion> | ||||||
| 	<groupId>com.baeldung</groupId> |     <groupId>com.baeldung</groupId> | ||||||
| 	<artifactId>spring-5-security</artifactId> |     <artifactId>spring-5-security</artifactId> | ||||||
| 	<version>0.0.1-SNAPSHOT</version> |     <version>0.0.1-SNAPSHOT</version> | ||||||
| 	<packaging>jar</packaging> |     <packaging>jar</packaging> | ||||||
| 
 | 
 | ||||||
| 	<name>spring-5-security</name> |     <name>spring-5-security</name> | ||||||
| 	<description>spring 5 security sample project</description> |     <description>spring 5 security sample project</description> | ||||||
| 
 | 
 | ||||||
| 	<parent> |     <parent> | ||||||
| 		<groupId>org.springframework.boot</groupId> |         <groupId>org.springframework.boot</groupId> | ||||||
| 		<artifactId>spring-boot-starter-parent</artifactId> |         <artifactId>spring-boot-starter-parent</artifactId> | ||||||
| 		<version>2.0.0.RC2</version> |         <version>2.0.0.RELEASE</version> | ||||||
| 		<relativePath /> <!-- lookup parent from repository --> |         <relativePath/> <!-- lookup parent from repository --> | ||||||
| 	</parent> |     </parent> | ||||||
| 
 | 
 | ||||||
| 	<dependencies> |     <dependencies> | ||||||
| 
 | 
 | ||||||
| 		<dependency> | 		<dependency> | ||||||
| 			<groupId>org.springframework.boot</groupId> | 			<groupId>org.springframework.boot</groupId> | ||||||
| @ -35,80 +35,80 @@ | |||||||
| 			<artifactId>thymeleaf-extras-springsecurity4</artifactId> | 			<artifactId>thymeleaf-extras-springsecurity4</artifactId> | ||||||
| 		</dependency> | 		</dependency> | ||||||
| 
 | 
 | ||||||
| 		<!-- oauth2 --> |         <!-- oauth2 --> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework.security</groupId> |             <groupId>org.springframework.security</groupId> | ||||||
| 			<artifactId>spring-security-oauth2-client</artifactId> |             <artifactId>spring-security-oauth2-client</artifactId> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework.security</groupId> |             <groupId>org.springframework.security</groupId> | ||||||
| 			<artifactId>spring-security-oauth2-jose</artifactId> |             <artifactId>spring-security-oauth2-jose</artifactId> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 
 | 
 | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework</groupId> |             <groupId>org.springframework</groupId> | ||||||
| 			<artifactId>spring-test</artifactId> |             <artifactId>spring-test</artifactId> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework.boot</groupId> |             <groupId>org.springframework.boot</groupId> | ||||||
| 			<artifactId>spring-boot-starter-test</artifactId> |             <artifactId>spring-boot-starter-test</artifactId> | ||||||
| 			<scope>test</scope> |             <scope>test</scope> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 		<dependency> |         <dependency> | ||||||
| 			<groupId>org.springframework.security</groupId> |             <groupId>org.springframework.security</groupId> | ||||||
| 			<artifactId>spring-security-test</artifactId> |             <artifactId>spring-security-test</artifactId> | ||||||
| 			<scope>test</scope> |             <scope>test</scope> | ||||||
| 		</dependency> |         </dependency> | ||||||
| 	</dependencies> |     </dependencies> | ||||||
| 
 | 
 | ||||||
| 	<build> |     <build> | ||||||
| 		<plugins> |         <plugins> | ||||||
| 			<plugin> |             <plugin> | ||||||
| 				<groupId>org.springframework.boot</groupId> |                 <groupId>org.springframework.boot</groupId> | ||||||
| 				<artifactId>spring-boot-maven-plugin</artifactId> |                 <artifactId>spring-boot-maven-plugin</artifactId> | ||||||
| 			</plugin> |             </plugin> | ||||||
| 
 | 
 | ||||||
| 			<plugin> |             <plugin> | ||||||
| 				<groupId>org.apache.maven.plugins</groupId> |                 <groupId>org.apache.maven.plugins</groupId> | ||||||
| 				<artifactId>maven-surefire-plugin</artifactId> |                 <artifactId>maven-surefire-plugin</artifactId> | ||||||
| 				<configuration> |                 <configuration> | ||||||
| 					<forkCount>3</forkCount> |                     <forkCount>3</forkCount> | ||||||
| 					<reuseForks>true</reuseForks> |                     <reuseForks>true</reuseForks> | ||||||
| 					<parallel>methods</parallel> |                     <parallel>methods</parallel> | ||||||
| 					<useUnlimitedThreads>true</useUnlimitedThreads> |                     <useUnlimitedThreads>true</useUnlimitedThreads> | ||||||
| 					<excludes> |                     <excludes> | ||||||
| 						<exclude>**/*IntegrationTest.java</exclude> |                         <exclude>**/*IntegrationTest.java</exclude> | ||||||
| 						<exclude>**/*LiveTest.java</exclude> |                         <exclude>**/*LiveTest.java</exclude> | ||||||
| 					</excludes> |                     </excludes> | ||||||
| 				</configuration> |                 </configuration> | ||||||
| 			</plugin> |             </plugin> | ||||||
| 		</plugins> |         </plugins> | ||||||
| 	</build> |     </build> | ||||||
| 	 |  | ||||||
| 	<repositories> |  | ||||||
| 		<repository> |  | ||||||
| 			<id>spring-milestones</id> |  | ||||||
| 			<name>Spring Milestones</name> |  | ||||||
| 			<url>https://repo.spring.io/milestone</url> |  | ||||||
| 			<snapshots> |  | ||||||
| 				<enabled>false</enabled> |  | ||||||
| 			</snapshots> |  | ||||||
| 		</repository> |  | ||||||
| 	</repositories> |  | ||||||
| 	<pluginRepositories> |  | ||||||
| 		<pluginRepository> |  | ||||||
| 			<id>spring-milestones</id> |  | ||||||
| 			<name>Spring Milestones</name> |  | ||||||
| 			<url>https://repo.spring.io/milestone</url> |  | ||||||
| 			<snapshots> |  | ||||||
| 				<enabled>false</enabled> |  | ||||||
| 			</snapshots> |  | ||||||
| 		</pluginRepository> |  | ||||||
| 	</pluginRepositories> |  | ||||||
| 
 | 
 | ||||||
| 	<properties> |     <repositories> | ||||||
| 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |         <repository> | ||||||
| 		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |             <id>spring-milestones</id> | ||||||
| 		<java.version>1.8</java.version> |             <name>Spring Milestones</name> | ||||||
| 	</properties> |             <url>https://repo.spring.io/milestone</url> | ||||||
|  |             <snapshots> | ||||||
|  |                 <enabled>false</enabled> | ||||||
|  |             </snapshots> | ||||||
|  |         </repository> | ||||||
|  |     </repositories> | ||||||
|  |     <pluginRepositories> | ||||||
|  |         <pluginRepository> | ||||||
|  |             <id>spring-milestones</id> | ||||||
|  |             <name>Spring Milestones</name> | ||||||
|  |             <url>https://repo.spring.io/milestone</url> | ||||||
|  |             <snapshots> | ||||||
|  |                 <enabled>false</enabled> | ||||||
|  |             </snapshots> | ||||||
|  |         </pluginRepository> | ||||||
|  |     </pluginRepositories> | ||||||
|  | 
 | ||||||
|  |     <properties> | ||||||
|  |         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||||||
|  |         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||||||
|  |         <java.version>1.8</java.version> | ||||||
|  |     </properties> | ||||||
| </project> | </project> | ||||||
| @ -21,7 +21,6 @@ import java.util.Map; | |||||||
| @Configuration | @Configuration | ||||||
| public class PasswordStorageWebSecurityConfigurer extends WebSecurityConfigurerAdapter { | public class PasswordStorageWebSecurityConfigurer extends WebSecurityConfigurerAdapter { | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     @Override |     @Override | ||||||
|     protected void configure(AuthenticationManagerBuilder auth) throws Exception { |     protected void configure(AuthenticationManagerBuilder auth) throws Exception { | ||||||
|         auth.eraseCredentials(false) // 4 |         auth.eraseCredentials(false) // 4 | ||||||
| @ -31,8 +30,11 @@ public class PasswordStorageWebSecurityConfigurer extends WebSecurityConfigurerA | |||||||
| 
 | 
 | ||||||
|     @Bean |     @Bean | ||||||
|     public UserDetailsService getUserDefaultDetailsService() { |     public UserDetailsService getUserDefaultDetailsService() { | ||||||
|         User testUser = new User("baeldung", "{noop}SpringSecurity5", Collections.emptyList()); |         return new InMemoryUserDetailsManager(User | ||||||
|         return new InMemoryUserDetailsManager(testUser); |           .withUsername("baeldung") | ||||||
|  |           .password("{noop}SpringSecurity5") | ||||||
|  |           .authorities(Collections.emptyList()) | ||||||
|  |           .build()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Bean |     @Bean | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user