GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing docs.stackstorm.com — Role Based Access Control — StackStorm 3.9.0 documentation Role Based Access ControlNote Prior to StackStorm 3.3, Extreme Networks provided a commercial version of the StackStorm automation platform which included Role Based Access Control (RBAC). As these enterprise features were donated to the Linux Foundation, RBAC is now available in StackStorm Open Source since 3.4. Role Based Access Control (RBAC) allows system administrators to restrict users’ access and limit the operations they can perform. For instance, you could give your database operator access only to the database-related actions. Read through the detailed overview below, or jump straight to a usage example. The source code for the RBAC module can be accessed at https://github.com/stackstorm/st2-rbac-backend. TerminologyThis section describes basic concepts with which you need to familiarize yourself, in order to understand and efficiently utilize RBAC. UserA user represents an entity (person/system) which needs to be authenticated and interacts with StackStorm through the API. User permissions are represented as a union of permission grants which are assigned to all the user roles. By default when a new StackStorm user is created, this user has no roles assigned to it, meaning it doesn’t have access to perform any API operation which is behind the RBAC wall. Note
RoleA role contains a set of permissions (permission grants) which apply to the resources. Permission grants are usually grouped together in a role using specific criteria (e.g. by project, location, team, responsibility, etc.). Roles are assigned to the users. Each user can have multiple roles assigned to it and each role can be assigned to multiple users. System RolesSystem roles are roles which are available by default and can’t be manipulated (modified and/or deleted). Currently, the following system roles are available:
Permission GrantPermission grant grants a particular permission (permission type) to a particular resource. For
example, you could grant an execute/run permission ( In general, there are five permission types available for each supported resource type:
In addition to that, there is also a special Keep in mind that in StackStorm a workflow is just an action so if you want someone to be able to
execute a particular workflow, you simply need to grant them As described in the table below, Available Permission TypesThe table below contains a list of all the available permission types. Global
Pack
Sensor Type
Action
Action Alias
Api Key
Key Value Pair
Rule
Runner Type
Execution
Trigger
Webhook
Trace
This list can also be retrieved using the RBAC meta API ( User PermissionsUser permissions (also called effective user permission set) are represented as a union of all the permission grants which are assigned to the user roles. For example, if a user has the following two roles assigned to it: --- name: "role_five" description: "Role which grants execute permission to my_action_1" permission_grants: - resource_uid: "action:dummy_pack_1:my_action_1" permission_types: - "action_execute" --- name: "role_six" description: "Role which grants execute permission to my_action_2" permission_grants: - resource_uid: "action:dummy_pack_1:my_action_2" permission_types: - "action_execute" The effective user permission set is:
RBAC system uses a whitelist approach which means there is no possibility of conflicting and contradictory permission grants in different roles (e.g. one role granting a particular permission and another role revoking it). ResourceIn the context of RBAC, a resource refers to the resource to which the permission grant applies to. Permission grants can be applied to the following resource types:
Note The support of key value pairs is only available in StackStorm v3.7.0 and above. A resource is identified by a You can retrieve the UID of a particular resource by listing all the resources of a particular type or by retrieving details of a single resource using either API or CLI. For example: st2 action list +-------------------------+-------------------------+-----------+-------------------------+-------------------------+ | uid | ref | pack | name | description | +-------------------------+-------------------------+-----------+-------------------------+-------------------------+ | action:core:remote | core.remote | core | remote | Action to execute | | | | | | arbitrary linux command | | | | | | remotely. | +-------------------------+-------------------------+-----------+-------------------------+-------------------------+ How it WorksUser permissions are checked when a user performs an operation using the API. If the user has the necessary permissions the API operation proceeds normally, otherwise an access denied error is returned and the error is logged in the audit log. Permission InheritancePack resources Pack resources inherit all the permissions from a pack. This means that if you grant
Executions Executions inherit permissions from the action they belong to and from the action’s parent pack. This
means that if you grant On top of that, granting Rule enforcements Rule enforcements (models that represent when a rule evaluated actually resulted in an action)
inherit permissions from the rule they belong to and from the rule’s parent pack. This means, if
a user has a Note that rule enforcements are Inquiries Inquiries inherit response permissions based on execution permissions of the workflow that generated them. This is useful for ensuring that anyone that has rights to execute a workflow that generates an Inquiry is also automatically granted permissions to respond to that Inquiry. Specifically, granting For detailed examples, see Securing Inquiries. Permissions and Executions Which Are Not Triggered via the APINormally when an execution is triggered via the API (POST to Rules - Effective user for executions which are triggered by a rule is the system user
(by default, ChatOps - Effective user for executions which are triggered via ChatOps (POST to
Enabling RBACTo configure RBAC you will need to manually enable it in To enable rbac, add this section to [rbac] enable = True backend = default Run To assign
Run Defining Roles and AssignmentsTo follow the infrastructure as code approach, roles and user role assignments are defined in YAML
files which are stored in Those definitions are simple YAML files means you can (and should) version control and manage them in the same way you version control and manage other source code and infrastructure artifacts. Both roles and user role assignments are loaded in lexicographical order based on the filename.
For example, if you have two role definitions in the files named Defining Roles and Permission GrantsRoles and permission grants are defined in YAML files which are stored in
Example role definition ( --- name: "sample" description: "Role which contains many different permission grants and serves for demonstration purposes" enabled: false permission_grants: - # Here we grant "pack_all" to "dummy_pack_1" pack which means user can perform all the # operations on this pack. resource_uid: "pack:dummy_pack_1" permission_types: - "pack_all" - # Here we grant "action_view" and "rule_view" to "dummy_pack_1" pack which means user # can view (list) all the actions and rules inside this pack. resource_uid: "pack:dummy_pack_1" permission_types: - "action_view" - "rule_view" - # Here we grant "rule_create" to "dummy_pack_1" pack which means user can create new # rules inside this pack. # Note: To be able to create a rule user also needs to have an "action_execute" permission # on the action used inside the rule. In case the rule trigger type is a webhook, user also # needs to have "webhook_create" permission on the corresponding webhook. resource_uid: "pack:dummy_pack_1" permission_types: - "rule_create" - # Here we grant "webhook_create" which allows user to create a webhook with a name of # "my_sample_webhook". # Keep in mind that webhooks have no parent resource so the permission grant is # directly on the webhook you want to allow a user to create. resource_uid: "webhook:my_sample_webhook" permission_types: - "webhook_create" - # Here we grant "action_execute" to "dummy_pack_2" which means user can execute (run) # all the actions inside this pack. Execute permission also grants "execution_re_run" # and "execution_stop" which means user can also re-run and stop (cancel) all the # executions which are triggered for the actions which belong to this pack. resource_uid: "pack:dummy_pack_2" permission_types: - "action_execute" - # Here we grant "action_all" to action "my_action_1" inside "dummy_pack_2" which means # user can perform all the operations (view, modify, execute and delete) on the # specified action. resource_uid: "action:dummy_pack_2:my_action_1" permission_types: - "action_all" - # Here we grant "action_execute" to action "my_action_2" inside "dummy_pack_2" allowing # user to execute (run) this particular action. resource_uid: "action:dummy_pack_2:my_action_2" permission_types: - "action_execute" - # Here we grant "rule_view" and "rule_modify" to rule "my_rule_1" inside "dummy_pack_2" allowing # user to view and modify (but not delete) this particular rule. resource_uid: "rule:dummy_pack_2:my_rule_1" permission_types: - "rule_view" - "rule_modify" - # Here we grant "webhook_send" to a webhook named "st2" (that's a generic webhook which exists # by default in every installation) allowing user to POST triggers to this particular webhook. # Keep in mind that the user needs to have "webhook_create" permissions on a particular webhook # if you want to allow user to create / register a new webhook via rule. resource_uid: "webhook:st2" permission_types: - "webhook_send" - # Here we grant "action_list" and "rule_list" allowing user to view / list all the actions and # rules permission_types: - "action_list" - "rule_list" The example above contains a variety of permission grants with corresponding explanations (comments). Defining User Role AssignmentsUser role assignments are defined in YAML files which are located in
Example role definition ( --- username: "user4" roles: - "role_one" - "observer" In the example above we assign two roles to the user named
Key Value PairsNote This functionality is only available in StackStorm v3.7.0 and above. Users with admin and system_admin roles have all access to system scoped KVPs. In v3.6.0 and before, users with admin role have full access to other users’ KVPs. This behavior is unchanged. By default, a user has access to his/her own user scoped KVPs without requiring specific permission grants. A non-admin user by default cannot access system scoped KVPs or other users’ KVPs. A non-admin user can be explicitly granted permission to one or more system scoped KVPs similar to how access to other resources are granted to users. Currently, there is no option or plan to grant non-admin user access to another user’s set of KVPs. The following is an example to assign a --- name: key1_write_role description: Role that allow users to set system key1 enabled: true permission_grants: - resource_uid: "key_value_pair:st2kv.system:key1" permission_types: - "key_value_pair_set" Applying RBAC DefinitionsAs described above, RBAC definitions are defined in YAML files located in the
Usually, you will want to run this script every time you modify the RBAC definitions. For example: st2-apply-rbac-definitions --config-file=/etc/st2/st2.conf 2015-08-12 22:30:18,439 - INFO - Synchronizing roles... 2015-08-12 22:30:18,441 - DEBUG - New roles: set([]) 2015-08-12 22:30:18,442 - DEBUG - Updated roles: set(['role_two', 'role_one', 'role_three']) 2015-08-12 22:30:18,442 - DEBUG - Removed roles: set([]) 2015-08-12 22:30:18,443 - DEBUG - Deleting 3 stale roles 2015-08-12 22:30:18,444 - DEBUG - Deleted 3 stale roles 2015-08-12 22:30:18,446 - DEBUG - Deleting 5 stale permission grants 2015-08-12 22:30:18,447 - DEBUG - Deleted 5 stale permission grants 2015-08-12 22:30:18,448 - DEBUG - Creating 3 new roles 2015-08-12 22:30:18,454 - DEBUG - Created 3 new roles 2015-08-12 22:30:18,458 - INFO - Synchronizing users role assignments... 2015-08-12 22:30:18,460 - DEBUG - New assignments for user "user1": set([]) 2015-08-12 22:30:18,461 - DEBUG - Updated assignments for user "user1": set(['role_two', 'role_one']) 2015-08-12 22:30:18,461 - DEBUG - Removed assignments for user "user1": set([]) 2015-08-12 22:30:18,462 - DEBUG - Removed 2 assignments for user "user1" 2015-08-12 22:30:18,464 - DEBUG - Created 2 new assignments for user "user1" Automatically Granting Roles Based on LDAP Group MembershipNote This functionality is only available in StackStorm v2.3.0 and above, with the LDAP auth backend used for authentication. In addition to manually assigning roles to the users based on the definitions in the
This comes handy in enterprise environments and makes StackStorm user provisioning easier and faster.
It means administrators don’t need to manually write and manage RBAC role assignment files on disk,
because roles are automatically granted to the users based on their LDAP group membership and
mappings files in To be able to utilize this feature it first needs to be enabled in [rbac] sync_remote_groups = True After this feature is enabled, the StackStorm administrator needs to write mapping files that tell StackStorm which roles to automatically grant to users, based upon LDAP group membership. Mapping files are located in the Two examples of such mapping files can be found below: Note LDAP group names referenced in the
Once the mapping definitions files are written, the StackStorm administrator needs to run the
How LDAP Group-Based Role Assignments WorkRole assignments based on the LDAP group to StackStorm role mappings are synchronized each time a user authenticates with the StackStorm auth API and receives a fresh auth token. If for some reason you want user roles to be synchronized before the existing auth token expires (default TTL is 24 hours), you can simply ask the user to re-authenticate to retrieve a new auth token. Alternatively, administrators can manually expire or disable an active auth token which will force the user to re-authenticate. A similar workflow can be used when removing a user from your system. By default, when a user is removed from LDAP they will still be able to use StackStorm if they have a valid auth token, until that auth token expires. If you want user access to be revoked as soon as they are removed from LDAP, you can manually purge active auth tokens for a particular user from the user database. Restricting Users to Only View Resources They Own or CreatedNote This functionality is disabled by default and is only available in StackStorm v2.7.0 and above. To enable it, you need to set the Currently it is only supported by the By default, a user needs The same applies to viewing a single resource (using “get one” API endpoint) - the user needs
When this feature is enabled, non-admin users can only view resources which belong to or are owned by
them (resource Examples with this feature enabled: 1. Admin user (can view all the resources)Authenticated as a user with admin role. curl "https://localhost/api/v1/rules" [ { "name": "rule1", "ref": "examples.rule1", ... "context": { "user": "admin" }, }, { "name": "rule2", "ref": "examples.rule2", ... "context": { "user": "user2" }, }, { "name": "rule3", "ref": "examples.rule3", ... "context": { "user": "user2" }, }, { "name": "rule4", "ref": "examples.rule4", ... "context": { "user": "user3" }, }, { "name": "rule5", "ref": "examples.rule5", ... "context": { "user": "user3" }, } ] 2. User “user2” can only view their own resourcesAuthenticated as “user2”. curl "https://localhost/api/v1/rules" [ { "name": "rule2", "ref": "examples.rule2", ... "context": { "user": "user2" }, }, { "name": "rule3", "ref": "examples.rule3", ... "context": { "user": "user2" }, } ] 3. User “user3” can only view their own resourcesAuthenticated as “user3”. curl "https://localhost/api/v1/rules" [ { "name": "rule4", "ref": "examples.rule4", ... "context": { "user": "user3" }, }, { "name": "rule5", "ref": "examples.rule5", ... "context": { "user": "user3" }, } ] Using RBAC ExamplePossible scenarios:
This example provides a walk-through of scenario 1 i.e configuring a user as a pack owner. The steps to be followed are by a StackStorm Administrator, on a system running StackStorm. User CreationAll user and password management is kept outside of StackStorm. Read the authentication docs to see how to configure to configure StackStorm with various identity providers. For sake of this example let us assume that the identity provider is managed by the OS on which StackStorm runs. On most Linux systems, to create a user and set their password, run this: $ useradd rbac_user1 $ passwd rbac_user1 Once this user is created StackStorm will allow access to this user. (Optional) To validate, try: $ st2 login rbac_user1 -p '<RBACU1_PASSWORD>' $ st2 action list Role CreationA newly created user has no assigned permissions. Each permission must be explicitly assigned to a user. To assign permission grants requires creation of a role and then associating this role with a user. In this case we are trying to create a pack owner role. Lets first make sure there is a pack $ cd /opt/stackstorm/packs/ $ mkdir example $ mkdir example/actions example/rules example/sensors $ touch example/pack.yaml $ touch /opt/stackstorm/configs/example.yaml $ touch example/requirements.txt $ cp core/icon.png example/icon.png Now we setup a role. Create --- name: "example_pack_owner" description: "Owner of pack example" enabled: true permission_grants: - resource_uid: "pack:example" permission_types: - "pack_all" - "sensor_type_all" - "rule_all" - "action_all" # Note: To be able to create a rule, the user also needs to have an "action_execute" permission # on the action used inside the rule. In this example, the rule created calls core.local action - resource_uid: "action:core:local" permission_types: - "action_execute" # Need runner_type_list on relevant runners - resource_uid: "runner_type:local-shell-cmd" permission_types: - "runner_type_list" A See available permission types for a full list of permission types. Role AssignmentCreation of a role is followed by assignment of a role to the user. Create the file
--- username: "rbac_user1" description: "Grant example_pack_owner role to rbac_user1 user." enabled: true roles: - "example_pack_owner" Applying RBACAs a StackStorm administrator, run: st2-apply-rbac-definitions --config-file=/etc/st2/st2.conf This command will sync the StackStorm RBAC state with the filesystem state. Only after running this command does StackStorm know of the latest changes to RBAC permission grants. ValidationLets take this for a spin using the StackStorm CLI.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |