gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + gno.land: a blockchain for timeless code and fair open-source.
https://gno.land/
Other
898 stars 374 forks source link

[r/boards] initialize `Permissions` #3139

Open salmad3 opened 5 days ago

salmad3 commented 5 days ago

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 an AdminDAO 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:

[!NOTE] The full version will include AdminDAO interaction, but this initializes the core Permission work as a proof of concept and should provide an interim solution for AdminDAO and other moderation tasks as needed.

graph TD
    subgraph /r/boards Realm
        direction TB
        subgraph PermissionsInterface
            WithPermission["func WithPermission(user Address, action string, args ...interface{}) error"]
            HasPermission["func HasPermission(user Address, action string, args ...interface{}) bool"]
            GetRoles["func GetRoles() []string"]
            GetUsers["func GetUsers(role string) []Address"]
            ModerationConfig["struct ModerationConfig"]
        end

        DefaultPermissions["struct DefaultPermissions"]
        DefaultPermissions -->|Implements| PermissionsInterface

        Owner["struct Owner"]
        Admin["struct Admin"]
        Moderator["struct Moderator"]
        Member["struct Member"]

        Owner -->|Manages| Admin
        Owner -->|Adds/Removes| Moderator
        Owner -->|Configures| PermissionsInterface
        Owner -->|Configures| ModerationConfig
        Admin -->|Manages| Moderator
        Admin -->|Handles| ContentModeration
        Admin -->|Adjusts| BoardSettings
        Moderator -->|Flags/Deletes| Content
        Moderator -->|Follows| ModerationConfig
        Member -->|Posts| ThreadsComments
    end

    subgraph AdminDAO
        direction TB
        ProposalApproval["func ProposalApproval()"]
        GovernanceDecisions["struct GovernanceDecisions"]
        ExternalValidation["interface ExternalValidation"]
    end

    PermissionsInterface -->|Uses| HasPermission
    PermissionsInterface -->|Executes| WithPermission
    WithPermission -->|Interacts with| AdminDAO
    AdminDAO -->|Initiates| ProposalApproval
    ProposalApproval -->|Requires| GovernanceDecisions
    GovernanceDecisions -->|Returns| ApprovalRejection

    subgraph FutureExpansion
        BoardForking["func BoardForking()"]
        BoardRenaming["func BoardRenaming()"]
    end

    WithPermission -->|Controls| BoardForking
    WithPermission -->|Controls| BoardRenaming

Acceptance Criteria:

MikaelVallenet commented 4 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