Open salmad3 opened 5 days ago
Hello, within teritori we developed a role manager: https://github.com/TERITORI/teritori-dapp/tree/main/gno/p/role_manager It does not meet all your criterias but allow to assign role & permissions easily to users, it could be used as base or inspiration to development of the Permissions interface
Within teritori we use it to manage roles for DAO deployed from our app. Hope it can help a bit, i would be happy to discuss and help if i can :D
Context:
Establish a
Permissions
interface within the/r/boards
to manage role-based access control and support callback-driven permission checks. This system should be adaptable for different levels of user roles (Owners
,Admins
,Moderators
,Members
) and should facilitate future integration with anAdminDAO
for governance. The core purpose is to create a composable permission structure that allows for the encapsulation of logic related to user actions, checks, and role management.Moderation and Ownership Recap:
Acceptance Criteria:
[x] Permissions` interface includes methods to account for board level operations based on roles.
Example
```go type Permissions interface { WithPermission(user Address, action string, args []interface{}, callback func(args []interface{})) error GetRoles() []string GetUsers(role string) []Address HasPermission(user Address, action string, args []interface{}) bool } ```[x] Implements
DefaultPermissions
as an initial realization of thePermissions
interface:AdminDAO
instance (which can be an address) for handling administrative decisions.Example
[x] Provides
WithPermission()
to validate user roles and execute callback actions based on permission checks.Example
```go func (dp *DefaultPermissions) WithPermission(user Address, action string, args []interface{}, callback func(args []interface{})) error { if !dp.HasPermission(user, action, args) { return errors.New("permission denied") } callback(args) return nil } ```GetRoles()
andGetUsers(role)
provide efficient role and user management.HasPermission()
is used for pre-checking if a user has the required access to perform an action.