Authentication using Active Directory
If you have an identity federation, you can use Active Directory Federation Services (ADFS) to authenticate in the cloud.
To set up authentication:
- Create an identity federation in the cloud.
- Add certificates to the federation.
- Get a console login link.
- Configure authentication on the AD FS server.
- Add users to the cloud.
- Test the authentication process.
Before you start
To use the instructions in this section, you need:
-
The admin or resource-manager.clouds.owner role in the cloud.
-
A working ADFS farm. If you didn't configure ADFS on your server, install and configure it now. To deploy ADFS, you also need to install and configure Active Directory Domain Services (AD DS).
If you don't have a Windows machine to deploy an ADFS server, you can create a VM in Yandex.Cloud.
Tip
We recommend that you include more than one server in the farm to ensure more reliable authentication.
-
A valid certificate that is used for signing in the ADFS service. If you don't have a valid SSL certificate, get one.
The subject name in the certificate must contain the FQDN of the Identity Provider (IdP) server, for example,
fs.contoso.com
, to prevent the browser from blocking the authentication page.
Create a federation in the cloud
To create a federation in IAM:
-
Open the folder page in the management console.
-
Select the Federations tab in the left menu.
-
Click Create federation.
-
Enter a name for the federation. The name must be unique within the folder.
-
Add a description if necessary.
-
In the Cookie lifetime field, specify the time before the browser asks the user to re-authenticate.
-
Enter the link in
https://<ADFS>/adfs/services/trust
format in the IdP Issuer field, where<ADFS>
is the FQDN of your ADFS server. -
In the SSO method field, choose POST.
-
In the Link to the IdP login page field, enter the link in
https://[ADFS]/adfs/ls/
format, where<ADFS>
is the FQDN of your ADFS server. -
Enable Automatically create users to automatically add authenticated users to the cloud. This option simplifies the user setup, but users created this way are only assigned the
resource-manager.clouds.member
role by default: they can't do anything with cloud resources. Exceptions are the resources that theallUsers
orallAuthenticatedUsers
system group roles are assigned to.If this option is disabled, users who aren't added to the cloud can't log in to the management console, even if they authenticate with your server. In this case, you can manage the white list of users who are allowed to use Yandex.Cloud.
If you don't have the Yandex.Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
See the description of the create federation command:
$ yc iam federation create --help
-
Create a federation:
$ yc iam federation create --name my-federation \ --auto-create-account-on-login \ --cookie-max-age 12h \ --issuer "http://example.com/adfs/services/trust" \ --sso-binding POST \ --sso-url "https://example.com/adfs/ls/"
Where:
-
name
: Federation name. The name must be unique within the folder. -
auto-create-account-on-login
: Flag for automatically creating new users in the cloud after authenticating on the IdP server. This option simplifies the user setup, but users created this way are only assigned theresource-manager.clouds.member
role by default: they can't do anything with cloud resources. Exceptions are the resources that theallUsers
orallAuthenticatedUsers
system group roles are assigned to.If this option is disabled, users who aren't added to the cloud can't log in to the management console, even if they authenticate with your server. In this case, you can manage the white list of users who are allowed to use Yandex.Cloud.
-
cookie-max-age
: Time before the browser asks the user to re-authenticate. -
issuer
: IdP server ID to be used for authentication.Enter the link in
http://<ADFS>/adfs/services/trust
format, where<ADFS>
is the FQDN of your ADFS server. -
sso-url
: URL of the page that the browser redirects the user to for authentication.Enter the link in
https://[ADFS]/adfs/ls/
format, where<ADFS>
is the FQDN of your ADFS server. -
sso-binding
: Specify the Single Sign-on binding type. Most Identity Providers support thePOST
binding type.
-
-
Get the ID of the folder to create your federation in.
-
Create a file with the request body (for example,
body.json
):{ "folderId": "<folder ID>", "name": "my-federation", "autocreateUsers": true, "cookieMaxAge":"43200s", "issuer": "http://example.com/adfs/services/trust", "ssoUrl": "https://example.com/adfs/ls/", "ssoBinding": "POST" }
Where:
-
folderId
: ID of the folder. -
name
: Federation name. The name must be unique within the folder. -
autocreateUsers
: Flag for automatically creating new users in the cloud after authenticating on the IdP server. This option simplifies the user setup, but users created this way are only assigned theresource-manager.clouds.member
role by default: they can't do anything with cloud resources. Exceptions are the resources that theallUsers
orallAuthenticatedUsers
system group roles are assigned to.If this option is disabled, users who aren't added to the cloud can't log in to the management console, even if they authenticate with your server. In this case, you can manage the white list of users who are allowed to use Yandex.Cloud.
-
cookieMaxAge
: Time before the browser asks the user to re-authenticate. -
issuer
: IdP server ID to be used for authentication.Enter the link in
http://<ADFS>/adfs/services/trust
format, where<ADFS>
is the FQDN of your ADFS server. -
ssoUrl
: URL of the page that the browser redirects the user to for authentication.Enter the link in
https://[ADFS]/adfs/ls/
format, where<ADFS>
is the FQDN of your ADFS server. -
ssoBinding
: Specify the Single Sign-on binding type. Most Identity Providers support thePOST
binding type.
-
-
Create a federation using the create method:
$ curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <IAM token>" \ -d '@body.json' \ https://iam.api.cloud.yandex.net/iam/v1/saml/federations { "done": true, "metadata": { "@type": "type.googleapis.com/yandex.cloud.iam.v1.saml.CreateFederationMetadata", "federationId": "ajeobmje4dgj0belagb9" }, ...
The
federationId
property of the response contains the federation ID to save. You'll need this ID in the next steps.
Specify certificates for the identity federation
When the Identity Provider (IdP) informs Yandex.Cloud that a user passed authentication, they sign the message with their certificate. To enable Yandex.Cloud to verify this certificate, add it to the federation in IAM.
Tip
To ensure that authentication isn't interrupted when the certificate expires, we recommend adding several certificates to the federation: the current one and the ones that will be used after. If a certificate is invalid, Yandex.Cloud tries to verify the signature with a different one.
To get an ADFS certificate:
- Log in to your ADFS server and open Server Manager.
- Open the ADFS management console: Tools → ADFS Management.
- In the window that opens, click Services → Certificates in the tree on the left.
- Right-click the certificate in the Token-signing section and select View certificate.
- In the window that opens, go to the Details tab.
- Click the Copy to file button.
- Click Next.
- Select the format Base-64 encoded X. 509 (.CER) and click Next.
- Specify where to save the certificate and under what name, then click Next.
- Check the certificate export settings and click Finish.
To add a certificate to a federation:
- Open the folder page in the management console.
- Select the Federations tab in the left menu.
- Click the name of the federation you want to add a certificate to.
- Click Add certificate at the bottom of the page.
- Choose how to add the certificate:
- To add a certificate as a file, click Choose a file and specify the path to it.
- To paste the contents of a copied certificate, select the Text method and paste the contents.
If you don't have the Yandex.Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View a description of the add certificate command:
$ yc iam certificate create --help
-
Add a federation certificate by specifying the certificate file path:
$ yc iam certificate create --federation-name my-federation \ --name "my-certificate" \ --certificate-file test.pem
To add the certificate, use the create method for the Certificate resource:
-
Create a request body by specifying the contents of the certificate's
data
property:{ "federationId": "<federation ID>", "name": "my-certificate", "data": "MII...==" }
-
Send the add certificate request:
$ export IAM_TOKEN=CggaATEVAgA... $ curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${IAM_TOKEN}" \ -d '@body.json' \ "https://iam.api.cloud.yandex.net/iam/v1/saml/certificates"
Get a console login link
When you set up federation authentication, users can log in to the management console from a link containing the federation ID. You must specify the same link when configuring the authentication server.
Obtain and save this link:
-
Get the federation ID:
- Open the folder page in the management console.
- Select the Federations tab in the left menu.
- Copy the ID of the federation you're configuring access for.
-
Generate a link using this ID:
https://console.cloud.yandex.com/federations/<federation ID>
Configure authentication on the ADFS server
After you obtained your management console login link, you can configure the ADFS server to notify the management console of each successful authentication session and forward the user to the specified address to log in to the management console.
The instructions in this section are written for Windows Server 2016 (different steps might be needed for other versions).
To set up authentication on the ADFS server:
Create a relying party trust
ADFS requires a relying party trust for each Service Provider (SP) that uses ADFS for authentication.
Create a relying party trust for the federation you created in the cloud:
-
Log in to your ADFS server and open Server Manager.
-
Open the ADFS management console: Tools → ADFS Management.
-
In the list of actions, select Add Relying Party Trust.
-
The wizard window opens. On the first page, select Claims aware and click Start.
-
Select Enter data about the relying party manually and click Next.
-
Enter a name, like
Yandex.Cloud
, and click Next. -
In the next step, you are asked to specify a certificate for signing tokens. This step is optional, so click Next.
-
In the Configure URL step, select Enable support for the SAML 2.0 WebSSO protocol and specify the console login link you obtained earlier. Then click Next.
-
On the next page, enter the same console login link as an identifier and click Add. Then click Next.
-
On the next page, you can choose who can authenticate using this federation. By default, the Permit for everyone policy is selected enabling access for all users.
You can choose a different policy. For example, to grant access to a specific group of users, select Permit specific group and click on the word
<parameter>
to select the groups to allow access to. Read more about access control policies. -
Click Next.
-
On the Ready to Add Trust page, check the data entered and click Close.
Configure Claims Mapping
When ADFS authenticates a user, it sends an SAML message to Yandex.Cloud to confirm successful authentication. The NameID
element in this message identifies the user authenticated. For this, you need to configure the user data to match the elements of the SAML message.
Warning
The NameID
must be unique for every federation user. We recommend specifying the User Principal Name (UPN) or email address as the ID.
To configure mapping of user data to SAML message elements:
- In the ADFS management console under Relying Party Trusts, right-click on the relying party trust created earlier and select Edit Claim Issuance Policy.
- In the window that opens, click Add Rule.
- Select Send LDAP Attributes as Claims and click Next.
- On the next page, configure what to pass in the message fields:
-
In the Claim rule name field, enter a name for the rule, like
Claims mapping
-
In the Attribute Store field, click
Active Directory
. -
Specify what the server will return as Name ID to uniquely identify the user. To do this, add a line to the Mapping of LDAP attributes list:
Under LDAP Attribute, select
User-Principal-Name
orE-Mail Addresses
.In Outgoing Claim Type, select
Name ID
. -
For users to be able to contact Yandex.Cloud technical support from the management console, configure the server to pass an email address (
E-Mail Address
and the name of the user (Name
):You can also pass the user's first and last name separately. For this, use the
Given Name
andSurname
types instead ofName
.
-
- Click Finish, then click OKto close the Edit Claim Issuance Policy window.
Add users to the cloud
If you enabled the Automatically create users option when creating an identity federation, this step is optional. If you didn't enable it, you must add users to the cloud manually.
To add identity federation users to the cloud:
-
Open the Access management page for the selected cloud. If necessary, switch to another cloud.
- Click the arrow next to the Add user button.
- Select Add federated users.
- Select the identity federation to add users from.
- List the Name IDs of users, separating them with line breaks.
If you don't have the Yandex.Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View a description of the add user command:
$ yc iam federation add-user-accounts --help
-
Add users by listing their Name IDs separated by a comma:
$ yc iam federation add-user-accounts --name my-federation \ --name-ids=alice@example.com,bob@example.com,charlie@example.com
To add identity federation users to the cloud:
-
Create a file with the request body (for example,
body.json
). In the request body, specify the array of Name IDs of users you want to add:{ "nameIds": [ "alice@example.com", "bob@example.com", "charlie@example.com" ] }
-
Send the request by specifying the Federation ID in the parameters:
$ curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <IAM token>" \ -d '@body.json' \ https://iam.api.cloud.yandex.net/iam/v1/saml/federations/<federation ID>:addUserAccounts
Test the authentication process
When you finish configuring authentication with Active Directory, test that it runs properly:
-
Open the browser in guest or incognito mode to simulate being a new user.
-
Follow the management console login link you obtained earlier. The browser forwards you to the ADFS authentication page, which by default looks as follows:
-
Enter your authentication data. By default, you must enter the UPN and password. Then click Sign in.
-
On successful authentication, ADFS redirects you back to the management console login link and then to the management console home page. In the upper-right corner, you can see that you are logged in to the console under an Active Directory account.