You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
c1a5c25 feat: [#702] allow overwriting casbin configuration (Jose Celano)
Pull request description:
This is an **unstable** feature. You can overwrite casbin configuration to change permissions for roles: guest, registered and admin.
You can do it by adding this new section to the TOML config file:
```toml
[unstable.auth.casbin]
model = """
[request_definition]
r = role, action
[policy_definition]
p = role, action
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.role == p.role && r.action == p.action
"""
policy = """
admin, GetAboutPage
admin, GetLicensePage
admin, AddCategory
admin, DeleteCategory
admin, GetCategories
admin, GetImageByUrl
admin, GetSettings
admin, GetSettingsSecret
admin, GetPublicSettings
admin, AddTag
admin, DeleteTag
admin, GetTags
admin, AddTorrent
admin, GetTorrent
admin, DeleteTorrent
admin, GetTorrentInfo
admin, GenerateTorrentInfoListing
admin, GetCanonicalInfoHash
admin, ChangePassword
admin, BanUser
registered, GetAboutPage
registered, GetLicensePage
registered, GetCategories
registered, GetImageByUrl
registered, GetPublicSettings
registered, GetTags
registered, AddTorrent
registered, GetTorrent
registered, GetTorrentInfo
registered, GenerateTorrentInfoListing
registered, GetCanonicalInfoHash
registered, ChangePassword
guest, GetAboutPage
guest, GetLicensePage
guest, GetCategories
guest, GetPublicSettings
guest, GetTags
guest, GetTorrent
guest, GetTorrentInfo
guest, GenerateTorrentInfoListing
guest, GetCanonicalInfoHash
"""
```
For example, if you want to force users to log in to see the torrent list, you can remove the following line from the policy:
```
guest, GenerateTorrentInfoListing
```
**NOTICE**: This is an unstable feature. It will panic with wrong casbin configuration, invalid roles, etcetera.
ACKs for top commit:
josecelano:
ACK c1a5c25
Tree-SHA512: 2bcc4bc69befd081aeef730768b4fa0f13bed14dc9c5f522ddbd0aa534b7679dc7adb870147e17120ff70af8e626b76b8662ea9d584ec4b1e11e9842f7fca8e4
0 commit comments