Commit b83284fa by manxiaoqiang

大后台token改为redis存储

parent aec63e4d
......@@ -62,7 +62,18 @@
<mail.valid_time>3</mail.valid_time>
<report.url>http://ec2-54-222-233-230.cn-north-1.compute.amazonaws.com.cn:9010</report.url>
<!--Redis setting-->
<redis.key.validtime>120</redis.key.validtime>
<redis.ip.requesttimes>5</redis.ip.requesttimes>
<redis.ip.unknown.requesttimes>5</redis.ip.unknown.requesttimes>
<redis.surl.host>192.168.2.57</redis.surl.host>
<redis.surl.port>6379</redis.surl.port>
<redis.event.host>192.168.2.57</redis.event.host>
<redis.event.port>6379</redis.event.port>
<redis.event.database>0</redis.event.database>
<!--Redis setting//end-->
</properties>
</profile>
......
package common.controller;
import common.model.Menu;
import com.sun.corba.se.spi.ior.ObjectKey;
import common.model.User;
import common.repository.MenuRepository;
import common.repository.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import security.RedisLoginStatusManager;
import security.TokenManager;
import security.annotation.CurrentAccount;
import util.CipherUtil;
import util.ResultModel;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
@Controller
......@@ -25,19 +32,35 @@ public class LoginController {
@Autowired
private UserRepository userRepository;
@Autowired
RedisLoginStatusManager redisLoginStatusManager;
@Autowired
TokenManager tokenManager;
@RequestMapping(value = "login", method = RequestMethod.GET)
@ResponseBody
public ResultModel login(HttpServletResponse response, @RequestParam String email, @RequestParam String password) {
User user = userRepository.login(email, CipherUtil.generatePassword(password));
if(null != user){
Cookie cookie = new Cookie("TOKEN", user.getId().toString());
//存储token
String token = tokenManager.createToken(String.valueOf(user.getId()));
//存储登陆密码
redisLoginStatusManager.createLoginStatus(token, user.getPassword());
Cookie cookie = new Cookie("TOKEN", token);
cookie.setPath("/");
cookie.setMaxAge(60 * 60 * 24 * 7);
response.addCookie(cookie);
return ResultModel.OK(user);
Map<String, Object> map = new HashMap();
map.put("TOKEN", token);
map.put("user", user);
map.put("code",200);
return ResultModel.OK(map);
}
return ResultModel.OK(false);
Map<String, Object> map = new HashMap();;
map.put("code",300);
return ResultModel.OK(map);
}
@RequestMapping(value = "login/check", method = RequestMethod.GET)
@ResponseBody
......@@ -48,6 +71,17 @@ public class LoginController {
}
return ResultModel.OK(false);
}
@RequestMapping(value = "logout", method = RequestMethod.GET)
@ResponseBody
public ResultModel logout(HttpServletResponse response, @CurrentAccount User user ) {
System.out.println(user);
if (user != null) {
Cookie cookie = new Cookie("TOKEN", user.getId().toString());
cookie.setPath("/");
cookie.setMaxAge(0);
response.addCookie(cookie);
}
return ResultModel.OK(true);
}
}
package security;
import security.exception.MethodNotSupportException;
import java.util.UUID;
public abstract class AbstractTokenManager implements TokenManager {
protected int tokenExpireSeconds = 7 * 24 * 3600;
protected boolean singleTokenWithUser = false;
protected boolean flushExpireAfterOperation = true;
public void setTokenExpireSeconds(int tokenExpireSeconds) {
this.tokenExpireSeconds = tokenExpireSeconds;
}
public void setSingleTokenWithUser(boolean singleTokenWithUser) {
this.singleTokenWithUser = singleTokenWithUser;
}
public void setFlushExpireAfterOperation(boolean flushExpireAfterOperation) {
this.flushExpireAfterOperation = flushExpireAfterOperation;
}
@Override
public void delRelationshipByKey(String key) {
//如果是多个Token关联同一个Key,不允许直接通过Key删除所有Token,防止误操作
if (!singleTokenWithUser) {
throw new MethodNotSupportException("非单点登录时无法调用该方法");
}
delSingleRelationshipByKey(key);
}
/**
* 一个用户只能绑定一个Token时通过Key删除关联关系
* @param key
*/
protected abstract void delSingleRelationshipByKey(String key);
private void createRelationship(String key, String token) {
//根据设置的每个用户是否只允许绑定一个Token,调用不同的方法
if (singleTokenWithUser) {
createSingleRelationship(key, token);
} else {
createMultipleRelationship(key, token);
}
}
/**
* 一个用户可以绑定多个Token时创建关联关系
* @param key
* @param token
*/
protected abstract void createMultipleRelationship(String key, String token);
/**
* 一个用户只能绑定一个Token时创建关联关系
* @param key
* @param token
*/
protected abstract void createSingleRelationship(String key, String token);
@Override
public String getKeyFromToken(String token) {
String key = getKeyByToken(token);
//根据设置,在每次有效操作后刷新过期时间
if (key != null && flushExpireAfterOperation) {
flushExpireAfterOperation(key, token);
}
return key;
}
@Override
public String getTokenFromKey(String key) {
return getTokenByKey(key);
}
@Override
public String createToken(String key) {
final String token = generateToken();
createRelationship(key, token);
return token;
}
protected String generateToken(){
return UUID.randomUUID().toString();
}
/**
* 通过Token获得Key
* @param token
* @return
*/
protected abstract String getKeyByToken(String token);
/**
* 通过key获取token
* @param key
* @return
*/
protected abstract String getTokenByKey(String key);
/**
* 在操作后刷新Token的过期时间
* @param key
* @param token
*/
protected abstract void flushExpireAfterOperation(String key, String token);
}
\ No newline at end of file
package security;
/**
* Created by sunhao on 17/3/3.
*/
public interface RedisLoginStatusManager {
/**
* 根据token和状态在redis中创建登陆状态
*/
void createLoginStatus(String token, String status);
/**
* 根据token删除登陆状态
*/
void deleteLoginStatus(String token);
/**
* 根据token获取登陆密码
*/
String getLoginPassword(String token);
/**
* 根据token获取登陆状态
*/
boolean getLoginStatusByKey(String token);
}
package security;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import util.StringUtil;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
/**
* Created by sunhao on 17/3/3.
*/
@Service
public class RedisLoginStatusManagerImpl implements RedisLoginStatusManager {
protected int tokenExpireSeconds = 7 * 24 * 3600;
@Autowired
private RedisTemplate redisTemplate;
/**
* Redis中记录login密码的Token的前缀
*/
private static final String REDIS_LOGIN_PREFIX = "LOGIN_STATUS_TOKEN_";
@Override
public void createLoginStatus(String token, String pwd) {
String formatToken = formatKey(token);
String loginStatus = getLoginPassword(formatToken);
if(!StringUtil.isEmpty(loginStatus)) {
delete(formatToken);
}
set(formatToken,pwd,tokenExpireSeconds);
}
@Override
public void deleteLoginStatus(String token) {
delete(formatKey(token));
}
@Override
public boolean getLoginStatusByKey(String token) {
String pwd = getLoginPassword(token);
return !StringUtil.isEmpty(pwd);
}
@Override
public String getLoginPassword(String token) {
String pwd = get(formatKey(token));
//每次取的时候重置失效时间
if(!StringUtil.isEmpty(pwd)) {
expire(formatKey(token), tokenExpireSeconds);
}
return pwd;
}
private String formatKey(String token) {
return REDIS_LOGIN_PREFIX.concat(token);
}
/**
* 取redis
*/
private String get(String key) {
return (String) redisTemplate.opsForValue().get(key);
}
/**
* 存redis
*/
private String set(String key, String value, int expireSeconds) {
redisTemplate.opsForValue().set(key, value);
redisTemplate.expire(key, expireSeconds, TimeUnit.SECONDS);
return value;
}
/**
* 设置过期时间
*/
private void expire(String key, int seconds) {
redisTemplate.expire(key, seconds, TimeUnit.SECONDS);
}
/**
* 删除redis记录
*/
private void delete(String... keys) {
redisTemplate.delete(Arrays.asList(keys));
}
}
package security;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Arrays;
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* Created by nolan on 11/11/2016.
* description:
*/
@Service
public class RedisTokenManager extends AbstractTokenManager {
private final String GLOBAL_TOKEN = "GLOBAL_TOKEN";
/**
* Redis中Key的前缀
*/
private static final String REDIS_KEY_PREFIX = "MANAGER_AUTHORIZATION_KEY_";
/**
* Redis中Token的前缀
*/
private static final String REDIS_TOKEN_PREFIX = "MANAGER_AUTHORIZATION_TOKEN_";
/**
* Redis中账户的前缀
*/
private static final String REDIS_ACCOUNT_PREFIX = "MANAGER_AUTHORIZATION_ACCOUNT_";
@Autowired
private RedisTemplate<String, String> redisTemplate;
/**
* 踢出此账号下的所有登陆
*/
@Override
public void delMultiRelationshipByKey(String key) {
if(Strings.isNullOrEmpty(key))
return;
//获取所有登陆TOKEN
Set<String> tokenSet = this.smembers(formatAccountKey(key));
if(!CollectionUtils.isEmpty(tokenSet)){
//删除这些TOKEN
delete(tokenSet);
//删除对应关系
delete(formatAccountKey(key));
}
}
@Override
protected void delSingleRelationshipByKey(String key) {
String token = getToken(key);
if (token != null) {
delete(formatKey(key), formatToken(token));
}
}
/**
* 根据token删掉关系
* @param token
*/
@Override
public void delRelationshipByToken(String token) {
final String formatToken = formatToken(token);
if (singleTokenWithUser) {
String key = getKeyFromToken(token);
delete(formatKey(key), formatToken);
} else {
//删除对应关系中的token
srem(formatAccountKey(get(formatToken)),formatToken);
//删除token
delete(formatToken);
}
}
/**
* 创建单点登陆的登陆关系
* @param key
* @param token
*/
@Override
protected void createSingleRelationship(String key, String token) {
String oldToken = get(formatKey(key));
if (oldToken != null) {
delete(formatToken(oldToken));
}
set(formatToken(token), key, tokenExpireSeconds);
set(formatKey(key), token, tokenExpireSeconds);
}
/**
* 创建多点登陆的登陆关系
* @param key
* @param token
*/
@Override
protected void createMultipleRelationship(String key, String token) {
set(formatToken(token), key, tokenExpireSeconds);
//添加到账户KEY对应的SET中
sadd(formatAccountKey(key), formatToken(token), tokenExpireSeconds);
}
@Override
protected String getKeyByToken(String token) {
return get(formatToken(token));
}
@Override
protected String getTokenByKey(String key) {
return get(formatKey(key));
}
/**
* 操作后刷新登陆关系时长
* @param key
* @param token
*/
@Override
protected void flushExpireAfterOperation(String key, String token) {
if (singleTokenWithUser) {
expire(formatKey(key), tokenExpireSeconds);
}
expire(formatToken(token), tokenExpireSeconds);
//刷新对应关系时长
expire(formatAccountKey(get(formatToken(token))), tokenExpireSeconds);
}
private String get(String key) {
return redisTemplate.opsForValue().get(key);
}
private String set(String key, String value, int expireSeconds) {
redisTemplate.opsForValue().set(key, value);
redisTemplate.expire(key, expireSeconds, TimeUnit.SECONDS);
return value;
}
/**
* 添加value 对于的KEY set
*/
private Long sadd(String key, String value, int expireSeconds){
Long num = redisTemplate.opsForSet().add(key, value);
if(0 != num){
redisTemplate.expire(key, expireSeconds, TimeUnit.SECONDS);
}
return num;
}
/**
* 删除set中的某个
*/
private Long srem(String key, String value){
return redisTemplate.opsForSet().remove(key,value);
}
/**
* 获取set中所有元素
*/
private Set<String> smembers(String key){
return redisTemplate.opsForSet().members(key);
}
private void expire(String key, int seconds) {
redisTemplate.expire(key, seconds, TimeUnit.SECONDS);
}
private void delete(String... keys) {
redisTemplate.delete(Arrays.asList(keys));
}
private void delete(Collection<String> collection){
redisTemplate.delete(collection);
}
private String getToken(String key) {
return get(formatKey(key));
}
private String formatKey(String key) {
return REDIS_KEY_PREFIX.concat(key);
}
private String formatToken(String token) {
return REDIS_TOKEN_PREFIX.concat(token);
}
private String formatAccountKey(String key){
return REDIS_ACCOUNT_PREFIX.concat(key);
}
}
package security;
/**
* Created by nolan on 11/11/2016.
* description:
*/
public interface TokenManager {
void delMultiRelationshipByKey(String key);
/**
* 通过key删除关联关系
*
* @param key
*/
void delRelationshipByKey(String key);
/**
* 通过token删除关联关系
*
* @param token
*/
void delRelationshipByToken(String token);
/**
* 通过token获得对应的key
*
* @param token
* @return
*/
String getKeyFromToken(String token);
/**
* 通过key获得对应token
* @param key
* @return
*/
String getTokenFromKey(String key);
/**
* 根据key生成对应token
* @param key
* @return
*/
String createToken(String key);
}
package security.cors;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Created by sunhao on 17/3/13.
* dec: 设置跨域
*/
public class CorsFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
httpServletResponse.addHeader("Access-Control-Allow-Origin", "*");
if (httpServletRequest.getHeader("Access-Control-Request-Method") != null && "OPTIONS".equals(httpServletRequest.getMethod())) {
httpServletResponse.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
httpServletResponse.addHeader("Access-Control-Allow-Headers", "Authorization, Origin, X-Requested-With, Content-Type, Accept");
httpServletResponse.addHeader("Access-Control-Max-Age", "3600");
}
filterChain.doFilter(httpServletRequest, httpServletResponse);
}
}
package security.exception;
public class MethodNotSupportException extends RuntimeException {
public MethodNotSupportException(String message) {
super(message);
}
}
\ No newline at end of file
......@@ -6,6 +6,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import security.RedisLoginStatusManager;
import security.TokenManager;
import util.Constant;
import util.StringUtil;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
......@@ -18,24 +22,54 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
@Autowired
private UserRepository userRepository;
@Autowired
private TokenManager manager;
@Autowired
private RedisLoginStatusManager redisLoginStatusManager;
//鉴权信息的无用前缀,默认为空
private String httpHeaderPrefix = "";
public void setHttpHeaderName(String httpHeaderName) {
this.httpHeaderName = httpHeaderName;
}
public void setHttpHeaderPrefix(String httpHeaderPrefix) {
this.httpHeaderPrefix = httpHeaderPrefix;
}
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
//放开登录
if (request.getRequestURL().indexOf("login/login") != -1){
return true;
}
//从header中得到token
String token = request.getHeader(httpHeaderName);
System.out.println(token);
String id = getCookieToken(request.getCookies(), "TOKEN");
if(null != id){
User account = userRepository.findOne(Long.parseLong(id));
User sessionAct = (User) request.getSession().getAttribute("$CURRENT_ACCOUNT$");
if (sessionAct == null || !account.getId().equals(sessionAct.getId())) {
request.getSession().setAttribute("$CURRENT_ACCOUNT$", account);
token = StringUtil.isEmpty(token) ? getCookieToken(request.getCookies(), "TOKEN") : token;
token = token.substring(httpHeaderPrefix.length());
//验证token
String key = manager.getKeyFromToken(token);
//登陆状态
boolean loginStatus = redisLoginStatusManager.getLoginStatusByKey(token);
if (!StringUtil.isEmpty(key)) {
String id = getCookieToken(request.getCookies(), "TOKEN");
User one = userRepository.findOne(Long.parseLong(key));
User sessionAct = (User) request.getSession().getAttribute(Constant.CURRENT_ACCOUNT);
if (sessionAct == null) {
request.getSession().setAttribute(Constant.CURRENT_ACCOUNT,one);
}
return true;
}
/* if(null != id){
User account = userRepository.findOne(Long.parseLong(id));
User sessionAct = (User) request.getSession().getAttribute("$CURRENT_ACCOUNT$");
if (sessionAct == null || !account.getId().equals(sessionAct.getId())) {
request.getSession().setAttribute("$CURRENT_ACCOUNT$", account);
}*/
return true;
}
return false;
}
......
......@@ -16,14 +16,18 @@ import util.ResultModel;
@RequestMapping("marketing/accountmng/tkio")
public class TkioAccountController {
@RequestMapping(value = "/find", method = RequestMethod.GET)
@Autowired
TkioAccountService tkioAccountService;
//客户列表
@RequestMapping(value = "/findAll", method = RequestMethod.GET)
@ResponseBody
public ResultModel find(@CurrentAccount User loginAccount) {
return ResultModel.OK();
return ResultModel.OK(tkioAccountService.findAll(loginAccount));
}
@RequestMapping(value = "/delete", method = RequestMethod.GET)
//关闭到期提醒
@RequestMapping(value = "/forbiden/{id}", method = RequestMethod.PUT)
@ResponseBody
public ResultModel delete(@CurrentAccount User loginAccount, @RequestBody User resource) {
......
......@@ -10,4 +10,11 @@ import java.util.List;
*/
public interface TkioAccountService {
List<Account4Web> findAll(User user);
//到期提醒关闭
Account4Web forbiden(User user, Long accountId);
//到期提醒开启
Account4Web enable(User user, Long accountId);
}
......@@ -25,7 +25,7 @@ import java.util.Map;
/**
* Created by mxq on 2017/12/26.
*/
@Service
public class TkioAccountServiceImpl implements TkioAccountService {
@Autowired
......@@ -92,6 +92,17 @@ public class TkioAccountServiceImpl implements TkioAccountService {
}
return result;
}
@Override
public Account4Web forbiden(User user, Long accountId) {
return null;
}
@Override
public Account4Web enable(User user, Long accountId) {
return null;
}
public Map<String, Integer> getBackTime(){
Map<String, Integer> map = new HashMap<>();
List<BackVisit> all = backVisitRepository.findAll();
......
......@@ -22,6 +22,12 @@ public class Constant {
public static ResourceBundle commonBundle = ResourceBundle.getBundle("common");
public static String reportUrl = commonBundle.getString("report.url");
public static ResourceBundle redis = ResourceBundle.getBundle("redis");
public static String REDIS_KEY_VALID_TIME = redis.getString("redis.key.validtime");
public static String REDIS_IP_REQUEST_TIMES = redis.getString("redis.ip.requesttimes");
public static String REDIS_IP_UNKNOWN_REQUEST_TIMES = redis.getString("redis.ip.unknown.requesttimes");
......
package util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
/**
* 单节点Jedis.
* @author Administrator
*
*/
public class RedisUtilNew {
protected static Logger logger = LoggerFactory.getLogger(RedisUtilNew.class);
private static RedisUtilNew redisUtil = new RedisUtilNew();
private JedisPool pool;
//
// private ResourceBundle resourceBundle;
private RedisUtilNew() {
ResourceBundle resourceBundle = ResourceBundle.getBundle("redis");
pool = new JedisPool(resourceBundle.getString("redis.surl.host"),
Integer.valueOf(resourceBundle.getString("redis.surl.port")));
}
public static RedisUtilNew getInstance() {
return redisUtil;
}
public Map<String, String> hgetAll(String key) {
Map<String, String> result = new HashMap<String, String>();
Jedis jedis = pool.getResource();
result = jedis.hgetAll(key);
pool.returnResource(jedis);
return result;
}
public void hsetAll(String key, Map<String, String> map) {
Jedis jedis = pool.getResource();
jedis.hmset(key, map);
pool.returnResource(jedis);
}
public void delete(String key) {
Jedis jedis = pool.getResource();
jedis.del(key);
pool.returnResource(jedis);
}
/**
* 取值
*
* @param key
* @return
*/
public String get(String key) {
Jedis jedis = pool.getResource();
try {
String result = jedis.get(key);
if (result == null) {
return null;
}
return result;
} finally {
pool.returnResource(jedis);
}
}
/**
* 向redis中写入数据
* @param key
* @param value
*/
public void set(String key,String value)
{
Jedis jedis = pool.getResource();
jedis.set(key,value);
pool.returnResource(jedis);
}
public Long getExpireTime(String key)
{
Jedis jedis = pool.getResource();
Long m = jedis.ttl(key);
pool.returnResource(jedis);
return m;
}
/**
* 加锁.
*
* @param key
* @param expireTime
* 超时时间单位秒.
* @return 锁定的value,返回null值加锁失败,供释放锁时使用.
*/
public String tryLock(String key, int expireTime) {
Jedis jedis = pool.getResource();
try {
String value = Long.toString(System.currentTimeMillis() + (expireTime * 1000));
String result = jedis.set(key, value, "NX", "EX", expireTime);
if (result == null) {
return null;
}
return value;
} finally {
pool.returnResource(jedis);
}
}
public String expireValue(String key, String value, int expireTime)
{
Jedis jedis = pool.getResource();
try {
String result = jedis.set(key, value, "NX", "EX", expireTime);
if (result == null) {
return null;
}
return value;
} finally {
pool.returnResource(jedis);
}
}
public void releaseLock(String key) {
Jedis jedis = pool.getResource();
try {
Set<String> set = jedis.keys(key);
String[] kk = new String[set.size()];
jedis.del(set.toArray(kk));
} catch (Exception e) {
e.printStackTrace();
} finally {
pool.returnResource(jedis);
}
}
public static void main(String[] args) {
RedisUtilNew redisUtilNew = RedisUtilNew.getInstance();
//redisUtilNew.expireValue("test005","12",1000);
Long outtime = redisUtilNew.getExpireTime("test005");
redisUtilNew.delete("test005");
redisUtilNew.expireValue("test005","12",outtime.intValue());
System.out.println(outtime);
}
}
......@@ -21,8 +21,25 @@
<context:component-scan base-package="tkio" />
<context:component-scan base-package="track" />
<context:component-scan base-package="common" />
<context:component-scan base-package="security" />
<context:property-placeholder location="classpath:persistence.properties"/>
<context:property-placeholder location="classpath:redis.properties" />
<!--Redis配置-->
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="300" />
<property name="maxTotal" value="600" />
<property name="maxWaitMillis" value="1000"></property>
<property name="testOnBorrow" value="true" />
</bean>
<bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:hostName="${redis.surl.host}" p:port="${redis.surl.port}" p:poolConfig-ref="poolConfig"/>
<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
<!--//Redis配置 -->
<bean id="parentDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="driverClassName" value="${dataSource.driverClassName}"/>
......
# Redis common settings
redis.key.validtime=${redis.key.validtime}
redis.ip.requesttimes=${redis.ip.requesttimes}
redis.ip.unknown.requesttimes=${redis.ip.unknown.requesttimes}
redis.maxIdle=300
redis.testOnBorrow=true
# token
redis.surl.host=${redis.surl.host}
redis.surl.port=${redis.surl.port}
# event
redis.event.host=${redis.event.host}
redis.event.port=${redis.event.port}
redis.event.database=${redis.event.database}
......@@ -51,6 +51,15 @@
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>cors</filter-name>
<filter-class>security.cors.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cors</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>/home.html</welcome-file>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment