Authorization

With no security switched on, there is of course no authorization either. Once you have configured security, the default is that any user can perform any operation. However, GoCD can limit certain operations to particular Users or Roles, and manage membership of those Roles.

Administrators

GoCD allows you to restrict the users who can perform certain functions. Administrators is a special role that allows its members to perform any action in GoCD. Specifying administrators is optional – without it, all users are automatically made administrators.

If administrators are specified, only they can perform the following actions:

  • Access the “administration” tab
  • Add/Edit Pipeline Templates
  • Enable agents
  • Add / remove agent resources

Users can be made administrators from the “Users Management” section found under the “Admin” menu.

Authorizing Users - 图1

To give admin privileges to users and/or roles via “Config xml”, please refer to the example in the section below, where members of the “go_admin” role (jhumble and qiao), along with the user chris, can administer GoCD.

Role-based Access Control

You can define roles that can be used anywhere that authorization is required. A role is just a group of users. Administrators can add users to a new or existing role from the “User Summary” tab in the “Admin” section. Here, you can select any number of users and assign a new or existing role to them. In this example, user “aantony” is being added to the role “analyst”

Authorizing Users - 图2

For power users, here’s how you would configure roles via “Config XML”:

  1. <cruise>
  2. <server>
  3. <license... />
  4. <security>
  5. <passwordFile path="/etc/go-server/passwords.properties" />
  6. <roles>
  7. <role name="qa">
  8. <users>
  9. <user>dyang</user>
  10. <user>pavan</user>
  11. </users>
  12. </role>
  13. <role name="go_admin">
  14. <users>
  15. <user>jhumble</user>
  16. <user>qiao</user>
  17. </users>
  18. </role>
  19. </roles>
  20. <admins>
  21. <role>go_admin</role>
  22. <user>chris</user>
  23. </admins>
  24. </security>
  25. </server>
  26. </cruise>

In this example, the “qa” role has two users: dyang and pavan. The “go_admin” role also has two users: jhumble and qiao.

Starting GoCD 19.11.0, the roles can be configured to allow how the users assigned the role can access a GoCD entity. GoCD system administrators can now define a role with a policy that will contain a set of permissions to govern access of a GoCD entity for the users belonging to the role.

The following role definition would grant view action permissions for GoCD entity type environment with the matching wild card pattern:

  1. ...
  2. <roles>
  3. <role name="view-permissions">
  4. <policy>
  5. <allow type="environment" action="view">env*</allow>
  6. </policy>
  7. </role>
  8. </roles>
  9. ...

This means that any user which has the role view-permissions will get view access to the environments which have the name starting with env. You can read more about policy here.

Specifying permissions for pipeline groups

GoCD allows you to group pipelines together. If you define pipeline groups, you can specify who is able to view or operate those groups. To do this, you configure permissions to the pipeline group. System administrators will continue to have full access to the pipeline group even if they have not been explicitly granted permissions.


Note: If no authorization is defined for a pipeline group, it is viewable and operable only by GoCD system administrators.


The “view” permission allows users to view the pipeline. It does not give permission to trigger pipelines, approve stages, or re-run stages. In the below example, the users “akrishna” and “aantony” can view the pipelines in this group, but they cannot perform any operations on it.

The “operate” permission allows users to trigger pipelines and its stages. In the below example, the role “developer” is being granted the operate permission and will be able to trigger pipelines and its stages within this group.

The “admin” permission makes the user a Pipeline Group Administrator allowing them to view, operate and administer the pipeline group. In the below example, role “admins” has been granted this permission.

Note that is is possible to give a user or role only the operate permission. In the example below, the user “bot” only has operate permission. That means they can not view the pipeline, they can only operate it. This can be used to enable a script to operate on pipelines via the APIs without letting that user access any other features of GoCD.

To edit the permissions for a pipeline group, navigate to the “Pipelines” tab on the “Admin” section:

Authorizing Users - 图3

Then, click the “Edit” link for the pipeline group you want to manage permissions for:

Authorizing Users - 图4

For power users, here’s how you would configure permissions via “Config XML”:

  1. <pipelines group="Shine">
  2. <authorization>
  3. <view>
  4. <user>aantony</user>
  5. <user>akrishna</user>
  6. <role>developer</role>
  7. </view>
  8. <operate>
  9. <user>bot</user>
  10. <role>developer</role>
  11. </operate>
  12. <admins>
  13. <role>admins</role>
  14. </admins>
  15. </authorization>
  16. ...
  17. </pipelines>

Adding authorization to approvals

In GoCD, it is possible to specify manual approvals between stages. You can also specify which user is allowed to trigger manual approvals.

The authorization can be inherited from the pipeline group this pipeline belongs to. But defining specific permissions overrides this. In the example below, only members of the role “admin”, and the user “goleys”, can trigger the approval.

Authorizing Users - 图5

For power users, here’s how you would configure authorization for approvals for a stage via “Config XML”:

  1. <stage name="defaultStage">
  2. <approval type="manual">
  3. <authorization>
  4. <role>admin</role>
  5. <user>goleys</user>
  6. </authorization>
  7. </approval>
  8. <jobs>
  9. <job name="deploy">
  10. <resources>
  11. <resource>uat</resource>
  12. </resources>
  13. <tasks>
  14. <ant target="deploy" />
  15. </tasks>
  16. </job>
  17. </jobs>
  18. </stage>

Specifying permissions for templates

A GoCD Administrator can make any user a template administrator for a specific template. As a template administrator, a user can now view and edit the template to which he has permissions.

To edit the permissions for a template, navigate to the “Templates” tab on the “Admin” section:

Authorizing Users - 图6

Then, click the “Permissions” link for the template you want to manage permissions for:

Authorizing Users - 图7

For power users, here’s how you would configure permissions via “Config XML”:

  1. <templates>
  2. <pipeline name="app-1-template">
  3. <authorization>
  4. <admins>
  5. <user>operate</user>
  6. </admins>
  7. </authorization>
  8. ...
  9. </pipeline>
  10. </templates>

Also See