6 files added
2 files renamed
25 files modified
| | |
| | | import org.springframework.cloud.openfeign.FeignClient;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.bind.annotation.RequestHeader;
|
| | | import com.ruoyi.common.core.constant.SecurityConstants;
|
| | | import com.ruoyi.common.core.constant.ServiceNameConstants;
|
| | | import com.ruoyi.common.core.domain.R;
|
| | | import com.ruoyi.system.api.domain.SysLogininfor;
|
| | | import com.ruoyi.system.api.domain.SysOperLog;
|
| | | import com.ruoyi.system.api.factory.RemoteLogFallbackFactory;
|
| | |
|
| | |
| | | * 保存系统日志
|
| | | *
|
| | | * @param sysOperLog 日志实体
|
| | | * @param source 请求来源
|
| | | * @return 结果
|
| | | */
|
| | | @PostMapping("/operlog")
|
| | | R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog);
|
| | | public R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
| | |
|
| | | /**
|
| | | * 保存访问记录
|
| | | *
|
| | | * @param username 用户名称
|
| | | * @param status 状态
|
| | | * @param message 消息
|
| | | * @param sysLogininfor 访问实体
|
| | | * @param source 请求来源
|
| | | * @return 结果
|
| | | */
|
| | | @PostMapping("/logininfor")
|
| | | R<Boolean> saveLogininfor(@RequestParam("username") String username, @RequestParam("status") String status,
|
| | | @RequestParam("message") String message);
|
| | | public R<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
| | | }
|
| | |
| | | import org.springframework.cloud.openfeign.FeignClient;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestHeader;
|
| | | import com.ruoyi.common.core.constant.SecurityConstants;
|
| | | import com.ruoyi.common.core.constant.ServiceNameConstants;
|
| | | import com.ruoyi.common.core.domain.R;
|
| | | import com.ruoyi.system.api.domain.SysUser;
|
| | | import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
|
| | | import com.ruoyi.system.api.model.LoginUser;
|
| | |
|
| | |
| | | * 通过用户名查询用户信息
|
| | | *
|
| | | * @param username 用户名
|
| | | * @param source 请求来源
|
| | | * @return 结果
|
| | | */
|
| | | @GetMapping(value = "/user/info/{username}")
|
| | | public R<LoginUser> getUserInfo(@PathVariable("username") String username);
|
| | | @GetMapping("/user/info/{username}")
|
| | | public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
| | |
|
| | | /**
|
| | | * 注册用户信息
|
| | | *
|
| | | * @param sysUser 用户信息
|
| | | * @param source 请求来源
|
| | | * @return 结果
|
| | | */
|
| | | @PostMapping("/user/register")
|
| | | public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
| | | }
|
| File was renamed from ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java |
| | |
| | | package com.ruoyi.system.domain;
|
| | | package com.ruoyi.system.api.domain;
|
| | |
|
| | | import java.util.Date;
|
| | | import com.fasterxml.jackson.annotation.JsonFormat;
|
| | |
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.core.domain.R;
|
| | | import com.ruoyi.system.api.RemoteLogService;
|
| | | import com.ruoyi.system.api.domain.SysLogininfor;
|
| | | import com.ruoyi.system.api.domain.SysOperLog;
|
| | |
|
| | | /**
|
| | |
| | | return new RemoteLogService()
|
| | | {
|
| | | @Override
|
| | | public R<Boolean> saveLog(SysOperLog sysOperLog)
|
| | | public R<Boolean> saveLog(SysOperLog sysOperLog, String source)
|
| | | {
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public R<Boolean> saveLogininfor(String username, String status, String message)
|
| | | public R<Boolean> saveLogininfor(SysLogininfor sysLogininfor, String source)
|
| | | {
|
| | | return null;
|
| | | }
|
| | |
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.core.domain.R;
|
| | | import com.ruoyi.system.api.RemoteUserService;
|
| | | import com.ruoyi.system.api.domain.SysUser;
|
| | | import com.ruoyi.system.api.model.LoginUser;
|
| | |
|
| | | /**
|
| | |
| | | return new RemoteUserService()
|
| | | {
|
| | | @Override
|
| | | public R<LoginUser> getUserInfo(String username)
|
| | | public R<LoginUser> getUserInfo(String username, String source)
|
| | | {
|
| | | return R.fail("获取用户失败:" + throwable.getMessage());
|
| | | }
|
| | |
|
| | | @Override
|
| | | public R<Boolean> registerUserInfo(SysUser sysUser, String source)
|
| | | {
|
| | | return R.fail("注册用户失败:" + throwable.getMessage());
|
| | | }
|
| | | };
|
| | | }
|
| | | }
|
| | |
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.auth.form.LoginBody;
|
| | | import com.ruoyi.auth.form.RegisterBody;
|
| | | import com.ruoyi.auth.service.SysLoginService;
|
| | | import com.ruoyi.common.core.domain.R;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | |
| | | }
|
| | | return R.ok();
|
| | | }
|
| | |
|
| | | @PostMapping("register")
|
| | | public R<?> register(@RequestBody RegisterBody registerBody)
|
| | | {
|
| | | // 用户注册
|
| | | sysLoginService.register(registerBody.getUsername(), registerBody.getPassword());
|
| | | return R.ok();
|
| | | }
|
| | | }
|
| New file |
| | |
| | | package com.ruoyi.auth.form;
|
| | |
|
| | | /**
|
| | | * 用户注册对象
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class RegisterBody extends LoginBody
|
| | | {
|
| | |
|
| | | }
|
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.enums.UserStatus; |
| | | import com.ruoyi.common.core.exception.BaseException; |
| | | import com.ruoyi.common.core.utils.SecurityUtils; |
| | | import com.ruoyi.common.core.utils.ServletUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.ip.IpUtils; |
| | | import com.ruoyi.system.api.RemoteLogService; |
| | | import com.ruoyi.system.api.RemoteUserService; |
| | | import com.ruoyi.system.api.domain.SysLogininfor; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | |
| | |
| | | // 用户名或密码为空 错误 |
| | | if (StringUtils.isAnyBlank(username, password)) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写"); |
| | | recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写"); |
| | | throw new BaseException("用户/密码必须填写"); |
| | | } |
| | | // 密码如果不在指定范围内 错误 |
| | | if (password.length() < UserConstants.PASSWORD_MIN_LENGTH |
| | | || password.length() > UserConstants.PASSWORD_MAX_LENGTH) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围"); |
| | | recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围"); |
| | | throw new BaseException("用户密码不在指定范围"); |
| | | } |
| | | // 用户名不在指定范围内 错误 |
| | | if (username.length() < UserConstants.USERNAME_MIN_LENGTH |
| | | || username.length() > UserConstants.USERNAME_MAX_LENGTH) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围"); |
| | | recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围"); |
| | | throw new BaseException("用户名不在指定范围"); |
| | | } |
| | | // 查询用户信息 |
| | | R<LoginUser> userResult = remoteUserService.getUserInfo(username); |
| | | R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); |
| | | |
| | | if (R.FAIL == userResult.getCode()) |
| | | { |
| | |
| | | |
| | | if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); |
| | | recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); |
| | | throw new BaseException("登录用户:" + username + " 不存在"); |
| | | } |
| | | LoginUser userInfo = userResult.getData(); |
| | | SysUser user = userResult.getData().getSysUser(); |
| | | if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); |
| | | |
| | | recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); |
| | | throw new BaseException("对不起,您的账号:" + username + " 已被删除"); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(user.getStatus())) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); |
| | | recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); |
| | | throw new BaseException("对不起,您的账号:" + username + " 已停用"); |
| | | } |
| | | if (!SecurityUtils.matchesPassword(password, user.getPassword())) |
| | | { |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "用户密码错误"); |
| | | recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码错误"); |
| | | throw new BaseException("用户不存在/密码错误"); |
| | | } |
| | | remoteLogService.saveLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); |
| | | recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); |
| | | return userInfo; |
| | | } |
| | | |
| | | public void logout(String loginName) |
| | | { |
| | | remoteLogService.saveLogininfor(loginName, Constants.LOGOUT, "退出成功"); |
| | | recordLogininfor(loginName, Constants.LOGOUT, "退出成功"); |
| | | } |
| | | |
| | | /** |
| | | * 注册 |
| | | */ |
| | | public void register(String username, String password) |
| | | { |
| | | // 用户名或密码为空 错误 |
| | | if (StringUtils.isAnyBlank(username, password)) |
| | | { |
| | | throw new BaseException("用户/密码必须填写"); |
| | | } |
| | | if (username.length() < UserConstants.USERNAME_MIN_LENGTH |
| | | || username.length() > UserConstants.USERNAME_MAX_LENGTH) |
| | | { |
| | | throw new BaseException("账户长度必须在2到20个字符之间"); |
| | | } |
| | | if (password.length() < UserConstants.PASSWORD_MIN_LENGTH |
| | | || password.length() > UserConstants.PASSWORD_MAX_LENGTH) |
| | | { |
| | | throw new BaseException("密码长度必须在5到20个字符之间"); |
| | | } |
| | | |
| | | // 注册用户信息 |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.setUserName(username); |
| | | sysUser.setNickName(username); |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(password)); |
| | | R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER); |
| | | |
| | | if (R.FAIL == registerResult.getCode()) |
| | | { |
| | | throw new BaseException(registerResult.getMsg()); |
| | | } |
| | | recordLogininfor(username, Constants.REGISTER, "注册成功"); |
| | | } |
| | | |
| | | /** |
| | | * 记录登录信息 |
| | | * |
| | | * @param username 用户名 |
| | | * @param status 状态 |
| | | * @param message 消息内容 |
| | | * @return |
| | | */ |
| | | public void recordLogininfor(String username, String status, String message) |
| | | { |
| | | SysLogininfor logininfor = new SysLogininfor(); |
| | | logininfor.setUserName(username); |
| | | logininfor.setIpaddr(IpUtils.getIpAddr(ServletUtils.getRequest())); |
| | | logininfor.setMsg(message); |
| | | // 日志状态 |
| | | if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER)) |
| | | { |
| | | logininfor.setStatus("0"); |
| | | } |
| | | else if (Constants.LOGIN_FAIL.equals(status)) |
| | | { |
| | | logininfor.setStatus("1"); |
| | | } |
| | | remoteLogService.saveLogininfor(logininfor, SecurityConstants.INNER); |
| | | } |
| | | } |
| | |
| | | public class CacheConstants
|
| | | {
|
| | | /**
|
| | | * 令牌自定义标识
|
| | | */
|
| | | public static final String TOKEN_AUTHENTICATION = "Authorization";
|
| | |
|
| | | /**
|
| | | * 令牌前缀
|
| | | */
|
| | | public static final String TOKEN_PREFIX = "Bearer ";
|
| | |
|
| | | /**
|
| | | * 权限缓存前缀
|
| | | */
|
| | | public final static String LOGIN_TOKEN_KEY = "login_tokens:";
|
| | |
|
| | | /**
|
| | | * 用户ID字段
|
| | | */
|
| | | public static final String DETAILS_USER_ID = "user_id";
|
| | |
|
| | | /**
|
| | | * 用户名字段
|
| | | */
|
| | | public static final String DETAILS_USERNAME = "username";
|
| | |
|
| | | /**
|
| | | * 授权信息字段
|
| | | */
|
| | | public static final String AUTHORIZATION_HEADER = "authorization";
|
| | | }
|
| New file |
| | |
| | | package com.ruoyi.common.core.constant;
|
| | |
|
| | | /**
|
| | | * 权限相关通用常量
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class SecurityConstants
|
| | | {
|
| | | /**
|
| | | * 令牌自定义标识
|
| | | */
|
| | | public static final String TOKEN_AUTHENTICATION = "Authorization";
|
| | |
|
| | | /**
|
| | | * 令牌前缀
|
| | | */
|
| | | public static final String TOKEN_PREFIX = "Bearer ";
|
| | |
|
| | | /**
|
| | | * 用户ID字段
|
| | | */
|
| | | public static final String DETAILS_USER_ID = "user_id";
|
| | |
|
| | | /**
|
| | | * 用户名字段
|
| | | */
|
| | | public static final String DETAILS_USERNAME = "username";
|
| | |
|
| | | /**
|
| | | * 授权信息字段
|
| | | */
|
| | | public static final String AUTHORIZATION_HEADER = "authorization";
|
| | |
|
| | | /**
|
| | | * 请求来源
|
| | | */
|
| | | public static final String FROM_SOURCE = "from-source";
|
| | |
|
| | | /**
|
| | | * 内部请求
|
| | | */
|
| | | public static final String INNER = "inner";
|
| | | }
|
| New file |
| | |
| | | package com.ruoyi.common.core.exception;
|
| | |
|
| | | /**
|
| | | * 内部认证异常
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | public class InnerAuthException extends RuntimeException
|
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public InnerAuthException(String message)
|
| | | {
|
| | | super(message);
|
| | | }
|
| | | }
|
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static String getUsername() |
| | | { |
| | | String username = ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USERNAME); |
| | | String username = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USERNAME); |
| | | return ServletUtils.urlDecode(username); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static Long getUserId() |
| | | { |
| | | return Convert.toLong(ServletUtils.getRequest().getHeader(CacheConstants.DETAILS_USER_ID)); |
| | | return Convert.toLong(ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USER_ID)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static String getToken(HttpServletRequest request) |
| | | { |
| | | String token = request.getHeader(CacheConstants.TOKEN_AUTHENTICATION); |
| | | String token = request.getHeader(SecurityConstants.TOKEN_AUTHENTICATION); |
| | | return replaceTokenPrefix(token); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static String replaceTokenPrefix(String token) |
| | | { |
| | | if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX)) |
| | | if (StringUtils.isNotEmpty(token) && token.startsWith(SecurityConstants.TOKEN_PREFIX)) |
| | | { |
| | | token = token.replace(CacheConstants.TOKEN_PREFIX, ""); |
| | | token = token.replace(SecurityConstants.TOKEN_PREFIX, ""); |
| | | } |
| | | return token; |
| | | } |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.scheduling.annotation.Async;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.common.core.constant.SecurityConstants;
|
| | | import com.ruoyi.system.api.RemoteLogService;
|
| | | import com.ruoyi.system.api.domain.SysOperLog;
|
| | |
|
| | |
| | | @Async
|
| | | public void saveSysLog(SysOperLog sysOperLog)
|
| | | {
|
| | | remoteLogService.saveLog(sysOperLog);
|
| | | remoteLogService.saveLog(sysOperLog, SecurityConstants.INNER);
|
| | | }
|
| | | }
|
| New file |
| | |
| | | package com.ruoyi.common.security.annotation;
|
| | |
|
| | | import java.lang.annotation.*;
|
| | |
|
| | | /**
|
| | | * 内部认证注解
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Target(ElementType.METHOD)
|
| | | @Retention(RetentionPolicy.RUNTIME)
|
| | | @Documented
|
| | | public @interface InnerAuth
|
| | | {
|
| | | /**
|
| | | * 是否校验用户信息
|
| | | */
|
| | | boolean isUser() default false;
|
| | | } |
| New file |
| | |
| | | package com.ruoyi.common.security.aspect;
|
| | |
|
| | | import org.aspectj.lang.ProceedingJoinPoint;
|
| | | import org.aspectj.lang.annotation.Around;
|
| | | import org.aspectj.lang.annotation.Aspect;
|
| | | import org.springframework.core.Ordered;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.core.constant.SecurityConstants;
|
| | | import com.ruoyi.common.core.exception.InnerAuthException;
|
| | | import com.ruoyi.common.core.utils.ServletUtils;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | | import com.ruoyi.common.security.annotation.InnerAuth;
|
| | |
|
| | | /**
|
| | | * 内部服务调用验证处理
|
| | | * |
| | | * @author ruoyi
|
| | | */
|
| | | @Aspect
|
| | | @Component
|
| | | public class InnerAuthAspect implements Ordered
|
| | | {
|
| | | @Around("@annotation(innerAuth)")
|
| | | public Object innerAround(ProceedingJoinPoint point, InnerAuth innerAuth) throws Throwable
|
| | | {
|
| | | String source = ServletUtils.getRequest().getHeader(SecurityConstants.FROM_SOURCE);
|
| | | // 内部请求验证
|
| | | if (!StringUtils.equals(SecurityConstants.INNER, source))
|
| | | {
|
| | | throw new InnerAuthException("没有内部访问权限,不允许访问");
|
| | | }
|
| | |
|
| | | String userid = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USER_ID);
|
| | | String username = ServletUtils.getRequest().getHeader(SecurityConstants.DETAILS_USERNAME);
|
| | | // 用户信息验证
|
| | | if (innerAuth.isUser() && (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)))
|
| | | {
|
| | | throw new InnerAuthException("没有设置用户信息,不允许访问 ");
|
| | | }
|
| | | return point.proceed();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 确保在权限认证aop执行前执行
|
| | | */
|
| | | @Override
|
| | | public int getOrder()
|
| | | {
|
| | | return Ordered.HIGHEST_PRECEDENCE + 1;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import java.util.Map;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import com.ruoyi.common.core.utils.ip.IpUtils;
|
| | | import org.springframework.stereotype.Component;
|
| | | import com.ruoyi.common.core.constant.CacheConstants;
|
| | | import com.ruoyi.common.core.constant.SecurityConstants;
|
| | | import com.ruoyi.common.core.utils.ServletUtils;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | | import com.ruoyi.common.core.utils.ip.IpUtils;
|
| | | import feign.RequestInterceptor;
|
| | | import feign.RequestTemplate;
|
| | |
|
| | |
| | | {
|
| | | Map<String, String> headers = ServletUtils.getHeaders(httpServletRequest);
|
| | | // 传递用户信息请求头,防止丢失
|
| | | String userId = headers.get(CacheConstants.DETAILS_USER_ID);
|
| | | String userId = headers.get(SecurityConstants.DETAILS_USER_ID);
|
| | | if (StringUtils.isNotEmpty(userId))
|
| | | {
|
| | | requestTemplate.header(CacheConstants.DETAILS_USER_ID, userId);
|
| | | requestTemplate.header(SecurityConstants.DETAILS_USER_ID, userId);
|
| | | }
|
| | | String userName = headers.get(CacheConstants.DETAILS_USERNAME);
|
| | | String userName = headers.get(SecurityConstants.DETAILS_USERNAME);
|
| | | if (StringUtils.isNotEmpty(userName))
|
| | | {
|
| | | requestTemplate.header(CacheConstants.DETAILS_USERNAME, userName);
|
| | | requestTemplate.header(SecurityConstants.DETAILS_USERNAME, userName);
|
| | | }
|
| | | String authentication = headers.get(CacheConstants.AUTHORIZATION_HEADER);
|
| | | String authentication = headers.get(SecurityConstants.AUTHORIZATION_HEADER);
|
| | | if (StringUtils.isNotEmpty(authentication))
|
| | | {
|
| | | requestTemplate.header(CacheConstants.AUTHORIZATION_HEADER, authentication);
|
| | | requestTemplate.header(SecurityConstants.AUTHORIZATION_HEADER, authentication);
|
| | | }
|
| | |
|
| | | // 配置客户端IP
|
| | |
| | | import com.ruoyi.common.core.exception.BaseException;
|
| | | import com.ruoyi.common.core.exception.CustomException;
|
| | | import com.ruoyi.common.core.exception.DemoModeException;
|
| | | import com.ruoyi.common.core.exception.InnerAuthException;
|
| | | import com.ruoyi.common.core.exception.PreAuthorizeException;
|
| | | import com.ruoyi.common.core.utils.StringUtils;
|
| | | import com.ruoyi.common.core.web.domain.AjaxResult;
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 内部认证异常
|
| | | */
|
| | | @ExceptionHandler(InnerAuthException.class)
|
| | | public AjaxResult InnerAuthException(InnerAuthException e)
|
| | | {
|
| | | return AjaxResult.error(e.getMessage());
|
| | | }
|
| | |
|
| | | /**
|
| | | * 演示模式异常
|
| | | */
|
| | | @ExceptionHandler(DemoModeException.class)
|
| | |
| | | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
| | | com.ruoyi.common.security.service.TokenService,\
|
| | | com.ruoyi.common.security.aspect.PreAuthorizeAspect,\
|
| | | com.ruoyi.common.security.aspect.InnerAuthAspect,\
|
| | | com.ruoyi.common.security.handler.GlobalExceptionHandler
|
| | |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.constant.HttpStatus; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.utils.SecurityUtils; |
| | | import com.ruoyi.common.core.utils.ServletUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | |
| | | // 设置过期时间 |
| | | redisService.expire(getTokenKey(token), EXPIRE_TIME); |
| | | // 设置用户信息到请求 |
| | | addHeader(mutate, CacheConstants.DETAILS_USER_ID, userid); |
| | | addHeader(mutate, CacheConstants.DETAILS_USERNAME, username); |
| | | addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid); |
| | | addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username); |
| | | // 内部请求来源参数清除 |
| | | removeHeader(mutate, SecurityConstants.FROM_SOURCE); |
| | | return chain.filter(exchange.mutate().request(mutate.build()).build()); |
| | | } |
| | | |
| | |
| | | String valueStr = value.toString(); |
| | | String valueEncode = ServletUtils.urlEncode(valueStr); |
| | | mutate.header(name, valueEncode); |
| | | } |
| | | |
| | | private void removeHeader(ServerHttpRequest.Builder mutate, String name) |
| | | { |
| | | mutate.headers(httpHeaders -> httpHeaders.remove(name)).build(); |
| | | } |
| | | |
| | | private Mono<Void> unauthorizedResponse(ServerWebExchange exchange, String msg) |
| | |
| | | */ |
| | | private String getToken(ServerHttpRequest request) |
| | | { |
| | | String token = request.getHeaders().getFirst(CacheConstants.TOKEN_AUTHENTICATION); |
| | | String token = request.getHeaders().getFirst(SecurityConstants.TOKEN_AUTHENTICATION); |
| | | return SecurityUtils.replaceTokenPrefix(token); |
| | | } |
| | | |
| | |
| | | @Component
|
| | | public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object>
|
| | | {
|
| | | private final static String AUTH_URL = "/auth/login";
|
| | | private final static String[] VALIDATE_URL = new String[] { "/auth/login", "/auth/register" };
|
| | |
|
| | | @Autowired
|
| | | private ValidateCodeService validateCodeService;
|
| | |
| | | return (exchange, chain) -> {
|
| | | ServerHttpRequest request = exchange.getRequest();
|
| | |
|
| | | // 非登录请求或验证码关闭,不处理
|
| | | if (!StringUtils.containsIgnoreCase(request.getURI().getPath(), AUTH_URL) || !captchaProperties.getEnabled())
|
| | | // 非登录/注册请求或验证码关闭,不处理
|
| | | if (!StringUtils.containsAnyIgnoreCase(request.getURI().getPath(), VALIDATE_URL) || !captchaProperties.getEnabled())
|
| | | {
|
| | | return chain.filter(exchange);
|
| | | }
|
| | |
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.RequestBody;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.core.constant.Constants;
|
| | | import com.ruoyi.common.core.utils.ServletUtils;
|
| | | import com.ruoyi.common.core.utils.ip.IpUtils;
|
| | | import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.common.core.web.controller.BaseController;
|
| | | import com.ruoyi.common.core.web.domain.AjaxResult;
|
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.InnerAuth;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.system.domain.SysLogininfor;
|
| | | import com.ruoyi.system.api.domain.SysLogininfor;
|
| | | import com.ruoyi.system.service.ISysLogininforService;
|
| | |
|
| | | /**
|
| | |
| | | return AjaxResult.success();
|
| | | }
|
| | |
|
| | | @InnerAuth
|
| | | @PostMapping
|
| | | public AjaxResult add(@RequestParam("username") String username, @RequestParam("status") String status,
|
| | | @RequestParam("message") String message)
|
| | | public AjaxResult add(@RequestBody SysLogininfor logininfor)
|
| | | {
|
| | | String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
|
| | |
|
| | | // 封装对象
|
| | | SysLogininfor logininfor = new SysLogininfor();
|
| | | logininfor.setUserName(username);
|
| | | logininfor.setIpaddr(ip);
|
| | | logininfor.setMsg(message);
|
| | | // 日志状态
|
| | | if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status))
|
| | | {
|
| | | logininfor.setStatus("0");
|
| | | }
|
| | | else if (Constants.LOGIN_FAIL.equals(status))
|
| | | {
|
| | | logininfor.setStatus("1");
|
| | | }
|
| | | return toAjax(logininforService.insertLogininfor(logininfor));
|
| | | }
|
| | | }
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.InnerAuth;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.system.api.domain.SysOperLog;
|
| | | import com.ruoyi.system.service.ISysOperLogService;
|
| | |
| | | return AjaxResult.success();
|
| | | }
|
| | |
|
| | | @InnerAuth
|
| | | @PostMapping
|
| | | public AjaxResult add(@RequestBody SysOperLog operLog)
|
| | | {
|
| | |
| | | import com.ruoyi.common.core.web.page.TableDataInfo;
|
| | | import com.ruoyi.common.log.annotation.Log;
|
| | | import com.ruoyi.common.log.enums.BusinessType;
|
| | | import com.ruoyi.common.security.annotation.InnerAuth;
|
| | | import com.ruoyi.common.security.annotation.PreAuthorize;
|
| | | import com.ruoyi.system.api.domain.SysRole;
|
| | | import com.ruoyi.system.api.domain.SysUser;
|
| | | import com.ruoyi.system.api.model.LoginUser;
|
| | | import com.ruoyi.system.service.ISysConfigService;
|
| | | import com.ruoyi.system.service.ISysPermissionService;
|
| | | import com.ruoyi.system.service.ISysPostService;
|
| | | import com.ruoyi.system.service.ISysRoleService;
|
| | |
| | |
|
| | | @Autowired
|
| | | private ISysPermissionService permissionService;
|
| | |
|
| | | @Autowired
|
| | | private ISysConfigService configService;
|
| | |
|
| | | /**
|
| | | * 获取用户列表
|
| | |
| | | /**
|
| | | * 获取当前用户信息
|
| | | */
|
| | | @InnerAuth
|
| | | @GetMapping("/info/{username}")
|
| | | public R<LoginUser> info(@PathVariable("username") String username)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 注册用户信息
|
| | | */
|
| | | @InnerAuth
|
| | | @PostMapping("/register")
|
| | | public R<Boolean> register(@RequestBody SysUser sysUser)
|
| | | {
|
| | | String username = sysUser.getUserName();
|
| | | if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
|
| | | {
|
| | | return R.fail("当前系统没有开启注册功能!");
|
| | | }
|
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username)))
|
| | | {
|
| | | return R.fail("保存用户'" + username + "'失败,注册账号已存在");
|
| | | }
|
| | | return R.ok(userService.registerUser(sysUser));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户信息
|
| | | *
|
| | | * @return 用户信息
|
| | |
| | | package com.ruoyi.system.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.system.domain.SysLogininfor;
|
| | | import com.ruoyi.system.api.domain.SysLogininfor;
|
| | |
|
| | | /**
|
| | | * 系统访问日志情况信息 数据层
|
| | |
| | | package com.ruoyi.system.service;
|
| | |
|
| | | import java.util.List;
|
| | | import com.ruoyi.system.domain.SysLogininfor;
|
| | | import com.ruoyi.system.api.domain.SysLogininfor;
|
| | |
|
| | | /**
|
| | | * 系统访问日志情况信息 服务层
|
| | |
| | | public int insertUser(SysUser user);
|
| | |
|
| | | /**
|
| | | * 注册用户信息
|
| | | * |
| | | * @param user 用户信息
|
| | | * @return 结果
|
| | | */
|
| | | public boolean registerUser(SysUser user);
|
| | |
|
| | | /**
|
| | | * 修改用户信息
|
| | | *
|
| | | * @param user 用户信息
|
| | |
| | | import java.util.List;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import com.ruoyi.system.domain.SysLogininfor;
|
| | | import com.ruoyi.system.api.domain.SysLogininfor;
|
| | | import com.ruoyi.system.mapper.SysLogininforMapper;
|
| | | import com.ruoyi.system.service.ISysLogininforService;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 注册用户信息
|
| | | * |
| | | * @param user 用户信息
|
| | | * @return 结果
|
| | | */
|
| | | public boolean registerUser(SysUser user)
|
| | | {
|
| | | return userMapper.insertUser(user) > 0;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 修改保存用户信息
|
| | | *
|
| | | * @param user 用户信息
|
| | |
| | | })
|
| | | }
|
| | |
|
| | | // 注册方法
|
| | | export function register(data) {
|
| | | return request({
|
| | | url: '/auth/register',
|
| | | headers: {
|
| | | isToken: false
|
| | | },
|
| | | method: 'post',
|
| | | data: data
|
| | | })
|
| | | }
|
| | |
|
| | | // 刷新方法
|
| | | export function refreshToken() {
|
| | | return request({
|
| | |
| | | hidden: true
|
| | | },
|
| | | {
|
| | | path: '/register',
|
| | | component: (resolve) => require(['@/views/register'], resolve),
|
| | | hidden: true
|
| | | },
|
| | | {
|
| | | path: '/404',
|
| | | component: (resolve) => require(['@/views/error/404'], resolve),
|
| | | hidden: true
|
| | |
| | | <span v-if="!loading">登 录</span>
|
| | | <span v-else>登 录 中...</span>
|
| | | </el-button>
|
| | | <div style="float: right;" v-if="register">
|
| | | <router-link class="link-type" :to="'/register'">立即注册</router-link>
|
| | | </div>
|
| | | </el-form-item>
|
| | | </el-form>
|
| | | <!-- 底部 -->
|
| | |
| | | },
|
| | | loginRules: {
|
| | | username: [
|
| | | { required: true, trigger: "blur", message: "用户名不能为空" }
|
| | | { required: true, trigger: "blur", message: "请输入您的账号" }
|
| | | ],
|
| | | password: [
|
| | | { required: true, trigger: "blur", message: "密码不能为空" }
|
| | | { required: true, trigger: "blur", message: "请输入您的密码" }
|
| | | ],
|
| | | code: [{ required: true, trigger: "change", message: "验证码不能为空" }]
|
| | | code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
| | | },
|
| | | loading: false,
|
| | | // 验证码开关
|
| | | captchaOnOff: true,
|
| | | // 注册开关
|
| | | register: false,
|
| | | redirect: undefined
|
| | | };
|
| | | },
|
| New file |
| | |
| | | <template>
|
| | | <div class="register">
|
| | | <el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form">
|
| | | <h3 class="title">若依后台管理系统</h3>
|
| | | <el-form-item prop="username">
|
| | | <el-input v-model="registerForm.username" type="text" auto-complete="off" placeholder="账号">
|
| | | <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
|
| | | </el-input>
|
| | | </el-form-item>
|
| | | <el-form-item prop="password">
|
| | | <el-input
|
| | | v-model="registerForm.password"
|
| | | type="password"
|
| | | auto-complete="off"
|
| | | placeholder="密码"
|
| | | @keyup.enter.native="handleRegister"
|
| | | >
|
| | | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
| | | </el-input>
|
| | | </el-form-item>
|
| | | <el-form-item prop="confirmPassword">
|
| | | <el-input
|
| | | v-model="registerForm.confirmPassword"
|
| | | type="password"
|
| | | auto-complete="off"
|
| | | placeholder="确认密码"
|
| | | @keyup.enter.native="handleRegister"
|
| | | >
|
| | | <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
|
| | | </el-input>
|
| | | </el-form-item>
|
| | | <el-form-item prop="code" v-if="captchaOnOff">
|
| | | <el-input
|
| | | v-model="registerForm.code"
|
| | | auto-complete="off"
|
| | | placeholder="验证码"
|
| | | style="width: 63%"
|
| | | @keyup.enter.native="handleRegister"
|
| | | >
|
| | | <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
|
| | | </el-input>
|
| | | <div class="register-code">
|
| | | <img :src="codeUrl" @click="getCode" class="register-code-img"/>
|
| | | </div>
|
| | | </el-form-item>
|
| | | <el-form-item style="width:100%;">
|
| | | <el-button
|
| | | :loading="loading"
|
| | | size="medium"
|
| | | type="primary"
|
| | | style="width:100%;"
|
| | | @click.native.prevent="handleRegister"
|
| | | >
|
| | | <span v-if="!loading">注 册</span>
|
| | | <span v-else>注 册 中...</span>
|
| | | </el-button>
|
| | | <div style="float: right;">
|
| | | <router-link class="link-type" :to="'/login'">使用已有账户登录</router-link>
|
| | | </div>
|
| | | </el-form-item>
|
| | | </el-form>
|
| | | <!-- 底部 -->
|
| | | <div class="el-register-footer">
|
| | | <span>Copyright © 2018-2021 ruoyi.vip All Rights Reserved.</span>
|
| | | </div>
|
| | | </div>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | import { getCodeImg, register } from "@/api/login";
|
| | |
|
| | | export default {
|
| | | name: "Register",
|
| | | data() {
|
| | | const equalToPassword = (rule, value, callback) => {
|
| | | if (this.registerForm.password !== value) {
|
| | | callback(new Error("两次输入的密码不一致"));
|
| | | } else {
|
| | | callback();
|
| | | }
|
| | | };
|
| | | return {
|
| | | codeUrl: "",
|
| | | registerForm: {
|
| | | username: "",
|
| | | password: "",
|
| | | confirmPassword: "",
|
| | | code: "",
|
| | | uuid: ""
|
| | | },
|
| | | registerRules: {
|
| | | username: [
|
| | | { required: true, trigger: "blur", message: "请输入您的账号" },
|
| | | { min: 2, max: 20, message: '用户账号长度必须介于 2 和 20 之间', trigger: 'blur' }
|
| | | ],
|
| | | password: [
|
| | | { required: true, trigger: "blur", message: "请输入您的密码" },
|
| | | { min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' }
|
| | | ],
|
| | | confirmPassword: [
|
| | | { required: true, trigger: "blur", message: "请再次输入您的密码" },
|
| | | { required: true, validator: equalToPassword, trigger: "blur" }
|
| | | ],
|
| | | code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
| | | },
|
| | | loading: false,
|
| | | captchaOnOff: true
|
| | | };
|
| | | },
|
| | | created() {
|
| | | this.getCode();
|
| | | },
|
| | | methods: {
|
| | | getCode() {
|
| | | getCodeImg().then(res => {
|
| | | this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff;
|
| | | if (this.captchaOnOff) {
|
| | | this.codeUrl = "data:image/gif;base64," + res.img;
|
| | | this.registerForm.uuid = res.uuid;
|
| | | }
|
| | | });
|
| | | },
|
| | | handleRegister() {
|
| | | this.$refs.registerForm.validate(valid => {
|
| | | if (valid) {
|
| | | this.loading = true;
|
| | | register(this.registerForm).then(res => {
|
| | | const username = this.registerForm.username;
|
| | | this.$alert("<font color='red'>恭喜你,您的账号 " + username + " 注册成功!</font>", '系统提示', {
|
| | | dangerouslyUseHTMLString: true
|
| | | }).then(() => {
|
| | | this.$router.push("/login");
|
| | | }).catch(() => {});
|
| | | }).catch(() => {
|
| | | this.loading = false;
|
| | | if (this.captchaOnOff) {
|
| | | this.getCode();
|
| | | }
|
| | | })
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | | };
|
| | | </script>
|
| | |
|
| | | <style rel="stylesheet/scss" lang="scss">
|
| | | .register {
|
| | | display: flex;
|
| | | justify-content: center;
|
| | | align-items: center;
|
| | | height: 100%;
|
| | | background-image: url("../assets/images/login-background.jpg");
|
| | | background-size: cover;
|
| | | }
|
| | | .title {
|
| | | margin: 0px auto 30px auto;
|
| | | text-align: center;
|
| | | color: #707070;
|
| | | }
|
| | |
|
| | | .register-form {
|
| | | border-radius: 6px;
|
| | | background: #ffffff;
|
| | | width: 400px;
|
| | | padding: 25px 25px 5px 25px;
|
| | | .el-input {
|
| | | height: 38px;
|
| | | input {
|
| | | height: 38px;
|
| | | }
|
| | | }
|
| | | .input-icon {
|
| | | height: 39px;
|
| | | width: 14px;
|
| | | margin-left: 2px;
|
| | | }
|
| | | }
|
| | | .register-tip {
|
| | | font-size: 13px;
|
| | | text-align: center;
|
| | | color: #bfbfbf;
|
| | | }
|
| | | .register-code {
|
| | | width: 33%;
|
| | | height: 38px;
|
| | | float: right;
|
| | | img {
|
| | | cursor: pointer;
|
| | | vertical-align: middle;
|
| | | }
|
| | | }
|
| | | .el-register-footer {
|
| | | height: 40px;
|
| | | line-height: 40px;
|
| | | position: fixed;
|
| | | bottom: 0;
|
| | | width: 100%;
|
| | | text-align: center;
|
| | | color: #fff;
|
| | | font-family: Arial;
|
| | | font-size: 12px;
|
| | | letter-spacing: 1px;
|
| | | }
|
| | | .register-code-img {
|
| | | height: 38px;
|
| | | }
|
| | | </style>
|
| File was renamed from sql/ry_config_20210728.sql |
| | |
| | | |
| | | insert into config_info(id, data_id, group_id, content, md5, gmt_create, gmt_modified, src_user, src_ip, app_name, tenant_id, c_desc, c_use, effect, type, c_schema) values |
| | | (1,'application-dev.yml','DEFAULT_GROUP','spring:\n main:\n allow-bean-definition-overriding: true\n autoconfigure:\n exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure\n\n#请求处理的超时时间\nribbon:\n ReadTimeout: 10000\n ConnectTimeout: 10000\n\n# feign 配置\nfeign:\n sentinel:\n enabled: true\n okhttp:\n enabled: true\n httpclient:\n enabled: false\n client:\n config:\n default:\n connectTimeout: 10000\n readTimeout: 10000\n compression:\n request:\n enabled: true\n response:\n enabled: true\n\n# 暴露监控端点\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n','c07e6f7321493f6d5390d0a08bffb75a','2019-11-29 16:31:20','2020-12-21 15:29:24',NULL,'0:0:0:0:0:0:0:1','','','通用配置','null','null','yaml','null'), |
| | | (2,'ruoyi-gateway-dev.yml','DEFAULT_GROUP','spring:\n redis:\n host: localhost\n port: 6379\n password: \n cloud:\n gateway:\n discovery:\n locator:\n lowerCaseServiceId: true\n enabled: true\n routes:\n # 认证中心\n - id: ruoyi-auth\n uri: lb://ruoyi-auth\n predicates:\n - Path=/auth/**\n filters:\n # 验证码处理\n - CacheRequestFilter\n - ValidateCodeFilter\n - StripPrefix=1\n # 代码生成\n - id: ruoyi-gen\n uri: lb://ruoyi-gen\n predicates:\n - Path=/code/**\n filters:\n - StripPrefix=1\n # 定时任务\n - id: ruoyi-job\n uri: lb://ruoyi-job\n predicates:\n - Path=/schedule/**\n filters:\n - StripPrefix=1\n # 系统模块\n - id: ruoyi-system\n uri: lb://ruoyi-system\n predicates:\n - Path=/system/**\n filters:\n - StripPrefix=1\n # 文件服务\n - id: ruoyi-file\n uri: lb://ruoyi-file\n predicates:\n - Path=/file/**\n filters:\n - StripPrefix=1\n\n# 安全配置\nsecurity:\n # 验证码\n captcha:\n enabled: true\n type: math\n # 防止XSS攻击\n xss:\n enabled: true\n excludeUrls:\n - /system/notice\n # 不校验白名单\n ignore:\n whites:\n - /auth/logout\n - /auth/login\n - /*/v2/api-docs\n - /csrf\n','4222c4f41631529567d83a6d8c1ba6d4','2020-05-14 14:17:55','2021-07-27 13:47:39',NULL,'0:0:0:0:0:0:0:1','','','网关模块','null','null','yaml','null'), |
| | | (2,'ruoyi-gateway-dev.yml','DEFAULT_GROUP','spring:\n redis:\n host: localhost\n port: 6379\n password: \n cloud:\n gateway:\n discovery:\n locator:\n lowerCaseServiceId: true\n enabled: true\n routes:\n # 认证中心\n - id: ruoyi-auth\n uri: lb://ruoyi-auth\n predicates:\n - Path=/auth/**\n filters:\n # 验证码处理\n - CacheRequestFilter\n - ValidateCodeFilter\n - StripPrefix=1\n # 代码生成\n - id: ruoyi-gen\n uri: lb://ruoyi-gen\n predicates:\n - Path=/code/**\n filters:\n - StripPrefix=1\n # 定时任务\n - id: ruoyi-job\n uri: lb://ruoyi-job\n predicates:\n - Path=/schedule/**\n filters:\n - StripPrefix=1\n # 系统模块\n - id: ruoyi-system\n uri: lb://ruoyi-system\n predicates:\n - Path=/system/**\n filters:\n - StripPrefix=1\n # 文件服务\n - id: ruoyi-file\n uri: lb://ruoyi-file\n predicates:\n - Path=/file/**\n filters:\n - StripPrefix=1\n\n# 安全配置\nsecurity:\n # 验证码\n captcha:\n enabled: true\n type: math\n # 防止XSS攻击\n xss:\n enabled: true\n excludeUrls:\n - /system/notice\n # 不校验白名单\n ignore:\n whites:\n - /auth/logout\n - /auth/login\n - /auth/register\n - /*/v2/api-docs\n - /csrf\n','2f5a6b5a4ccf20b5801c5cf842456ec6','2020-05-14 14:17:55','2021-07-30 09:07:14',NULL,'0:0:0:0:0:0:0:1','','','网关模块','null','null','yaml','null'),
|
| | | (3,'ruoyi-auth-dev.yml','DEFAULT_GROUP','spring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n','b7354e1eb62c2d846d44a796d9ec6930','2020-11-20 00:00:00','2021-02-28 21:06:58',NULL,'0:0:0:0:0:0:0:1','','','认证中心','null','null','yaml','null'), |
| | | (4,'ruoyi-monitor-dev.yml','DEFAULT_GROUP','# spring\r\nspring: \r\n security:\r\n user:\r\n name: ruoyi\r\n password: 123456\r\n boot:\r\n admin:\r\n ui:\r\n title: 若依服务状态监控\r\n','d8997d0707a2fd5d9fc4e8409da38129','2020-11-20 00:00:00','2020-12-21 16:28:07',NULL,'0:0:0:0:0:0:0:1','','','监控中心','null','null','yaml','null'), |
| | | (5,'ruoyi-system-dev.yml','DEFAULT_GROUP','# spring配置\r\nspring: \r\n redis:\r\n host: localhost\r\n port: 6379\r\n password: \r\n datasource:\r\n druid:\r\n stat-view-servlet:\r\n enabled: true\r\n loginUsername: admin\r\n loginPassword: 123456\r\n dynamic:\r\n druid:\r\n initial-size: 5\r\n min-idle: 5\r\n maxActive: 20\r\n maxWait: 60000\r\n timeBetweenEvictionRunsMillis: 60000\r\n minEvictableIdleTimeMillis: 300000\r\n validationQuery: SELECT 1 FROM DUAL\r\n testWhileIdle: true\r\n testOnBorrow: false\r\n testOnReturn: false\r\n poolPreparedStatements: true\r\n maxPoolPreparedStatementPerConnectionSize: 20\r\n filters: stat,slf4j\r\n connectionProperties: druid.stat.mergeSql\\=true;druid.stat.slowSqlMillis\\=5000\r\n datasource:\r\n # 主库数据源\r\n master:\r\n driver-class-name: com.mysql.cj.jdbc.Driver\r\n url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8\r\n username: root\r\n password: password\r\n # 从库数据源\r\n # slave:\r\n # username: \r\n # password: \r\n # url: \r\n # driver-class-name: \r\n # seata: true # 开启seata代理,开启后默认每个数据源都代理,如果某个不需要代理可单独关闭\r\n\r\n# seata配置\r\nseata:\r\n # 默认关闭,如需启用spring.datasource.dynami.seata需要同时开启\r\n enabled: false\r\n # Seata 应用编号,默认为 ${spring.application.name}\r\n application-id: ${spring.application.name}\r\n # Seata 事务组编号,用于 TC 集群名\r\n tx-service-group: ${spring.application.name}-group\r\n # 关闭自动代理\r\n enable-auto-data-source-proxy: false\r\n # 服务配置项\r\n service:\r\n # 虚拟组和分组的映射\r\n vgroup-mapping:\r\n ruoyi-system-group: default\r\n config:\r\n type: nacos\r\n nacos:\r\n serverAddr: 127.0.0.1:8848\r\n group: SEATA_GROUP\r\n namespace:\r\n registry:\r\n type: nacos\r\n nacos:\r\n application: seata-server\r\n server-addr: 127.0.0.1:8848\r\n namespace:\r\n\r\n# mybatis配置\r\nmybatis:\r\n # 搜索指定包别名\r\n typeAliasesPackage: com.ruoyi.system\r\n # 配置mapper的扫描,找到所有的mapper.xml映射文件\r\n mapperLocations: classpath:mapper/**/*.xml\r\n\r\n# swagger配置\r\nswagger:\r\n title: 系统模块接口文档\r\n license: Powered By ruoyi\r\n licenseUrl: https://ruoyi.vip','ac8913dee679e65bb7d482df5f267d4e','2020-11-20 00:00:00','2021-01-27 10:42:25',NULL,'0:0:0:0:0:0:0:1','','','系统模块','null','null','yaml','null'), |