Looking for a way to accomplish the command (via drush) to give permissions to all roles.

Right now if I use: drush perm-grant 'anonymous user' 'access devel information' I will end up with only that role having that permission. In fact, it even removed that permission from the Admin Role since there isn't a normal permission save to re-grant that role all permissions.

Would love to see this...
drush perm-grant all 'access devel information'

Extra note: Seems the output info on a failed permissions grant isn't quite right...

After trying: drush perm-grant all 'access devel information'
Get back:

WD permissions_api: permissions_grant_permissions: failed to get role .
Specified Permissions granted to all.

After trying: drush perm-grant 'access devel information'
Get back:

WD permissions_api: permissions_grant_permissions: failed to get role .
Specified Permissions granted to access devel information.

Comments

ebeyrent’s picture

Assigned: Unassigned » ebeyrent
doublejosh’s picture

Could it also/instead be possible to include multiple roles in a permissions drush command?

ebeyrent’s picture

Here's a list of all the actions it seems that Permissions API ought to support and expose via Drush.

grant N permissions to a role(s)
revoke N permissions from a role(s)

grant ALL permissions to a role(s)
revoke N permissions from a role(s)

grant N permissions to ALL roles
revoke N permissions from ALL roles

grant ALL permissions provided by a module to a role(s)
revoke ALL permissions provided by a module from a role(s)

grant ALL permissions a role has to another role(s)
revoke ALL permissions a role has from another role(s)

Does that cover all the use cases?

doublejosh’s picture

This is beyond what I was asking, but I'm sure those would all be useful.
Some of these require a major change in that N values are allowed.

The one case I was interested in is this: grant N permissions to ALL roles
However it would be faster like this: grant ALL permissions provided by a module to a role(s) to ALL role(s).
...which isn't in the list.

I'd want to use it like this: drush perm-grant all-mod devel all
Or like this: drush perm-grant all 'access devel information' 'display source code' 'switch users'
(in a dev environment of course)
However this might be super useful when deploying a new module to a number of Aegir sites along with required permissions.

BTW: "grant ALL permissions to a role(s)" would be covered by Admin Role, but no use excluding because of that.

ebeyrent’s picture

If I understand correctly, you want to be able to grant all permissions provided by a module to all roles. In your example, you wish to grant all permissions provided by the Devel module to all roles.

Is that correct?

grant N permissions to a role(s)
revoke N permissions from a role(s)

grant ALL permissions to a role(s)
revoke N permissions from a role(s)

grant N permissions to ALL roles
revoke N permissions from ALL roles

grant ALL permissions provided by a module to a role(s)
revoke ALL permissions provided by a module from a role(s)

grant ALL permissions provided by a module to ALL roles
revoke ALL permissions provided by a module from ALL roles

grant ALL permissions a role has to another role(s)
revoke ALL permissions a role has from another role(s)

doublejosh’s picture

Yeah that was my intension.

ebeyrent’s picture

I have added this functionality in the 3.x branch. I've refactored much of the drush interface to provide this functionality:

drush help perm-grant
Grant permissions to a role.

Examples:
 drush perm-grant --roles="Admin"          Grant all permissions provided by the Node module to the Admin role. 
 --modules="node"                                                                                               
 drush perm-grant --all-modules            Grant all permissions to Admin role.                                 
 --roles-="Admin"                                                                                               
 drush perm-grant --roles="Editor,Copy     Grant "administer nodes" to Editor and Copy Editor roles.            
 Editor" --permissions="administer nodes"                                                                       
 drush perm-grant --all-roles              Grant "administer nodes" permission to all roles.                    
 --permissions="administer nodes"                                                                               


Options:
 --all-roles                               Grant the permissions to all defined roles.                      
 --roles                                   Comma-separated list of roles to grant permissions to.           
 --permissions                             Comma-separated list of permissions to grant to a role or roles. 
 --modules                                 Comma-separated list of modules providing permissions to grant.  
 --all-modules                             Grant all defined permissions to a role or roles.  
drush help perm-revoke
Revoke permissions from a role.

Examples:
 drush perm-revoke --roles="Admin"         Revoke all permissions provided by the Node module from the Admin role. 
 --modules="node"                                                                                                  
 drush perm-revoke --all-modules           Revoke all permissions from the Admin role.                             
 --roles-="Admin"                                                                                                  
 drush perm-revoke --roles="Editor,Copy    Revoke "administer nodes" from the Editor and Copy Editor roles.        
 Editor" --permissions="administer nodes"                                                                          
 drush perm-revoke --all-roles             Revoke "administer nodes" permission from all roles.                    
 --permissions="administer nodes"                                                                                  
 drush perm-revoke --reset                 Revoke all permissions from all roles.  Requires confirmation, use with 
                                           caution.                                                                


Options:
 --all-roles                               Revoke the permissions from all defined roles.                         
 --roles                                   Comma-separated list of roles to revoke permissions from.              
 --permissions                             Comma-separated list of permissions to revoke from a role or roles.    
 --modules                                 Comma-separated list of modules providing permissions to revoke.       
 --all-modules                             Revoke all defined permissions from a role or roles.                   
 --reset                                   Revoke all defined permissions from all roles.  Requires confirmation, 
                                           use with caution.    
ebeyrent’s picture

Status: Active » Closed (fixed)
doublejosh’s picture

This is wonderful BTW.

doublejosh’s picture

Issue summary: View changes

strikethrough claim about removing permissions