You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/container-registry/container-registry-repository-scoped-permissions.md
+38-28Lines changed: 38 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Permissions to repositories in Azure Container Registry
3
3
description: Create a token with permissions scoped to specific repositories in a registry to pull or push images, or perform other actions
4
4
ms.topic: article
5
-
ms.date: 02/13/2020
5
+
ms.date: 05/27/2020
6
6
---
7
7
8
8
# Create a token with repository-scoped permissions
@@ -15,12 +15,13 @@ Scenarios for creating a token include:
15
15
* Provide an external organization with permissions to a specific repository
16
16
* Limit repository access to different user groups in your organization. For example, provide write and read access to developers who build images that target specific repositories, and read access to teams that deploy from those repositories.
17
17
18
+
This feature is available in **Premium** container registries. For information about registry service tiers and limits, see [Azure Container Registry service tiers](container-registry-skus.md).
19
+
18
20
> [!IMPORTANT]
19
21
> This feature is currently in preview, and some [limitations apply](#preview-limitations). Previews are made available to you on the condition that you agree to the [supplemental terms of use][terms-of-use]. Some aspects of this feature may change prior to general availability (GA).
20
22
21
23
## Preview limitations
22
24
23
-
* This feature is available in **Premium** container registries. For information about registry service tiers and limits, see [Azure Container Registry service tiers](container-registry-skus.md).
24
25
* You can't currently assign repository-scoped permissions to an Azure Active Directory identity, such as a service principal or managed identity.
25
26
* You can't create a scope map in a registry enabled for [anonymous pull access](container-registry-faq.md#how-do-i-enable-anonymous-pull-access).
26
27
@@ -47,7 +48,7 @@ To configure repository-scoped permissions, you create a *token* with an associa
47
48
* Configure multiple tokens with identical permissions to a set of repositories
48
49
* Update token permissions when you add or remove repository actions in the scope map, or apply a different scope map
49
50
50
-
Azure Container Registry also provides several system-defined scope maps you can apply, with fixed permissions across all repositories.
51
+
Azure Container Registry also provides several system-defined scope maps you can apply when creating tokens. The permissions of system-defined scope maps apply to all repositories in your registry.
51
52
52
53
The following image shows the relationship between tokens and scope maps.
53
54
@@ -63,7 +64,7 @@ The following image shows the relationship between tokens and scope maps.
63
64
64
65
### Create token and specify repositories
65
66
66
-
Create a token using the [az acr token create][az-acr-token-create] command. When creating a token, you can specify one or more repositories and associated actions on each repository. The repositories don't need to be in the registry yet. To create a token by specifying an existing scope map, see the next section.
67
+
Create a token using the [az acr token create][az-acr-token-create] command. When creating a token, you can specify one or more repositories and associated actions on each repository. The repositories don't need to be in the registry yet. To create a token by specifying an existing scope map, see the [next section](#create-token-and-specify-scope-map).
67
68
68
69
The following example creates a token in the registry *myregistry* with the following permissions on the `samples/hello-world` repo: `content/write` and `content/read`. By default, the command sets the default token status to `enabled`, but you can update the status to `disabled` at any time.
The output shows details about the token, including two generated passwords. It's recommended to save the passwords in a safe place to use later for authentication. The passwords can't be retrieved again, but new ones can be generated.
77
+
The output shows details about the token. By default, two passwords are generated. It's recommended to save the passwords in a safe place to use later for authentication. The passwords can't be retrieved again, but new ones can be generated.
77
78
78
79
```console
79
80
{
@@ -106,6 +107,9 @@ The output shows details about the token, including two generated passwords. It'
> If you want to regenerate token passwords and set password expiration periods, see [Regenerate token passwords](#regenerate-token-passwords) later in this article.
112
+
109
113
The output includes details about the scope map the command created. You can use the scope map, here named `MyToken-scope-map`, to apply the same repository actions to other tokens. Or, update the scope map later to change the permissions of the associated tokens.
The output shows details about the token, including two generated passwords. It's recommended to save the passwords in a safe place to use later for authentication. The passwords can't be retrieved again, but new ones can be generated.
136
+
The output shows details about the token. By default, two passwords are generated. It's recommended to save the passwords in a safe place to use later for authentication. The passwords can't be retrieved again, but new ones can be generated.
137
+
138
+
> [!NOTE]
139
+
> If you want to regenerate token passwords and set password expiration periods, see [Regenerate token passwords](#regenerate-token-passwords) later in this article.
133
140
134
141
## Create token - portal
135
142
@@ -138,14 +145,16 @@ You can use the Azure portal to create tokens and scope maps. As with the `az ac
138
145
The following example creates a token, and creates a scope map with the following permissions on the `samples/hello-world` repository: `content/write` and `content/read`.
139
146
140
147
1. In the portal, navigate to your container registry.
141
-
1. Under **Services**, select **Tokens (Preview) > +Add**.
142
-

148
+
1. Under **Repository permissions**, select **Tokens (Preview) > +Add**.
149
+
150
+
:::image type="content" source="media/container-registry-repository-scoped-permissions/portal-token-add.png" alt-text="Create token in portal":::
143
151
1. Enter a token name.
144
152
1. Under **Scope map**, select **Create new**.
145
153
1. Configure the scope map:
146
154
1. Enter a name and description for the scope map.
147
155
1. Under **Repositories**, enter `samples/hello-world`, and under **Permissions**, select `content/read` and `content/write`. Then select **+Add**.
148
-

156
+
157
+
:::image type="content" source="media/container-registry-repository-scoped-permissions/portal-scope-map-add.png" alt-text="Create scope map in portal":::
149
158
150
159
1. After adding repositories and permissions, select **Add** to add the scope map.
151
160
1. Accept the default token **Status** of **Enabled** and then select **Create**.
@@ -154,26 +163,26 @@ After the token is validated and created, token details appear in the **Tokens**
154
163
155
164
### Add token password
156
165
157
-
Generate a password after you create a token. To authenticate with the registry, the token must be enabled and have a valid password.
158
-
159
-
You can generate one or two passwords, and set an expiration date for each one.
166
+
To use a token created in the portal, you must generate a password. You can generate one or two passwords, and set an expiration date for each one.
160
167
161
168
1. In the portal, navigate to your container registry.
162
-
1. Under **Services**, select **Tokens (Preview)**, and select a token.
169
+
1. Under **Repository permissions**, select **Tokens (Preview)**, and select a token.
163
170
1. In the token details, select **password1** or **password2**, and select the Generate icon.
164
-
1. In the password screen, optionally set an expiration date for the password, and select **Generate**.
171
+
1. In the password screen, optionally set an expiration date for the password, and select **Generate**. It's recommended to set an expiration date.
165
172
1. After generating a password, copy and save it to a safe location. You can't retrieve a generated password after closing the screen, but you can generate a new one.
166
173
167
-

174
+
:::image type="content" source="media/container-registry-repository-scoped-permissions/portal-token-password.png" alt-text="Create token password in portal":::
168
175
169
176
## Authenticate with token
170
177
171
-
When a user or service uses a token to authenticate with the target registry, it provides the token name as a user name and one of its generated passwords. The authentication method depends on the configured action or actions associated with the token.
178
+
When a user or service uses a token to authenticate with the target registry, it provides the token name as a user name and one of its generated passwords.
179
+
180
+
The authentication method depends on the configured action or actions associated with the token.
172
181
173
182
|Action |How to authenticate |
174
183
|---------|---------|
175
-
|`content/delete`|`az acr repository delete` in Azure CLI|
176
-
|`content/read`|`docker login`<br/><br/>`az acr login` in Azure CLI |
@@ -195,7 +204,7 @@ docker tag hello-world myregistry.azurecr.io/samples/alpine:v1
195
204
196
205
### Authenticate using token
197
206
198
-
Run `docker login` to authenticate with the registry, Provide the token name as the user name, and provide one of its passwords. The token must have the `Enabled` status.
207
+
Run `docker login`or `az acr login`to authenticate with the registry to push or pull images. Provide the token name as the user name, and provide one of its passwords. The token must have the `Enabled` status.
199
208
200
209
The following example is formatted for the bash shell, and provides the values using environment variables.
201
210
@@ -226,7 +235,7 @@ The token doesn't have permissions to the `samples/alpine` repo, so the followin
To update the permissions of a token, update the permissions in the associated scope map. The updated scope map is applied immediately to all associated tokens.
232
241
@@ -245,7 +254,7 @@ az acr scope-map update \
245
254
In the Azure portal:
246
255
247
256
1. Navigate to your container registry.
248
-
1. Under **Services**, select **Scope maps (Preview)**, and select the scope map to update.
257
+
1. Under **Repository permissions**, select **Scope maps (Preview)**, and select the scope map to update.
249
258
1. Under **Repositories**, enter `samples/alpine`, and under **Permissions**, select `content/read` and `content/write`. Then select **+Add**.
250
259
1. Under **Repositories**, select `samples/hello-world` and under **Permissions**, deselect `content/write`. Then select **Save**.
251
260
@@ -280,9 +289,9 @@ az acr scope-map update \
280
289
--add samples/alpine content/delete
281
290
```
282
291
283
-
To update the scope map using the portal, see the preceding section.
292
+
To update the scope map using the portal, see the [previous section](#update-token-permissions).
284
293
285
-
Use the following [az acr repository delete][az-acr-repository-delete] command to delete the `samples/alpine` repository. To delete images or repositories, the token doesn't authenticate through `docker login`. Instead, pass the token's name and password to the command. The following example uses the environment variables created earlier in the article:
294
+
Use the following [az acr repository delete][az-acr-repository-delete] command to delete the `samples/alpine` repository. To delete images or repositories, pass the token's name and password to the command. The following example uses the environment variables created earlier in the article:
286
295
287
296
```azurecli
288
297
az acr repository delete \
@@ -303,11 +312,11 @@ az acr scope-map update \
303
312
--add samples/hello-world metadata/read
304
313
```
305
314
306
-
To update the scope map using the portal, see the preceding section.
315
+
To update the scope map using the portal, see the [previous section](#update-token-permissions).
307
316
308
317
To read metadata in the `samples/hello-world` repository, run the [az acr repository show-manifests][az-acr-repository-show-manifests] or [az acr repository show-tags][az-acr-repository-show-tags] command.
309
318
310
-
To read metadata, the token doesn't authenticate through `docker login`. Instead, pass the token's name and password to either command. The following example uses the environment variables created earlier in the article:
319
+
To read metadata, pass the token's name and password to either command. The following example uses the environment variables created earlier in the article:
311
320
312
321
```azurecli
313
322
az acr repository show-tags \
@@ -322,6 +331,7 @@ Sample output:
322
331
"v1"
323
332
]
324
333
```
334
+
325
335
## Manage tokens and scope maps
326
336
327
337
### List scope maps
@@ -333,7 +343,7 @@ az acr scope-map list \
333
343
--registry myregistry --output table
334
344
```
335
345
336
-
The output shows the scope maps you defined and several system-defined scope maps youcan use to configure tokens:
346
+
The output consists of the three system-defined scope maps and other scope maps generated by you. Tokens can be configured with any of these scope maps.
337
347
338
348
```
339
349
NAME TYPE CREATION DATE DESCRIPTION
@@ -359,9 +369,9 @@ Use the [az acr token list][az-acr-token-list] command, or the **Tokens (Preview
359
369
az acr token list --registry myregistry --output table
360
370
```
361
371
362
-
### Generate passwords for token
372
+
### Regenerate token passwords
363
373
364
-
If you don't have a token password, or you want to generate new passwords, run the [az acr token credential generate][az-acr-token-credential-generate] command.
374
+
If you didn't generate a token password, or you want to generate new passwords, run the [az acr token credential generate][az-acr-token-credential-generate] command.
365
375
366
376
The following example generates a new value for password1 for the *MyToken* token, with an expiration period of 30 days. It stores the password in the environment variable `TOKEN_PWD`. This example is formatted for the bash shell.
0 commit comments