HTTP Authentication
Every work cycle with Veeam Backup Enterprise Manager REST API must begin with the client logon. The logon procedure includes the following steps:
- The client sends an unauthorized GET HTTP request to the base URL of Veeam Backup Enterprise Manager REST API:
https://<Enterprise-Manager>:9398/api/
- In the response body, the server returns links for creating a new logon session:
Response:
200 OK
Response Body:
<?xml version="1.0" encoding="utf-8"?>
<EnterpriseManager xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.veeam.com/ent/v1.0">
<Links>
<Link Href="https://enterprise04.tech.local:9398/api/logonSessions" Type="LogonSessionList" Rel="Down"/>
<Link Href="https://enterprise04.tech.local:9398/api/sessionMngr/?v=latest" Type="LogonSession" Rel="Create"/>
</Links>
<SupportedVersions>
<SupportedVersion Name="v1_5">
<Links>
<Link Href="https://enterprise04.tech.local:9398/api/sessionMngr/?v=v1_5" Type="LogonSession" Rel="Create"/>
</Links>
</SupportedVersion>
<SupportedVersion Name="v1_6">
<Links>
<Link Href="https://enterprise04.tech.local:9398/api/sessionMngr/?v=v1_6" Type="LogonSession" Rel="Create"/>
</Links>
</SupportedVersion>
<SupportedVersion Name="v1_7">
<Links>
<Link Href="https://enterprise04.tech.local:9398/api/sessionMngr/?v=v1_7" Type="LogonSession" Rel="Create"/>
</Links>
</SupportedVersion>
</SupportedVersions>
</EnterpriseManager>
- The client sends the POST HTTP requests to the obtained URL to create a new logon session.
In the header of the POST HTTP request, the client must provide the username and password of the account to be used for authentication. The account must have one of the following roles in Veeam Backup Enterprise Manager:
- Portal Administrators
- Portal Users
- Restore Operators
The user name format depends on the OS of the Enterprise Manager server:
- Microsoft Windows-based Enterprise Manager: specify a domain account in the DOMAIN\Username format, for example: TECH\william.fox. For a local account, the domain is optional.
- Linux-based Enterprise Manager: specify a domain account in the UPN format (Username@Domain), for example: william.fox@tech.local. If the account belongs to a child domain, specify the full name of the child domain, for example: william.fox@sub.tech.local, not william.fox@tech.local. For a local account, specify the user name only.
For logon, Veeam Backup Enterprise Manager REST API uses the Basic HTTP Authentication. For example, if the client uses the account with the following credentials:
- Username: User
- Password: Password
the client must compose the User:Password base64 encoded:
VXNlcjpQYXNzd29yZA==
Encode the Username:Password string in UTF-8 before you apply base64 encoding. If the decoded string is not valid UTF-8, Veeam Backup Enterprise Manager REST API reads it as ISO-8859-1 (Latin-1), the encoding that Windows PowerShell 5.1 and other .NET Framework clients use.
The Username:Password pair is supplied in the
Authorizationheader to the POST HTTP request. In the value of the header, the client must prependBasicbefore the Username:Password pair:Authorization: Basic VXNlcjpQYXNzd29yZA==
- The server analyzes the provided credentials and checks if the specified account has the Portal Administrator, Portal User or Restore Operator role in Veeam Backup Enterprise Manager.
- If the provided credentials are valid and logon has been successful, the server creates a new authentication token and returns it to the client with a representation of a new logon session.
- If Enterprise Manager is Linux-based and the user name contains a backslash (\), the server returns a 401 Unauthorized error with the following message: Specify a username in the UPN format (username@domain.com). The server does not check the credentials, and the failed attempt does not count toward account lockout.
- If the value of the
Authorizationheader cannot be parsed, for example, the decoded string does not contain a colon (:) between the user name and password, the server returns a 403 Forbidden error with the following message: Authorization header is invalid. - If the provided credentials are not valid or the
Authorizationheader is missing, the server returns a 401 Unauthorized error in response. The server also returns theWWW-Authenticateheader indicating the authorization scheme to be used, for example:
WWW-Authenticate: Basic Realm=RestSvc
- If logon is successful, the server returns the created authentication token in the
X-RestSvcSessionIdheader of the response. The client must obtain the returned authentication token and add it to the header of every subsequent request to the server.X-RestSvcSessionId: OsU6RL7OGkGKrPBGxKxURw==
In addition, Veeam Backup Enterprise Manager REST API returns the cookie token in the
Set-Cookieheader of the response. The cookie token is kept in the client. If HTTP cookies are enabled for the client, the client can automatically take the authentication token from the cookie and add it to every request to Veeam Backup Enterprise Manager REST API.Set-Cookie: X-RestSvcSessionId=OsU6RL7OGkGKrPBGxKxURw==; Path=/api;
If the client is set to send the authentication token both from the HTTP header and from the cookie, Veeam Backup Enterprise Manager REST API will use the cookie token and ignore the token sent in the
X-RestSvcSessionIdheader of the request.
Timeout Value for Idle Sessions
The timeout value for an idle logon session is 15 minutes. If the client sends no requests to the server for 15 minutes, the current session token expires. To continue working with Veeam Backup Enterprise Manager REST API, the client must obtain a new authentication token from the server.
Logout
To log out, the client must delete a created logon session. A URL for a session deletion is provided in the representation of the logon session resource:
|
<Link Rel="Delete" Type="LogonSession" Href="https://localhost:9398/api/logonSessions/d4130a8b-3f5a-4999-8a33-b02c7ff4b441" /> |
Tip |
|
For an example of the logon and logout procedures, see Beginner Example. |