Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datacollector
Overview
Overview
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
chenweisong
datacollector
Commits
35feaef5
Commit
35feaef5
authored
Mar 19, 2020
by
linxu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加security config
parent
fcea4901
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
0 deletions
+65
-0
auth-common-1.0.2-SNAPSHOT.jar
lib/auth-common-1.0.2-SNAPSHOT.jar
+0
-0
pom.xml
pom.xml
+8
-0
SecurityConfig.java
...n/java/com/keymobile/rest/common/conf/SecurityConfig.java
+57
-0
No files found.
lib/auth-common-1.0.2-SNAPSHOT.jar
0 → 100644
View file @
35feaef5
File added
pom.xml
View file @
35feaef5
...
...
@@ -126,6 +126,14 @@
<artifactId>
activiti-modeler
</artifactId>
<version>
${activiti.version}
</version>
</dependency>
<dependency>
<groupId>
auth
</groupId>
<artifactId>
auth-common
</artifactId>
<scope>
system
</scope>
<systemPath>
${project.basedir}/lib/auth-common-1.0.2-SNAPSHOT.jar
</systemPath>
<version>
1.0.2
</version>
</dependency>
<!-- activiti end -->
...
...
src/main/java/com/keymobile/rest/common/conf/SecurityConfig.java
0 → 100644
View file @
35feaef5
package
com
.
keymobile
.
rest
.
common
.
conf
;
import
com.keymobile.auth.common.security.CustomizedUserDetailService
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
javax.sql.DataSource
;
@Configuration
@ComponentScan
(
"com.keymobile.auth.common.security"
)
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Autowired
private
CustomizedUserDetailService
customUserDetailService
;
@Value
(
"${security.permit}"
)
private
boolean
permit
=
true
;
@Autowired
private
DataSource
dataSource
;
@Autowired
public
void
configure
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
userDetailsService
(
customUserDetailService
).
passwordEncoder
(
new
SHA1PasswordEncoder
());
}
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
if
(
permit
)
http
.
httpBasic
().
and
().
authorizeRequests
().
anyRequest
().
permitAll
();
else
{
http
.
httpBasic
().
and
().
authorizeRequests
().
anyRequest
().
authenticated
();
}
http
.
csrf
().
disable
();
}
class
SHA1PasswordEncoder
implements
PasswordEncoder
{
@Override
public
String
encode
(
CharSequence
charSequence
)
{
return
DigestUtils
.
sha1Hex
(
charSequence
.
toString
());
}
@Override
public
boolean
matches
(
CharSequence
charSequence
,
String
s
)
{
return
DigestUtils
.
sha1Hex
(
charSequence
.
toString
()).
equals
(
s
);
}
}
}
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