Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loginservice
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
lanmw
loginservice
Commits
f44f1bc1
Commit
f44f1bc1
authored
Dec 03, 2024
by
linxu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mcd-jdk17' of
ssh://132.232.112.242:7022/lanmw/loginservice
into mcd-jdk17
parents
69922cb7
0a1c6eb3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
154 deletions
+97
-154
LoginManagement.java
src/main/java/com/keymobile/login/api/LoginManagement.java
+2
-1
PeopleCenterApi.java
src/main/java/com/keymobile/login/api/PeopleCenterApi.java
+1
-1
SecurityConfig.java
src/main/java/com/keymobile/login/conf/SecurityConfig.java
+80
-47
SecurityNewConfig.java
...main/java/com/keymobile/login/conf/SecurityNewConfig.java
+0
-91
CustomizedUserDetailServiceImpl.java
...mobile/login/service/CustomizedUserDetailServiceImpl.java
+14
-14
No files found.
src/main/java/com/keymobile/login/api/LoginManagement.java
View file @
f44f1bc1
...
@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.provisioning.UserDetailsManager
;
import
org.springframework.security.web.authentication.WebAuthenticationDetails
;
import
org.springframework.security.web.authentication.WebAuthenticationDetails
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -62,7 +63,7 @@ public class LoginManagement {
...
@@ -62,7 +63,7 @@ public class LoginManagement {
private
AuthService
authService
;
private
AuthService
authService
;
@Autowired
@Autowired
private
CustomizedUserDetailService
customizedUserDetailService
;
private
UserDetailsManager
customizedUserDetailService
;
@Autowired
@Autowired
private
SsoUserRepository
ssoUserRepository
;
private
SsoUserRepository
ssoUserRepository
;
...
...
src/main/java/com/keymobile/login/api/PeopleCenterApi.java
View file @
f44f1bc1
...
@@ -43,7 +43,7 @@ import java.util.concurrent.TimeUnit;
...
@@ -43,7 +43,7 @@ import java.util.concurrent.TimeUnit;
@Tag
(
name
=
"用户中心"
)
@Tag
(
name
=
"用户中心"
)
public
class
PeopleCenterApi
{
public
class
PeopleCenterApi
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
LoginManagement
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
PeopleCenterApi
.
class
);
@Value
(
"${peopleCenter.sysSecret}"
)
@Value
(
"${peopleCenter.sysSecret}"
)
private
String
sysSecret
;
private
String
sysSecret
;
...
...
src/main/java/com/keymobile/login/conf/SecurityConfig.java
View file @
f44f1bc1
//package com.keymobile.login.conf;
package
com
.
keymobile
.
login
.
conf
;
//
//import com.keymobile.auth.common.security.CustomizedUserDetailService;
import
com.keymobile.auth.common.security.CustomizedUserDetailService
;
//import org.springframework.beans.factory.annotation.Autowired;
import
org.apache.commons.codec.digest.DigestUtils
;
//
import
org.springframework.beans.factory.annotation.Autowired
;
//import org.springframework.context.annotation.ComponentScan;
import
org.springframework.beans.factory.annotation.Value
;
//import org.springframework.context.annotation.Configuration;
import
org.springframework.context.annotation.Bean
;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import
org.springframework.context.annotation.ComponentScan
;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import
org.springframework.context.annotation.Configuration
;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
//import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
//
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
//
import
org.springframework.security.crypto.password.NoOpPasswordEncoder
;
//@Configuration
import
org.springframework.security.crypto.password.PasswordEncoder
;
//@ComponentScan("com.keymobile.auth.common.security")
import
org.springframework.security.provisioning.UserDetailsManager
;
//public class SecurityConfig extends WebSecurityConfigurerAdapter {
import
org.springframework.security.web.SecurityFilterChain
;
//
// @Autowired
import
javax.sql.DataSource
;
// private CustomizedUserDetailService customUserDetailService;
// @Autowired
/**
// private RESTAuthenticationEntryPoint authenticationEntryPoint;
* SecurityConfig.
// @Autowired
* @author mahx
// private RESTAuthenticationFailureHandler authenticationFailureHandler;
* @version 1.0
// @Autowired
* @date 2019/12/27 16:55
// private RESTAuthenticationSuccessHandler authenticationSuccessHandler;
*/
// @Autowired
@Configuration
// private RESTLogoutSuccessHandler logoutSuccessHandler;
@EnableWebSecurity
//
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
// @Autowired
@ComponentScan
(
"com.keymobile.auth.common.security"
)
// public void configure(AuthenticationManagerBuilder auth) throws Exception {
public
class
SecurityConfig
{
// auth.userDetailsService(customUserDetailService).passwordEncoder(NoOpPasswordEncoder.getInstance());
// }
@Autowired
//
private
RESTAuthenticationEntryPoint
authenticationEntryPoint
;
// @Override
@Autowired
// protected void configure(HttpSecurity http) throws Exception {
private
RESTAuthenticationFailureHandler
authenticationFailureHandler
;
// http.authorizeRequests().anyRequest().permitAll();
@Autowired
// http.csrf().disable();
private
RESTAuthenticationSuccessHandler
authenticationSuccessHandler
;
// http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint);
@Autowired
// http.formLogin().successHandler(authenticationSuccessHandler);
private
RESTLogoutSuccessHandler
logoutSuccessHandler
;
// http.formLogin().failureHandler(authenticationFailureHandler);
// http.formLogin().loginPage("/login");
@Bean
// http.formLogin().loginProcessingUrl("/signin");
public
UserDetailsManager
users
(
DataSource
dataSource
)
{
// http.logout().logoutUrl("/signout");
return
new
CustomizedUserDetailService
(
dataSource
);
// http.logout().logoutSuccessHandler(logoutSuccessHandler);
}
// }
//
@Bean
//}
public
PasswordEncoder
passwordEncoder
()
{
return
NoOpPasswordEncoder
.
getInstance
();
}
@Bean
protected
SecurityFilterChain
securityFilterChain
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
().
anyRequest
().
permitAll
();
http
.
csrf
().
disable
();
http
.
exceptionHandling
().
authenticationEntryPoint
(
authenticationEntryPoint
);
http
.
formLogin
().
successHandler
(
authenticationSuccessHandler
);
http
.
formLogin
().
failureHandler
(
authenticationFailureHandler
);
http
.
formLogin
().
loginPage
(
"/login"
);
http
.
formLogin
().
loginProcessingUrl
(
"/signin"
);
http
.
logout
().
logoutUrl
(
"/signout"
);
http
.
logout
().
logoutSuccessHandler
(
logoutSuccessHandler
);
return
http
.
build
();
}
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
);
}
}
}
src/main/java/com/keymobile/login/conf/SecurityNewConfig.java
deleted
100644 → 0
View file @
69922cb7
package
com
.
keymobile
.
login
.
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.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.crypto.password.NoOpPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.provisioning.UserDetailsManager
;
import
org.springframework.security.web.SecurityFilterChain
;
import
javax.sql.DataSource
;
/**
* SecurityConfig.
* @author mahx
* @version 1.0
* @date 2019/12/27 16:55
*/
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
@ComponentScan
(
"com.keymobile.auth.common.security"
)
public
class
SecurityNewConfig
{
@Value
(
"${security.permit}"
)
private
boolean
permit
;
@Autowired
private
CustomizedUserDetailService
customUserDetailService
;
@Autowired
private
RESTAuthenticationEntryPoint
authenticationEntryPoint
;
@Autowired
private
RESTAuthenticationFailureHandler
authenticationFailureHandler
;
@Autowired
private
RESTAuthenticationSuccessHandler
authenticationSuccessHandler
;
@Autowired
private
RESTLogoutSuccessHandler
logoutSuccessHandler
;
@Bean
public
UserDetailsManager
users
(
DataSource
dataSource
)
{
return
new
CustomizedUserDetailService
(
dataSource
);
}
@Bean
public
PasswordEncoder
passwordEncoder
()
{
return
NoOpPasswordEncoder
.
getInstance
();
}
@Bean
protected
SecurityFilterChain
securityFilterChain
(
HttpSecurity
http
)
throws
Exception
{
if
(
permit
)
{
http
.
httpBasic
().
and
().
authorizeHttpRequests
().
anyRequest
().
permitAll
();
}
else
{
http
.
httpBasic
().
and
().
authorizeHttpRequests
().
requestMatchers
(
"/actuator/**"
).
permitAll
()
.
and
().
authorizeHttpRequests
().
anyRequest
().
authenticated
();
}
http
.
exceptionHandling
().
authenticationEntryPoint
(
authenticationEntryPoint
);
http
.
formLogin
().
successHandler
(
authenticationSuccessHandler
);
http
.
formLogin
().
failureHandler
(
authenticationFailureHandler
);
http
.
formLogin
().
loginPage
(
"/login"
);
http
.
formLogin
().
loginProcessingUrl
(
"/signin"
);
http
.
logout
().
logoutUrl
(
"/signout"
);
http
.
logout
().
logoutSuccessHandler
(
logoutSuccessHandler
);
http
.
csrf
().
disable
();
return
http
.
build
();
}
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
);
}
}
}
src/main/java/com/keymobile/login/service/CustomizedUserDetailServiceImpl.java
View file @
f44f1bc1
package
com
.
keymobile
.
login
.
service
;
//
package com.keymobile.login.service;
//
import
com.keymobile.auth.common.security.CustomizedUserDetailService
;
//
import com.keymobile.auth.common.security.CustomizedUserDetailService;
import
org.springframework.stereotype.Service
;
//
import org.springframework.stereotype.Service;
//
import
javax.sql.DataSource
;
//
import javax.sql.DataSource;
//
@Service
//
@Service
public
class
CustomizedUserDetailServiceImpl
extends
CustomizedUserDetailService
{
//
public class CustomizedUserDetailServiceImpl extends CustomizedUserDetailService {
//
public
CustomizedUserDetailServiceImpl
(
DataSource
dataSource
)
{
//
public CustomizedUserDetailServiceImpl(DataSource dataSource) {
super
(
dataSource
);
//
super(dataSource);
}
//
}
}
//
}
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