refactor: 认证鉴权优化,新增自定义数据权限拦截注解
This commit is contained in:
16
src/main/java/com/youlai/system/pojo/dto/TokenResult.java
Normal file
16
src/main/java/com/youlai/system/pojo/dto/TokenResult.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.youlai.system.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class TokenResult {
|
||||||
|
|
||||||
|
private String accessToken;
|
||||||
|
|
||||||
|
private String refreshToken;
|
||||||
|
|
||||||
|
private Long expires;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,20 +1,4 @@
|
|||||||
/*
|
package com.youlai.system.security;
|
||||||
* Copyright 1999-2021 Alibaba Group Holding Ltd.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.youlai.system.security.jwt;
|
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import com.youlai.system.security.userdetails.SysUserDetails;
|
import com.youlai.system.security.userdetails.SysUserDetails;
|
||||||
@@ -103,7 +87,7 @@ public class JwtTokenManager {
|
|||||||
redisTemplate.opsForValue().set("USER_PERMS:" + userDetails.getUserId(), perms);
|
redisTemplate.opsForValue().set("USER_PERMS:" + userDetails.getUserId(), perms);
|
||||||
|
|
||||||
return Jwts.builder().setClaims(claims).setExpiration(validity)
|
return Jwts.builder().setClaims(claims).setExpiration(validity)
|
||||||
.signWith(SignatureAlgorithm.HS256, Keys.hmacShaKeyFor(this.getSecretKeyBytes())).compact();
|
.signWith( Keys.hmacShaKeyFor(this.getSecretKeyBytes()),SignatureAlgorithm.HS256).compact();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2,8 +2,8 @@ package com.youlai.system.security.filter;
|
|||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.youlai.system.common.result.ResultCode;
|
import com.youlai.system.common.result.ResultCode;
|
||||||
import com.youlai.system.security.jwt.JwtTokenManager;
|
import com.youlai.system.security.JwtTokenManager;
|
||||||
import com.youlai.system.util.ResponseUtils;
|
import com.youlai.system.common.util.ResponseUtils;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.youlai.system.security.service;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.youlai.system.util.SecurityUtils;
|
import com.youlai.system.security.util.SecurityUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|||||||
Reference in New Issue
Block a user