Updatable, unobtrusive Solidity authorization pattern

Martin Lundfall 434bf463b2 solc 0.6 compatibility 8 months ago
lib 52bbaf5ced dapp upgrade ds-test 8 months ago
src 434bf463b2 solc 0.6 compatibility 8 months ago
.gitignore 64d8e9e31a clean up and fix 3 years ago
.gitmodules 6ca7f26faa dapp-install ds-test 3 years ago
Dappfile 03f9df9aa5 clean up, add `auth_as' 3 years ago
LICENSE c0050bbb68 gpl3 3 years ago
Makefile 64d8e9e31a clean up and fix 3 years ago
README.md 52c6a32a85 updating README for dapp.tools 3 years ago
default.nix 8050e1eacd Add default.nix 2 years ago

README.md

DSAuth

Fully updatable unobtrusive auth

Provides a flexible and updatable auth pattern which is completely separate from application logic. By default, the auth modifier will restrict function-call access to the including contract owner and the including contract itself.

In addition, fine-grained function access can be controlled by specifying an authority - a contract which implements the DSAuthority interface to define custom access permissions.

Dappsys provides a couple of ready-made authority contracts, ds-guard and ds-roles, which can be used as authorities where updatable fine-grained permissioned auth is required.

Usage

The auth modifier provided by DSAuth triggers the internal isAuthorized function to require that the msg.sender is authorized ie. the sender is either:

  1. the contract owner;
  2. the contract itself;
  3. or has been granted permission via a specified authority.
function myProtectedFunction() auth {}

API

setOwner(address owner_)

Set a new owner (requires auth)

setAuthority(DSAuthority authority_)

Set a new authority (requires auth)