feat(auth): 添加JWT与Casbin权限认证功能

This commit is contained in:
unclesam committed 2026-07-07 20:24:30 +08:00
1 parent fe86c081f4
commit 16a9f64109
9 files changed
+236 -27

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
# Request definition
[request_definition]
r = sub, obj, act
# Policy definition
[policy_definition]
p = sub, obj, act
# Role definition
[role_definition]
g = _, _
# Policy effect
[policy_effect]
e = some(where (p.eft == allow))
# Matchers
[matchers]
m = r.sub == "unclesam" || g(r.sub, p.sub) && keyMatch2(r.obj, p.obj) && regexMatch(r.act, p.act)
+8 -1
View File
@@ -21,4 +21,11 @@ logger:
max_size: 100 # 单个日志文件最大大小 (单位: MB)
max_backups: 7 # 最多保留的旧日志文件个数
max_age: 30 # 旧日志文件最长保留天数 (单位: 天)
compress: true # 是否对历史归档日志进行 gzip 压缩
compress: true # 是否对历史归档日志进行 gzip 压缩
jwt:
issuer: "山姆叔叔"
access_secret: "django-insecure-pfgn+96(rq74los_7d#n8#b07+$23vnxy*#y^y=eu9&_1eqk$7"
refresh_secret: "3676f2d0e99f294aab75997e16340370"
access_expire: 2 # 小时
refresh_expire: 168 # 小时(7天)