github.com/argoproj/argo-cd/v2@v2.10.9/docs/operator-manual/rbac.md (about) 1 # RBAC Configuration 2 3 The RBAC feature enables restriction of access to Argo CD resources. Argo CD does not have its own 4 user management system and has only one built-in user `admin`. The `admin` user is a superuser and 5 it has unrestricted access to the system. RBAC requires [SSO configuration](user-management/index.md) or [one or more local users setup](user-management/index.md). 6 Once SSO or local users are configured, additional RBAC roles can be defined, and SSO groups or local users can then be mapped to roles. 7 8 ## Basic Built-in Roles 9 10 Argo CD has two pre-defined roles but RBAC configuration allows defining roles and groups (see below). 11 12 * `role:readonly` - read-only access to all resources 13 * `role:admin` - unrestricted access to all resources 14 15 These default built-in role definitions can be seen in [builtin-policy.csv](https://github.com/argoproj/argo-cd/blob/master/assets/builtin-policy.csv) 16 17 ### RBAC Permission Structure 18 19 Breaking down the permissions definition differs slightly between applications and every other resource type in Argo CD. 20 21 * All resources *except* application-specific permissions (see next bullet): 22 23 `p, <role/user/group>, <resource>, <action>, <object>` 24 25 * Applications, applicationsets, logs, and exec (which belong to an `AppProject`): 26 27 `p, <role/user/group>, <resource>, <action>, <appproject>/<object>` 28 29 ### RBAC Resources and Actions 30 31 Resources: `clusters`, `projects`, `applications`, `applicationsets`, 32 `repositories`, `certificates`, `accounts`, `gpgkeys`, `logs`, `exec`, 33 `extensions` 34 35 Actions: `get`, `create`, `update`, `delete`, `sync`, `override`,`action/<group/kind/action-name>` 36 37 Note that `sync`, `override`, and `action/<group/kind/action-name>` only have meaning for the `applications` resource. 38 39 #### Application resources 40 41 The resource path for application objects is of the form 42 `<project-name>/<application-name>`. 43 44 Delete access to sub-resources of a project, such as a rollout or a pod, cannot 45 be managed granularly. `<project-name>/<application-name>` grants access to all 46 subresources of an application. 47 48 #### The `action` action 49 50 The `action` action corresponds to either built-in resource customizations defined 51 [in the Argo CD repository](https://github.com/argoproj/argo-cd/tree/master/resource_customizations), 52 or to [custom resource actions](resource_actions.md#custom-resource-actions) defined by you. 53 The `action` path is of the form `action/<api-group>/<Kind>/<action-name>`. For 54 example, a resource customization path 55 `resource_customizations/extensions/DaemonSet/actions/restart/action.lua` 56 corresponds to the `action` path `action/extensions/DaemonSet/restart`. You can 57 also use glob patterns in the action path: `action/*` (or regex patterns if you have 58 [enabled the `regex` match mode](https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/argocd-rbac-cm.yaml)). 59 60 If the resource is not under a group (for examples, Pods or ConfigMaps), then omit the group name from your RBAC 61 configuration: 62 63 ```csv 64 p, example-user, applications, action//Pod/maintenance-off, default/*, allow 65 ``` 66 67 #### The `exec` resource 68 69 `exec` is a special resource. When enabled with the `create` action, this privilege allows a user to `exec` into Pods via 70 the Argo CD UI. The functionality is similar to `kubectl exec`. 71 72 See [Web-based Terminal](web_based_terminal.md) for more info. 73 74 #### The `applicationsets` resource 75 76 [ApplicationSets](applicationset/index.md) provide a declarative way to automatically create/update/delete Applications. 77 78 Granting `applicationsets, create` effectively grants the ability to create Applications. While it doesn't allow the 79 user to create Applications directly, they can create Applications via an ApplicationSet. 80 81 In v2.5, it is not possible to create an ApplicationSet with a templated Project field (e.g. `project: {{path.basename}}`) 82 via the API (or, by extension, the CLI). Disallowing templated projects makes project restrictions via RBAC safe: 83 84 ```csv 85 p, dev-group, applicationsets, *, dev-project/*, allow 86 ``` 87 88 With this rule in place, a `dev-group` user will be unable to create an ApplicationSet capable of creating Applications 89 outside the `dev-project` project. 90 91 #### The `extensions` resource 92 93 With the `extensions` resource it is possible configure permissions to 94 invoke [proxy 95 extensions](../developer-guide/extensions/proxy-extensions.md). The 96 `extensions` RBAC validation works in conjunction with the 97 `applications` resource. A user logged in Argo CD (UI or CLI), needs 98 to have at least read permission on the project, namespace and 99 application where the request is originated from. 100 101 Consider the example below: 102 103 ```csv 104 g, ext, role:extension 105 p, role:extension, applications, get, default/httpbin-app, allow 106 p, role:extension, extensions, invoke, httpbin, allow 107 ``` 108 109 Explanation: 110 111 * *line1*: defines the group `role:extension` associated with the 112 subject `ext`. 113 * *line2*: defines a policy allowing this role to read (`get`) the 114 `httpbin-app` application in the `default` project. 115 * *line3*: defines another policy allowing this role to `invoke` the 116 `httpbin` extension. 117 118 **Note 1**: that for extensions requests to be allowed, the policy defined 119 in the *line2* is also required. 120 121 **Note 2**: `invoke` is a new action introduced specifically to be used 122 with the `extensions` resource. The current actions for `extensions` 123 are `*` or `invoke`. 124 125 ## Tying It All Together 126 127 Additional roles and groups can be configured in `argocd-rbac-cm` ConfigMap. The example below 128 configures a custom role, named `org-admin`. The role is assigned to any user which belongs to 129 `your-github-org:your-team` group. All other users get the default policy of `role:readonly`, 130 which cannot modify Argo CD settings. 131 132 !!! warning 133 All authenticated users get *at least* the permissions granted by the default policy. This access cannot be blocked 134 by a `deny` rule. Instead, restrict the default policy and then grant permissions to individual roles as needed. 135 136 *ArgoCD ConfigMap `argocd-rbac-cm` Example:* 137 138 ```yaml 139 apiVersion: v1 140 kind: ConfigMap 141 metadata: 142 name: argocd-rbac-cm 143 namespace: argocd 144 data: 145 policy.default: role:readonly 146 policy.csv: | 147 p, role:org-admin, applications, *, */*, allow 148 p, role:org-admin, clusters, get, *, allow 149 p, role:org-admin, repositories, get, *, allow 150 p, role:org-admin, repositories, create, *, allow 151 p, role:org-admin, repositories, update, *, allow 152 p, role:org-admin, repositories, delete, *, allow 153 p, role:org-admin, projects, get, *, allow 154 p, role:org-admin, projects, create, *, allow 155 p, role:org-admin, projects, update, *, allow 156 p, role:org-admin, projects, delete, *, allow 157 p, role:org-admin, logs, get, *, allow 158 p, role:org-admin, exec, create, */*, allow 159 160 g, your-github-org:your-team, role:org-admin 161 ``` 162 163 ---- 164 165 Another `policy.csv` example might look as follows: 166 167 ```csv 168 p, role:staging-db-admin, applications, create, staging-db-project/*, allow 169 p, role:staging-db-admin, applications, delete, staging-db-project/*, allow 170 p, role:staging-db-admin, applications, get, staging-db-project/*, allow 171 p, role:staging-db-admin, applications, override, staging-db-project/*, allow 172 p, role:staging-db-admin, applications, sync, staging-db-project/*, allow 173 p, role:staging-db-admin, applications, update, staging-db-project/*, allow 174 p, role:staging-db-admin, logs, get, staging-db-project/*, allow 175 p, role:staging-db-admin, exec, create, staging-db-project/*, allow 176 p, role:staging-db-admin, projects, get, staging-db-project, allow 177 g, db-admins, role:staging-db-admin 178 ``` 179 180 This example defines a *role* called `staging-db-admin` with nine *permissions* that allow users with that role to perform the following *actions*: 181 182 * `create`, `delete`, `get`, `override`, `sync` and `update` for applications in the `staging-db-project` project, 183 * `get` logs for objects in the `staging-db-project` project, 184 * `create` exec for objects in the `staging-db-project` project, and 185 * `get` for the project named `staging-db-project`. 186 187 !!! note 188 The `scopes` field controls which OIDC scopes to examine during rbac 189 enforcement (in addition to `sub` scope). If omitted, defaults to: 190 `'[groups]'`. The scope value can be a string, or a list of strings. 191 192 Following example shows targeting `email` as well as `groups` from your OIDC provider. 193 194 ```yaml 195 apiVersion: v1 196 kind: ConfigMap 197 metadata: 198 name: argocd-rbac-cm 199 namespace: argocd 200 labels: 201 app.kubernetes.io/name: argocd-rbac-cm 202 app.kubernetes.io/part-of: argocd 203 data: 204 policy.csv: | 205 p, my-org:team-alpha, applications, sync, my-project/*, allow 206 g, my-org:team-beta, role:admin 207 g, user@example.org, role:admin 208 policy.default: role:readonly 209 scopes: '[groups, email]' 210 ``` 211 212 For more information on `scopes` please review the [User Management Documentation](user-management/index.md). 213 214 ## Policy CSV Composition 215 216 It is possible to provide additional entries in the `argocd-rbac-cm` 217 configmap to compose the final policy csv. In this case the key must 218 follow the pattern `policy.<any string>.csv`. Argo CD will concatenate 219 all additional policies it finds with this pattern below the main one 220 ('policy.csv'). The order of additional provided policies are 221 determined by the key string. Example: if two additional policies are 222 provided with keys `policy.A.csv` and `policy.B.csv`, it will first 223 concatenate `policy.A.csv` and then `policy.B.csv`. 224 225 This is useful to allow composing policies in config management tools 226 like Kustomize, Helm, etc. 227 228 The example below shows how a Kustomize patch can be provided in an 229 overlay to add additional configuration to an existing RBAC policy. 230 231 ```yaml 232 apiVersion: v1 233 kind: ConfigMap 234 metadata: 235 name: argocd-rbac-cm 236 namespace: argocd 237 data: 238 policy.tester-overlay.csv: | 239 p, role:tester, applications, *, */*, allow 240 p, role:tester, projects, *, *, allow 241 g, my-org:team-qa, role:tester 242 ``` 243 244 ## Anonymous Access 245 246 The anonymous access to Argo CD can be enabled using `users.anonymous.enabled` field in `argocd-cm` (see [argocd-cm.yaml](argocd-cm.yaml)). 247 The anonymous users get default role permissions specified by `policy.default` in `argocd-rbac-cm.yaml`. For read-only access you'll want `policy.default: role:readonly` as above 248 249 ## Validating and testing your RBAC policies 250 251 If you want to ensure that your RBAC policies are working as expected, you can 252 use the `argocd admin settings rbac` command to validate them. This tool allows you to 253 test whether a certain role or subject can perform the requested action with a 254 policy that's not live yet in the system, i.e. from a local file or config map. 255 Additionally, it can be used against the live policy in the cluster your Argo 256 CD is running in. 257 258 To check whether your new policy is valid and understood by Argo CD's RBAC 259 implementation, you can use the `argocd admin settings rbac validate` command. 260 261 ### Validating a policy 262 263 To validate a policy stored in a local text file: 264 265 ```shell 266 argocd admin settings rbac validate --policy-file somepolicy.csv 267 ``` 268 269 To validate a policy stored in a local K8s ConfigMap definition in a YAML file: 270 271 ```shell 272 argocd admin settings rbac validate --policy-file argocd-rbac-cm.yaml 273 ``` 274 275 To validate a policy stored in K8s, used by Argo CD in namespace `argocd`, 276 ensure that your current context in `~/.kube/config` is pointing to your 277 Argo CD cluster and give appropriate namespace: 278 279 ```shell 280 argocd admin settings rbac validate --namespace argocd 281 ``` 282 283 ### Testing a policy 284 285 To test whether a role or subject (group or local user) has sufficient 286 permissions to execute certain actions on certain resources, you can 287 use the `argocd admin settings rbac can` command. Its general syntax is 288 289 ```shell 290 argocd admin settings rbac can SOMEROLE ACTION RESOURCE SUBRESOURCE [flags] 291 ``` 292 293 Given the example from the above ConfigMap, which defines the role 294 `role:org-admin`, and is stored on your local system as `argocd-rbac-cm-yaml`, 295 you can test whether that role can do something like follows: 296 297 ```console 298 $ argocd admin settings rbac can role:org-admin get applications --policy-file argocd-rbac-cm.yaml 299 Yes 300 301 $ argocd admin settings rbac can role:org-admin get clusters --policy-file argocd-rbac-cm.yaml 302 Yes 303 304 $ argocd admin settings rbac can role:org-admin create clusters 'somecluster' --policy-file argocd-rbac-cm.yaml 305 No 306 307 $ argocd admin settings rbac can role:org-admin create applications 'someproj/someapp' --policy-file argocd-rbac-cm.yaml 308 Yes 309 ``` 310 311 Another example, given the policy above from `policy.csv`, which defines the 312 role `role:staging-db-admin` and associates the group `db-admins` with it. 313 Policy is stored locally as `policy.csv`: 314 315 You can test against the role: 316 317 ```console 318 $ # Plain policy, without a default role defined 319 $ argocd admin settings rbac can role:staging-db-admin get applications --policy-file policy.csv 320 No 321 322 $ argocd admin settings rbac can role:staging-db-admin get applications 'staging-db-project/*' --policy-file policy.csv 323 Yes 324 325 $ # Argo CD augments a builtin policy with two roles defined, the default role 326 $ # being 'role:readonly' - You can include a named default role to use: 327 $ argocd admin settings rbac can role:staging-db-admin get applications --policy-file policy.csv --default-role role:readonly 328 Yes 329 ``` 330 331 Or against the group defined: 332 333 ```console 334 $ argocd admin settings rbac can db-admins get applications 'staging-db-project/*' --policy-file policy.csv 335 Yes 336 ```