propagate resolved roles in remoting context#2957
Merged
bajtos merged 1 commit intoMar 20, 2017
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For some advanced CRUD access control in remote methods, it is often required to get/check roles resolved (i.e. allowed) for a user against a method with
Role.getRoles(context)orRole.isInRole(role, context).In addition to clutter the remote methods / hooks code, it forces the app to run again through all static roles and registered dynamic role resolvers, inducing performance loss and extra calls to db.
Meanwhile, the exact same course of action is performed right when the
Model.checkAccess()method is called to verify if a principal is allowed to access a protected resource :Model.checkAccess(context)->ACL.checkAccessForContext(context)->acls.forEach(acl, ...)->roleModel.isInRole(acl.principalId, context)This PR proposes to add a new param (
Array) in remoting context (name proposed:resolvedRoles, to be discussed) which is filled during Model Access Permission Checking phase with the roles for which the user is allowed to run the remote method.an example of
resolvedRolesis:['admin', '$owner']where admin is a custom role statically mapped to a principal, and $owner is a built-in smart roleresolvedRolesparam can then be accessed in remote method and remote method hooks asctx.req.remotingContext.resolvedRolesTo be noted: the
resolvedRolesparam is set in a way that the calling user cannot temper the value to fool the additional access control policies added by user in remote methodsReviewers: please review/discuss the general idea before i provide the required tests
Related issues
Checklist
guide