{"id":20460480,"url":"https://github.com/dapphub/ds-roles","last_synced_at":"2025-04-13T05:53:23.667Z","repository":{"id":55867151,"uuid":"66574474","full_name":"dapphub/ds-roles","owner":"dapphub","description":"A DSAuthority for up to 256 roles","archived":false,"fork":false,"pushed_at":"2021-07-29T07:38:20.000Z","size":60,"stargazers_count":17,"open_issues_count":6,"forks_count":19,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-13T05:53:19.206Z","etag":null,"topics":["authorization","dappsys","ds-auth","ethereum","solidity"],"latest_commit_sha":null,"homepage":"https://dapp.tools/dappsys/ds-roles.html","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dapphub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-25T16:22:20.000Z","updated_at":"2023-04-15T17:38:30.000Z","dependencies_parsed_at":"2022-08-15T08:10:14.643Z","dependency_job_id":null,"html_url":"https://github.com/dapphub/ds-roles","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapphub%2Fds-roles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapphub%2Fds-roles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapphub%2Fds-roles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapphub%2Fds-roles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dapphub","download_url":"https://codeload.github.com/dapphub/ds-roles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670503,"owners_count":21142901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authorization","dappsys","ds-auth","ethereum","solidity"],"created_at":"2024-11-15T12:19:45.158Z","updated_at":"2025-04-13T05:53:23.644Z","avatar_url":"https://github.com/dapphub.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch2\u003eDSRoles\n  \u003csmall class=\"text-muted\"\u003e\n    \u003ca href=\"https://github.com/dapphub/ds-roles\"\u003e\u003cspan class=\"fa fa-github\"\u003e\u003c/span\u003e\u003c/a\u003e\n  \u003c/small\u003e\n\u003c/h2\u003e\n\n_A DSAuthority for up to 256 roles_\n\nA role-driven `authority` for [ds-auth](https://dapp.tools/dappsys/ds-auth) \nwhich facilitates access to lists of user roles and capabilities. Works as a \nset of lookup tables for the `canCall` function to provide boolean answers\nas to whether a user is authorized to call a given function at given address.\n\nThe ability to check permissions in constant time is entirely due to the\nartificial constraint on the number of roles. 256 was chosen because this lets\nus abuse the large word size and cheap bitwise operations.\n\nIn the context of providing `authority` for DSAuth, a `user` is the `msg.sender`.\nDSRoles provides 3 different ways of permitting/forbidding function call access \nto users, with root access being the most permissive:\n\n1. **Root Users** - any users added to the `_root_users`\n   whitelist will be authorized to call any function regardless of what roles or\n   capabilities might be defined.\n\n2. **Public Capabilities** - public capabilities are global\n   capabilities which apply to all users and take precedence over any user\n   specific role-capabilities which might be defined.\n    \n3. **Role Capabilities** - capabilities which are associated\n   with a particular role. Role capabilities are only checked if the user\n   does not have root access and the capability is not public.\n\n**Roles** are assigned to users by number:\n\n```solidity\nuint8 owner_role = 0;\nuint8 user_role = 1;\n\nsetUserRole(owner_address, owner_role, true);\nsetUserRole(user_address, user_role, true);\n```\n\n**Capabilities** can be assigned to anyone (public) or to a\n`role` permitting/forbidding access to a particular function\nat a given address:\n\n```solidity\naddress target = 0x123;  // code address\n\nbytes4 withdraw_sig = bytes4(sha3(\"withdrawAll()\"));\nsetRoleCapability(owner_role, target, withdraw_sig, true);\nsetRoleCapability(user_role, target, withdraw_sig, false);\n\nbytes4 deposit_sig = bytes4(sha3(\"deposit(uint256)\"));\nsetRoleCapability(user_role, target, deposit_sig, true);\n```\n\n### Actions\n\n#### `setRootUser`\ngrant root access to a given user (requires auth)\n\n#### `setUserRole`\nassign a role to given user (requires auth)\n\n#### `setPublicCapability`\nset public permissions for a given capability (requires auth)\n\n#### `setRoleCapability`\nset a capability for a given role (requires auth)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdapphub%2Fds-roles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdapphub%2Fds-roles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdapphub%2Fds-roles/lists"}