refactor: 认证鉴权优化,新增自定义数据权限拦截注解

This commit is contained in:
haoxr
2022-12-18 12:50:32 +08:00
parent bbdf915fd1
commit 0e8e56a24a
4 changed files with 21 additions and 21 deletions

View 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;
}

View File

@@ -1,20 +1,4 @@
/*
* 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;
package com.youlai.system.security;
import cn.hutool.core.convert.Convert;
import com.youlai.system.security.userdetails.SysUserDetails;
@@ -103,7 +87,7 @@ public class JwtTokenManager {
redisTemplate.opsForValue().set("USER_PERMS:" + userDetails.getUserId(), perms);
return Jwts.builder().setClaims(claims).setExpiration(validity)
.signWith(SignatureAlgorithm.HS256, Keys.hmacShaKeyFor(this.getSecretKeyBytes())).compact();
.signWith( Keys.hmacShaKeyFor(this.getSecretKeyBytes()),SignatureAlgorithm.HS256).compact();
}
/**

View File

@@ -2,8 +2,8 @@ package com.youlai.system.security.filter;
import cn.hutool.core.util.StrUtil;
import com.youlai.system.common.result.ResultCode;
import com.youlai.system.security.jwt.JwtTokenManager;
import com.youlai.system.util.ResponseUtils;
import com.youlai.system.security.JwtTokenManager;
import com.youlai.system.common.util.ResponseUtils;
import org.springframework.http.HttpMethod;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

View File

@@ -2,7 +2,7 @@ package com.youlai.system.security.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.youlai.system.util.SecurityUtils;
import com.youlai.system.security.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;