mirror of https://gitee.com/stylefeng/roses
【7.1.6】去除广告修改&帐号错误检测开关改为config配置
parent
ae24582306
commit
e99ee5d137
|
@ -0,0 +1,22 @@
|
|||
package cn.stylefeng.roses.kernel.auth.api.expander;
|
||||
|
||||
import cn.stylefeng.roses.kernel.config.api.context.ConfigContext;
|
||||
|
||||
/**
|
||||
* 登录相关配置快速获取
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/1/24 15:47
|
||||
*/
|
||||
public class LoginConfigExpander {
|
||||
|
||||
/**
|
||||
* 获取帐号错误次数校验开关
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/1/24 15:48
|
||||
*/
|
||||
public static boolean getAccountErrorDetectionFlag() {
|
||||
return ConfigContext.me().getSysConfigValueWithDefault("ACCOUNT_ERROR_DETECTION", Boolean.class, false);
|
||||
}
|
||||
}
|
|
@ -24,7 +24,6 @@
|
|||
*/
|
||||
package cn.stylefeng.roses.kernel.auth.auth;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
|
@ -42,6 +41,7 @@ import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
|||
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
|
||||
import cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.auth.api.expander.AuthConfigExpander;
|
||||
import cn.stylefeng.roses.kernel.auth.api.expander.LoginConfigExpander;
|
||||
import cn.stylefeng.roses.kernel.auth.api.password.PasswordStoredEncryptApi;
|
||||
import cn.stylefeng.roses.kernel.auth.api.password.PasswordTransferEncryptApi;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.SsoProperties;
|
||||
|
@ -49,9 +49,7 @@ import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginRequest;
|
|||
import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginResponse;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginWithTokenRequest;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.auth.session.cache.loginuser.RedisLoginUserCache;
|
||||
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||
import cn.stylefeng.roses.kernel.cache.memory.operator.DefaultMemoryCacheOperator;
|
||||
import cn.stylefeng.roses.kernel.demo.expander.DemoConfigExpander;
|
||||
import cn.stylefeng.roses.kernel.jwt.JwtTokenOperator;
|
||||
import cn.stylefeng.roses.kernel.jwt.api.context.JwtContext;
|
||||
|
@ -77,7 +75,6 @@ import cn.stylefeng.roses.kernel.validator.api.exception.enums.ValidatorExceptio
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -133,9 +130,6 @@ public class AuthServiceImpl implements AuthServiceApi {
|
|||
@Resource
|
||||
private CacheOperatorApi<String> loginCacheOperatorApi;
|
||||
|
||||
@Value("${login.enable}")
|
||||
private Boolean enable;
|
||||
|
||||
@Override
|
||||
public LoginResponse login(LoginRequest loginRequest) {
|
||||
return loginAction(loginRequest, true, null);
|
||||
|
@ -273,7 +267,7 @@ public class AuthServiceImpl implements AuthServiceApi {
|
|||
private LoginResponse loginAction(LoginRequest loginRequest, Boolean validatePassword, String caToken) {
|
||||
SysUser userByAccount = sysUserService.getUserByAccount(loginRequest.getAccount());
|
||||
// 判断登录错误检测是否开启
|
||||
if (enable) {
|
||||
if (LoginConfigExpander.getAccountErrorDetectionFlag()) {
|
||||
// 判断错误次数,超过最大放入缓存中
|
||||
if (StrUtil.isBlank(loginCacheOperatorApi.get(userByAccount.getUserId().toString()))) {
|
||||
if (userByAccount.getLoginCount() > LoginCacheConstants.MAX_LOGIN_COUNT) {
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package cn.stylefeng.roses.kernel.auth.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 控制帐号错误检测开关
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/1/23 23:42
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "login")
|
||||
public class AccountErrorDetectionConfig {
|
||||
|
||||
/**
|
||||
* 开关:true-开启错误检测,false-关闭错误检测
|
||||
*/
|
||||
private Boolean enable;
|
||||
}
|
|
@ -37,12 +37,6 @@
|
|||
<artifactId>db-sdk-flyway</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.2.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,38 +1,29 @@
|
|||
package cn.stylefeng.roses.kernel.db.starter;
|
||||
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.druid.DruidProperties;
|
||||
import com.alibaba.druid.util.Utils;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.*;
|
||||
import java.io.IOException;
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnWebApplication
|
||||
@AutoConfigureAfter(DruidDataSourceAutoConfigure.class)
|
||||
@ConditionalOnProperty(name = "spring.datasource.druid.stat-view-servlet.enabled", havingValue = "true", matchIfMissing = true)
|
||||
@AutoConfigureBefore(DataSourceAutoConfiguration.class)
|
||||
public class RemoveDruidAdConfig {
|
||||
|
||||
|
||||
/**
|
||||
* 方法名: removeDruidAdFilterRegistrationBean
|
||||
* 方法描述: 除去页面底部的广告
|
||||
* @param properties
|
||||
* @return org.springframework.boot.web.servlet.FilterRegistrationBean
|
||||
* @throws
|
||||
* 除去页面底部的广告
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/1/24 15:23
|
||||
*/
|
||||
@Bean
|
||||
public FilterRegistrationBean removeDruidAdFilterRegistrationBean(DruidStatProperties properties) {
|
||||
// 获取web监控页面的参数
|
||||
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
|
||||
public FilterRegistrationBean removeDruidAdFilterRegistrationBean() {
|
||||
// 提取common.js的配置路径
|
||||
String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*";
|
||||
String pattern = "/druid/*";
|
||||
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
|
||||
|
||||
final String filePath = "support/http/resources/js/common.js";
|
||||
|
|
Loading…
Reference in New Issue