-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(boards2): initial permissions support #3151
feat(boards2): initial permissions support #3151
Conversation
Interface is defined based on Jae's idea to handle permissioned tasks. Co-authored-by: Jae Kwon <[email protected]>
Also rename `auth.gno` file to `permission.gno`
The `HasPermission` methods has been removed in favor of using the permissioner interface. Currently there is only a global permissioner but once the AdminDAO is implemented permissions will provably be handled by each individual board and the realm.
There are function that require checks that should be done by an implementer, like a DAO. Initially the implementer might choose to use proposals under the hood making it impossible to return the ID of a newly created entity syncronically. This change just adds permission support but the pattern must be improved to handle these cases.
This check might be reintroduced in the default permissioner implementation.
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
Removed two methods which are not yet used. These methods can be added later if boards2 requires them.
This implementation doesn't have support for proposals, it's only intended to have the minimal initial AdminDAO implementation required to start writting other boards2 features.
DAO only implementes support for members and eventually proposals. Roles and permissions should be managed by another entity.
Users must have the permission configured in the ACL and also be a member of the AdminDAO.
Role string | ||
|
||
// ACL or access control list manages user roles and permissions. | ||
ACL struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type could be named Permissions
(or DefaultPermissions
) instead of ACL
. Naming it ACL
makes sense thinking that it not only handles permissions but also roles.
args := Args{name, id} | ||
// TODO: Do the callback really need the args or we could have the same result directly referencing? | ||
gAuth.WithPermission(caller, PermissionBoardCreate, args, func(a Args) { // TODO: Caller could be an extra func arg | ||
name := a[0].(string) | ||
id := a[1].(BoardID) | ||
board := newBoard(id, name, caller) | ||
gBoardsByID.Set(id.Key(), board) | ||
gBoardsByName.Set(name, board) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sending the arguments to WithPermission
is necessary for the case where the Permissioner
interface implementer, for example a DAO, creates a proposal under the hood. The arguments could be considered parameters for the proposal in that case.
Does using the args in the callback function make sense? Code would be cleaner if outer variables are used instead. Or is it better for the VM to use args from the function instead of outer references?
Caller is normally used within the callback, so we could send the caller as an argument for the callback if we don't want to use outer references.
Using `WithPermission` is not needed in many cases at this point and it can be introduced once the functionalities are better defined.
Related to gnolang#3139 Permissioner interface is defined based on Jae's idea to handle permissioned tasks. --------- Co-authored-by: Jae Kwon <[email protected]>
Related to #3139