Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
644b7772
提交
644b7772
authored
7月 13, 2022
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 新增 @AuthIgnore 注解, 忽略接口鉴权
上级
b0fef6c5
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
1 行删除
+28
-1
AuthIgnore.java
.../src/main/java/com/yiring/auth/annotation/AuthIgnore.java
+20
-0
SaTokenConfigure.java
...rc/main/java/com/yiring/auth/config/SaTokenConfigure.java
+8
-1
没有找到文件。
basic-auth/src/main/java/com/yiring/auth/annotation/AuthIgnore.java
0 → 100644
浏览文件 @
644b7772
/* (C) 2022 YiRing, Inc. */
package
com
.
yiring
.
auth
.
annotation
;
import
java.lang.annotation.*
;
/**
* 忽略登录校验
* 与 @SaCheckLogin 相对
*
* @author Jim
* @version 0.1
* 2022/4/7 15:21
*/
@SuppressWarnings
({
"unused"
})
@Target
({
ElementType
.
METHOD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
AuthIgnore
{
}
basic-auth/src/main/java/com/yiring/auth/config/SaTokenConfigure.java
浏览文件 @
644b7772
...
@@ -5,7 +5,9 @@ import cn.dev33.satoken.interceptor.SaRouteInterceptor;
...
@@ -5,7 +5,9 @@ import cn.dev33.satoken.interceptor.SaRouteInterceptor;
import
cn.dev33.satoken.router.SaHttpMethod
;
import
cn.dev33.satoken.router.SaHttpMethod
;
import
cn.dev33.satoken.router.SaRouter
;
import
cn.dev33.satoken.router.SaRouter
;
import
cn.dev33.satoken.stp.StpUtil
;
import
cn.dev33.satoken.stp.StpUtil
;
import
com.yiring.auth.annotation.AuthIgnore
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
...
@@ -34,11 +36,16 @@ public class SaTokenConfigure implements WebMvcConfigurer {
...
@@ -34,11 +36,16 @@ public class SaTokenConfigure implements WebMvcConfigurer {
// TODO
// TODO
// .notMatch("/**")
// .notMatch("/**")
// 示例接口
// 示例接口
.
notMatch
(
"/example/**"
)
//
.notMatch("/example/**")
// 授权相关接口(登录、登出、注册等)
// 授权相关接口(登录、登出、注册等)
.
notMatch
(
"/auth/**"
)
.
notMatch
(
"/auth/**"
)
.
notMatch
(
"/favicon.ico"
,
"/**/*.html"
,
"/**/*.js"
,
"/**/*.css"
)
.
notMatch
(
"/favicon.ico"
,
"/**/*.html"
,
"/**/*.js"
,
"/**/*.css"
)
.
notMatch
(
"/v2/api-docs/**"
,
"/v3/api-docs/**"
,
"/swagger-resources/**"
)
.
notMatch
(
"/v2/api-docs/**"
,
"/v3/api-docs/**"
,
"/swagger-resources/**"
)
// 自定义注解忽略接口鉴权
.
notMatch
(
r
->
{
HandlerMethod
method
=
(
HandlerMethod
)
handler
;
return
method
.
hasMethodAnnotation
(
AuthIgnore
.
class
);
})
.
check
(
r
->
StpUtil
.
checkLogin
());
.
check
(
r
->
StpUtil
.
checkLogin
());
})
})
)
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论