Lierbao 1 år sedan
förälder
incheckning
447e8e3121
3 ändrade filer med 108 tillägg och 0 borttagningar
  1. +49
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/config/RedisSessionConfig.java
  2. +47
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/constants/AuthTypeEnum.java
  3. +12
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/constants/SessionTimeConstant.java

+ 49
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/config/RedisSessionConfig.java Visa fil

@@ -0,0 +1,49 @@
//package com.ningdatech.pmapi.user.security.auth.config;
//
//import com.ningdatech.basic.util.StrPool;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
///**
// * <p>
// * 设置session的过期时间为一天
// * </p>
// *
// * @Author LiuXinXin
// * @Date 2020/7/29 9:46 上午
// * @Version 1.0
// **/
//@Configuration
//@EnableRedisHttpSession(
// maxInactiveIntervalInSeconds = RedisSessionConfig.SESSION_TIMEOUT,
// redisNamespace = RedisSessionConfig.REDIS_NAMESPACE
//)
//public class RedisSessionConfig {
//
// static final int SESSION_TIMEOUT = 24 * 60 * 60 * 10;
//
// static final String REDIS_NAMESPACE = "#{redisSessionConfig.getRedisNamespace()}";
//
// @Value("${nd.cache.def.keyPrefix:}")
// private String keyPrefix;
//
// public String getRedisNamespace() {
// return (StrUtils.isBlank(keyPrefix) ? StrPool.EMPTY : keyPrefix + StrPool.COLON) + RedisIndexedSessionRepository.DEFAULT_NAMESPACE;
// }
//
// @Bean
// public CookieHttpSessionIdResolver sessionIdResolver() {
// // 创建 CookieHttpSessionIdResolver 对象
// CookieHttpSessionIdResolver sessionIdResolver = new CookieHttpSessionIdResolver();
// // 创建 DefaultCookieSerializer 对象
// DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
//
// // 设置到 sessionIdResolver 中
// sessionIdResolver.setCookieSerializer(cookieSerializer);
// cookieSerializer.setCookieName(BizConst.COOKIE_KEY);
// cookieSerializer.setCookieMaxAge(SessionTimeConstant.SESSION_TIME_SECONDS);
// return sessionIdResolver;
// }
//
//}

+ 47
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/constants/AuthTypeEnum.java Visa fil

@@ -0,0 +1,47 @@
package com.ningdatech.pmapi.user.security.auth.constants;

/**
* @author Liuxinxin
* @date 2021/7/30 下午2:10
*/

public enum AuthTypeEnum {

/**
* 手机 + 密码的认证方式
*/
PHONE_PASSWORD("phone_password"),

/**
* 子账号 账号 + 密码的认证方式
*/
ACCOUNT_PASSWORD("account_password");

private final String key;

AuthTypeEnum(String key) {
this.key = key;
}

public static boolean contains(String key) {
for (AuthTypeEnum value : AuthTypeEnum.values()) {
if (key.equals(value.getKey())) {
return true;
}
}
return false;
}

public String getKey() {
return key;
}

public static AuthTypeEnum of(String key) {
for (AuthTypeEnum value : AuthTypeEnum.values()) {
if (key.equals(value.getKey())) {
return value;
}
}
throw new RuntimeException(String.format("invalid AuthTypeEnum = %s", key));
}
}

+ 12
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/constants/SessionTimeConstant.java Visa fil

@@ -0,0 +1,12 @@
package com.ningdatech.pmapi.user.security.auth.constants;

/**
* @Author LiuXinXin
* @Date 2022/2/17 12:59 上午
* @Version 1.0
**/
public class SessionTimeConstant {

public static final Integer SESSION_TIME_SECONDS = 24 * 60 * 60 * 10;

}

Laddar…
Avbryt
Spara