Add Spring Boot Hello World guide
Add Spring Boot Hello World Guide Fixes gh-3866
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-samples-boot-helloworld</artifactId>
|
||||
<version>4.1.0.RELEASE</version>
|
||||
<version>4.1.1.BUILD-SNAPSHOT</version>
|
||||
<name>spring-security-samples-boot-helloworld</name>
|
||||
<description>spring-security-samples-boot-helloworld</description>
|
||||
<url>http://spring.io/spring-security</url>
|
||||
@@ -55,13 +55,13 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
<version>4.1.0.RELEASE</version>
|
||||
<version>4.1.1.BUILD-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-web</artifactId>
|
||||
<version>4.1.0.RELEASE</version>
|
||||
<version>4.1.1.BUILD-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -115,7 +115,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<version>4.1.0.RELEASE</version>
|
||||
<version>4.1.1.BUILD-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -124,6 +124,12 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshot</id>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
+4
-4
@@ -76,7 +76,7 @@ public class HelloWorldApplicationTests {
|
||||
|
||||
@Test
|
||||
public void loginUser() throws Exception {
|
||||
this.mockMvc.perform(formLogin().user("user1").password("password1"))
|
||||
this.mockMvc.perform(formLogin().user("user").password("password"))
|
||||
.andExpect(authenticated());
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class HelloWorldApplicationTests {
|
||||
|
||||
@Test
|
||||
public void loginUserAccessProtected() throws Exception {
|
||||
MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user1").password("password1"))
|
||||
MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user").password("password"))
|
||||
.andExpect(authenticated())
|
||||
.andReturn();
|
||||
|
||||
@@ -102,7 +102,7 @@ public class HelloWorldApplicationTests {
|
||||
|
||||
@Test
|
||||
public void loginUserValidateLogout() throws Exception {
|
||||
MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user1").password("password1"))
|
||||
MvcResult mvcResult = this.mockMvc.perform(formLogin().user("user").password("password"))
|
||||
.andExpect(authenticated())
|
||||
.andReturn();
|
||||
|
||||
@@ -117,4 +117,4 @@ public class HelloWorldApplicationTests {
|
||||
.andExpect(unauthenticated())
|
||||
.andExpect(status().is3xxRedirection());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
.withUser("user1").password("password1").roles("USER");
|
||||
.withUser("user").password("password").roles("USER");
|
||||
}
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ logging:
|
||||
|
||||
spring:
|
||||
thymeleaf:
|
||||
cache: true
|
||||
cache: false
|
||||
|
||||
@@ -10,9 +10,8 @@
|
||||
Logged in user: <span sec:authentication="name"></span> |
|
||||
Roles: <span sec:authentication="principal.authorities"></span>
|
||||
<div>
|
||||
<form action="/logout" method="post">
|
||||
<form action="#" th:action="@{/logout}" method="post">
|
||||
<input type="submit" value="Logout" />
|
||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -22,4 +21,4 @@
|
||||
<li>Go to the <a href="/user/index" th:href="@{/user/index}">secured pages</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<h1>Login page</h1>
|
||||
<p>Example user: user1 / password1</p>
|
||||
<p>Example user: user / password</p>
|
||||
<p th:if="${loginError}" class="error">Wrong user or password</p>
|
||||
<form th:action="@{/login}" method="post">
|
||||
<label for="username">Username</label>:
|
||||
|
||||
Reference in New Issue
Block a user