bug修复+代码调整+日志优化
This commit is contained in:
+14
-14
@@ -22,22 +22,22 @@ import org.dromara.maxkey.authn.jwt.AuthTokenService;
|
||||
import org.dromara.maxkey.authn.provider.AbstractAuthenticationProvider;
|
||||
import org.dromara.maxkey.configuration.ApplicationConfig;
|
||||
import org.dromara.maxkey.constants.ConstsLoginType;
|
||||
import org.dromara.maxkey.entity.Institutions;
|
||||
import org.dromara.maxkey.entity.Message;
|
||||
import org.dromara.maxkey.web.WebConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.nimbusds.jwt.SignedJWT;
|
||||
|
||||
|
||||
@Controller
|
||||
@RestController
|
||||
@RequestMapping(value = "/login")
|
||||
public class HttpJwtEntryPoint {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(HttpJwtEntryPoint.class);
|
||||
@@ -54,11 +54,11 @@ public class HttpJwtEntryPoint {
|
||||
@Autowired
|
||||
JwtLoginService jwtLoginService;
|
||||
|
||||
@RequestMapping(value={"/jwt"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@RequestMapping(value={"/jwt"}, produces = {MediaType.APPLICATION_JSON_VALUE},method={RequestMethod.GET,RequestMethod.POST})
|
||||
public Message<AuthJwt> jwt(@RequestParam(value = WebConstants.JWT_TOKEN_PARAMETER, required = true) String jwt) {
|
||||
try {
|
||||
//for jwt Login
|
||||
_logger.debug("jwt : " + jwt);
|
||||
_logger.debug("jwt : {}" , jwt);
|
||||
|
||||
SignedJWT signedJWT = jwtLoginService.jwtTokenValidation(jwt);
|
||||
|
||||
@@ -66,15 +66,15 @@ public class HttpJwtEntryPoint {
|
||||
String username =signedJWT.getJWTClaimsSet().getSubject();
|
||||
LoginCredential loginCredential =new LoginCredential(username,"",ConstsLoginType.JWT);
|
||||
Authentication authentication = authenticationProvider.authenticate(loginCredential,true);
|
||||
_logger.debug("JWT Logined in , username " + username);
|
||||
_logger.debug("JWT Logined in , username {}" , username);
|
||||
AuthJwt authJwt = authTokenService.genAuthJwt(authentication);
|
||||
return new Message<AuthJwt>(authJwt);
|
||||
return new Message<>(authJwt);
|
||||
}
|
||||
}catch(Exception e) {
|
||||
_logger.error("Exception ",e);
|
||||
}
|
||||
|
||||
return new Message<AuthJwt>(Message.FAIL);
|
||||
return new Message<>(Message.FAIL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,25 +82,25 @@ public class HttpJwtEntryPoint {
|
||||
* @param jwt
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value={"/jwt/trust"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@RequestMapping(value={"/jwt/trust"}, produces = {MediaType.APPLICATION_JSON_VALUE},method={RequestMethod.GET,RequestMethod.POST})
|
||||
public Message<AuthJwt> jwtTrust(@RequestParam(value = WebConstants.JWT_TOKEN_PARAMETER, required = true) String jwt) {
|
||||
try {
|
||||
//for jwt Login
|
||||
_logger.debug("jwt : " + jwt);
|
||||
_logger.debug("jwt : {}" , jwt);
|
||||
|
||||
if(authTokenService.validateJwtToken(jwt)) {
|
||||
String username =authTokenService.resolve(jwt).getSubject();
|
||||
LoginCredential loginCredential =new LoginCredential(username,"",ConstsLoginType.JWT);
|
||||
Authentication authentication = authenticationProvider.authenticate(loginCredential,true);
|
||||
_logger.debug("JWT Logined in , username " + username);
|
||||
_logger.debug("JWT Logined in , username {}" , username);
|
||||
AuthJwt authJwt = authTokenService.genAuthJwt(authentication);
|
||||
return new Message<AuthJwt>(authJwt);
|
||||
return new Message<>(authJwt);
|
||||
}
|
||||
}catch(Exception e) {
|
||||
_logger.error("Exception ",e);
|
||||
}
|
||||
|
||||
return new Message<AuthJwt>(Message.FAIL);
|
||||
return new Message<>(Message.FAIL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+8
-8
@@ -78,7 +78,7 @@ public class AuthnProviderAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ScanCodeAuthenticationProvider scanCodeAuthenticationProvider(
|
||||
ScanCodeAuthenticationProvider scanCodeAuthenticationProvider(
|
||||
AbstractAuthenticationRealm authenticationRealm,
|
||||
SessionManager sessionManager
|
||||
) {
|
||||
@@ -89,7 +89,7 @@ public class AuthnProviderAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AppAuthenticationProvider appAuthenticationProvider(
|
||||
AppAuthenticationProvider appAuthenticationProvider(
|
||||
AbstractAuthenticationRealm authenticationRealm,
|
||||
ApplicationConfig applicationConfig,
|
||||
SessionManager sessionManager,
|
||||
@@ -104,7 +104,7 @@ public class AuthnProviderAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MobileAuthenticationProvider mobileAuthenticationProvider(
|
||||
MobileAuthenticationProvider mobileAuthenticationProvider(
|
||||
AbstractAuthenticationRealm authenticationRealm,
|
||||
ApplicationConfig applicationConfig,
|
||||
SmsOtpAuthnService smsAuthnService,
|
||||
@@ -120,7 +120,7 @@ public class AuthnProviderAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TrustedAuthenticationProvider trustedAuthenticationProvider(
|
||||
TrustedAuthenticationProvider trustedAuthenticationProvider(
|
||||
AbstractAuthenticationRealm authenticationRealm,
|
||||
ApplicationConfig applicationConfig,
|
||||
SessionManager sessionManager
|
||||
@@ -134,17 +134,17 @@ public class AuthnProviderAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordPolicyValidator passwordPolicyValidator(JdbcTemplate jdbcTemplate,MessageSource messageSource) {
|
||||
PasswordPolicyValidator passwordPolicyValidator(JdbcTemplate jdbcTemplate,MessageSource messageSource) {
|
||||
return new PasswordPolicyValidator(jdbcTemplate,messageSource);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LoginRepository loginRepository(JdbcTemplate jdbcTemplate) {
|
||||
LoginRepository loginRepository(JdbcTemplate jdbcTemplate) {
|
||||
return new LoginRepository(jdbcTemplate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LoginHistoryRepository loginHistoryRepository(JdbcTemplate jdbcTemplate) {
|
||||
LoginHistoryRepository loginHistoryRepository(JdbcTemplate jdbcTemplate) {
|
||||
return new LoginHistoryRepository(jdbcTemplate);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class AuthnProviderAutoConfiguration {
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public AbstractRemeberMeManager remeberMeManager(
|
||||
AbstractRemeberMeManager remeberMeManager(
|
||||
@Value("${maxkey.server.persistence}") int persistence,
|
||||
@Value("${maxkey.login.remeberme.validity}") int validity,
|
||||
ApplicationConfig applicationConfig,
|
||||
|
||||
+3
-6
@@ -17,8 +17,6 @@
|
||||
|
||||
package org.dromara.maxkey.autoconfigure;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.dromara.maxkey.authn.support.socialsignon.service.JdbcSocialsAssociateService;
|
||||
import org.dromara.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService;
|
||||
import org.dromara.maxkey.authn.support.socialsignon.token.RedisTokenStore;
|
||||
@@ -42,11 +40,10 @@ public class SocialSignOnAutoConfiguration{
|
||||
|
||||
@Bean(name = "socialSignOnProviderService")
|
||||
@ConditionalOnClass(SocialsProvider.class)
|
||||
public SocialSignOnProviderService socialSignOnProviderService(
|
||||
SocialSignOnProviderService socialSignOnProviderService(
|
||||
@Value("${maxkey.server.persistence}") int persistence,
|
||||
JdbcTemplate jdbcTemplate,
|
||||
RedisConnectionFactory redisConnFactory
|
||||
) throws IOException {
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
SocialSignOnProviderService socialSignOnProviderService = new SocialSignOnProviderService(jdbcTemplate);
|
||||
//load default Social Providers from database
|
||||
socialSignOnProviderService.loadSocials("1");
|
||||
@@ -59,7 +56,7 @@ public class SocialSignOnAutoConfiguration{
|
||||
}
|
||||
|
||||
@Bean(name = "socialsAssociateService")
|
||||
public JdbcSocialsAssociateService socialsAssociateService(
|
||||
JdbcSocialsAssociateService socialsAssociateService(
|
||||
JdbcTemplate jdbcTemplate) {
|
||||
JdbcSocialsAssociateService socialsAssociateService = new JdbcSocialsAssociateService(jdbcTemplate);
|
||||
_logger.debug("JdbcSocialsAssociateService inited.");
|
||||
|
||||
Reference in New Issue
Block a user