Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
springBoot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WitCloud
springBoot
Commits
0bec70c8
Commit
0bec70c8
authored
Mar 01, 2017
by
杨伊博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
a46fcef8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
15 deletions
+8
-15
pom.xml
springboot-springSecurity2/pom.xml
+0
-5
WebSecurityConfig.java
...rc/main/java/com/us/example/config/WebSecurityConfig.java
+8
-10
No files found.
springboot-springSecurity2/pom.xml
View file @
0bec70c8
...
@@ -35,11 +35,6 @@
...
@@ -35,11 +35,6 @@
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
</dependency>
</dependency>
<!-- 用于home.html文件中的 hasRole('ROLE_ADMIN') 语句-->
<dependency>
<groupId>
org.thymeleaf.extras
</groupId>
<artifactId>
thymeleaf-extras-springsecurity4
</artifactId>
</dependency>
<!--db-->
<!--db-->
<dependency>
<dependency>
<groupId>
mysql
</groupId>
<groupId>
mysql
</groupId>
...
...
springboot-springSecurity2/src/main/java/com/us/example/config/WebSecurityConfig.java
View file @
0bec70c8
...
@@ -11,26 +11,27 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
...
@@ -11,26 +11,27 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
/**
/**
* Created by yangyibo on 17/1/18.
* Created by yangyibo on 17/1/18.
*/
*/
@Configuration
@Configuration
@EnableWebSecurity
@EnableWebSecurity
@EnableGlobalMethodSecurity
(
securedEnabled
=
true
)
//
@EnableGlobalMethodSecurity(securedEnabled = true)
public
class
WebSecurityConfig
extends
WebSecurityConfigurerAdapter
{
public
class
WebSecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Bean
@Autowired
UserDetailsService
customUserService
(){
//注册UserDetailsService 的bean
private
CustomUserService
customUserService
;
return
new
CustomUserService
();
}
@Override
@Autowired
protected
void
configure
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
protected
void
configure
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
userDetailsService
(
customUserService
()
).
passwordEncoder
(
new
PasswordEncoder
(){
auth
.
userDetailsService
(
customUserService
).
passwordEncoder
(
new
PasswordEncoder
(){
@Override
@Override
public
String
encode
(
CharSequence
rawPassword
)
{
public
String
encode
(
CharSequence
rawPassword
)
{
...
@@ -48,9 +49,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
...
@@ -48,9 +49,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http
http
.
csrf
().
disable
()
.
csrf
().
disable
()
.
authorizeRequests
()
.
authorizeRequests
()
.
antMatchers
(
"/login"
).
permitAll
()
.
antMatchers
(
"/logout"
).
permitAll
()
.
antMatchers
(
"/"
).
permitAll
()
.
antMatchers
(
"/users/**"
)
.
antMatchers
(
"/users/**"
)
.
authenticated
()
.
authenticated
()
.
antMatchers
(
HttpMethod
.
POST
)
.
antMatchers
(
HttpMethod
.
POST
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment