app-cloudep-permission-server/etc/rbac.conf

33 lines
1.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 表示請求參數
# role: 角色
# path: api path
# method: http method
[request_definition]
r = role, path, method
# 策略的基本參數
# role: 角色
# path: api path
# method: http method可以多個
# name: 名稱
[policy_definition]
p = role, path, methods, name
# 策略配對結果後的應對,只要配對到一個即可成功
[policy_effect]
e = some(where (p.eft == allow))
# 規範角色對應是"用戶"與"角色"
# g=A用戶,管理員
[role_definition]
g = _, _
# 策略配對規則
# 三個條件必須完全匹配
# g(r.role, p.role),只要判斷用戶角色(r.role)是否屬於策略角色(p.role)為什麼不寫r.role == p.role因為role可以有繼承關係所以不能這樣寫
# keyMatch(r.path, p.path)使用正則表達式分析api path參考 https://casbin.org/docs/function
# regexMatch(r.method, p.methods)使用正則表達式分析http method參考 https://casbin.org/docs/function
# 或達到一個條件
# r.role == admin用戶 UID 是 GodDog 全開放
[matchers]
m = g(r.role, p.role) && keyMatch2(r.path, p.path) && regexMatch(r.method, p.methods) || r.role == "GodDog"