[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud Registry](../../index.md) > [Step-by-step guides](../index.md) > Managing a registry > Managing registry access permissions > Assigning a role

# Assigning a role for a registry

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder where the registry is located.
  1. Navigate to **Cloud Registry**.
  1. Select the registry.
  1. Navigate to the **Access bindings** tab.
  1. Click **Assign roles**.
  1. In the window that opens, select a group, user, or [service account](../../../iam/concepts/users/service-accounts.md).
  1. Click ![image](../../../_assets/console-icons/plus.svg) **Add role** and select the role from the list.
  1. Click **Save**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  Run the following command to assign a role for a registry:

  * To a user:

    ```bash
    yc cloud-registry registry add-access-binding <registry_name_or_ID> \
      --role <role> \
      --user-account-id <user_ID>
    ```

  * To a [service account](../../../iam/concepts/users/service-accounts.md):

    ```bash
    yc cloud-registry registry add-access-binding <registry_name_or_ID> \
      --role <role> \
      --service-account-id <service_account_ID>
    ```

  * To all authenticated users (the `All authenticated users` [public group](../../../iam/concepts/access-control/public-group.md#allAuthenticatedUsers)):

    ```bash
    yc cloud-registry registry add-access-binding <registry_name_or_ID> \
      --role <role> \
      --allAuthenticatedUsers
    ```

  * To all users (the `All users` [public group](../../../iam/concepts/access-control/public-group.md#allUsers)):

    ```bash
    yc cloud-registry registry add-access-binding <registry_name_or_ID> \
      --role <role> \
      --subject system:allUsers
    ```

    Where `<role>` is the [role](../../security/index.md#service-roles) you want to assign.

  To revoke all roles from a registry and immediately assign new ones, use the `yc cloud-registry registry set-access-bindings` command.
  
  **Example**

  In the example below, we are assigning the `cloud-registry.admin` role for `my-first-registry` to a user.

  ```bash
  yc cloud-registry registry add-access-binding my-first-registry \
    --role cloud-registry.admin \
    --user-account-id ajeugsk5ubk6********
  ```

  Result:

  ```text
  done (4s)
  ```
- API {#api}

  Use the [updateAccessBindings](../../api-ref/Registry/updateAccessBindings.md) REST API method for the [Registry](../../api-ref/Registry/index.md) resource or the [RegistryService/UpdateAccessBindings](../../api-ref/grpc/Registry/updateAccessBindings.md) gRPC API call.

{% endlist %}

For more information on role assignment, see [this Yandex Identity and Access Management guide](../../../iam/operations/roles/grant.md).