Authorization in Yandex.Cloud

When a user does something with a resource in Yandex.Cloud, IAM checks whether the user has the necessary access rights to perform this operation.

Users get permissions along with resource roles. For more information about how roles are assigned and how the list of permissions is checked, see How access management in Yandex.Cloud works.

Authentication in Yandex.Cloud

Before authorization, a user must get authenticated, i.e., log in under their account. Authentication is performed in different ways, depending on the type of account and the interface used.

Authentication with a Yandex.Passport account

Authentication is carried out automatically when you log in to your Yandex or Yandex.Connect account.

To configure authentication in the CLI, enter your OAuth token during profile initialization. The token will be saved in the profile configuration and authentication will work automatically.

Warning

If you are the owner of the cloud and you use your own account to access the API, remember that the owner of the cloud can perform any operations with cloud resources.

We recommend using a service account to work with the API. This way, you can assign only the roles that are necessary.

To perform operations in the API:

  1. Get an IAM token in exchange for your OAuth token.

  2. Specify the received IAM token when accessing Yandex.Cloud resources via the API. Pass the IAM token in the Authorization header in the following format:

    Authorization: Bearer <IAM-TOKEN>
    

    The IAM token is valid for 12 hours. After that period expires, get a new IAM token.

Service account authentication

To perform operations on behalf of your service account, specify the path to its authorized key in the service-account-key configuration during profile initialization. The key will be saved in the profile configuration and authentication will work automatically.

There are three ways to perform operations on behalf of a service account: