Home Page Technical VCF Platform

Automating vSphere Authorization with Global Authorization APIs

In a vSphere environment, authorization determines what actions an authenticated user is allowed to perform. Once a user is authenticated (i.e., their identity is verified), vSphere enforces access control through a combination of Privileges, Roles, and Permissions. Let’s break these down.

Understanding vSphere Authorization Constructs

Privileges

A Privilege is the most granular unit of access control. Each privilege corresponds to a specific action that a user can perform.

Examples:

  • VirtualMachine > Interaction > Power On
  • Content Library > Upload a file

Roles

A Role is a collection of one or more privileges. Roles are used to define the capabilities required for a user or group to carry out their tasks.

Examples:

  • Read-Only: Grants view-only access.
  • Administrator: Grants full access.
  • Custom Roles: Created by administrators to tailor specific privilege sets for specific needs.

Permissions

A Permission links a user (or group) to a role on a specific vSphere object. This binding determines who can do what, and where.

Example:
Assign the Power User role to user ‘holodeck-vmadmin’ on the datacenter object.

Why Automate Authorization?

Historically, vSphere administrators lacked native API support for managing roles, privileges, and permissions. This meant that access control operations had to be performed manually—a process prone to human error, inconsistencies, and operational overhead, especially in large-scale environments. With VMware Cloud Foundation (VCF) 9.0, a new set of Global Authorization APIs is now available. These APIs enable full lifecycle management of:

Global Authorization APIs

CategoryDescription
PrivilegesRetrieve and query vCenter authorization privileges
RolesCreate, update, delete, and list authorization roles
PermissionsCreate, update, delete, and list authorization permissions

Refer to the API documentation for full details.

API Usage Example: Creating a Custom Role

Objective

Create a new role called “Holodeck-VMAdmin” with the ability to perform a set of virtual machine operations.

Required Privileges

Using Postman

Step 1: Import OpenAPI Spec

  1. Download the VCF OpenAPI specification.
  2. Extract the zip and locate:
    vcf-api-specs-9.0.0.0-24798170/specifications/vsphere/openapi/automation/vcenter.yaml
  3. Set your vCenter base URL inside servers > url.

servers:

  1. Import vcenter.yaml into Postman.

Step 2: Authenticate and Create a Session

  1. Use the API: POST /api/session
  2. Provide your credentials in the body.
  3. Copy the token for subsequent requests.

Step 3: Create Role via API

Endpoint: POST /api/vcenter/authorization/roles

Request Body:

Step 4: Assign Permission

Endpoint:  POST /api/vcenter/authorization/permissions

Request Body:

Using VCF PowerCLI SDK

Currently PowerCLI offers the auto generated cmdlets from PowerCLI SDK module. Please check out the detailed blog post on how to use PowerCLI SDK. Below is the sample code to create a role and permission using PowerCLI SDK.

Using VCF Python SDK

Using VCF Java SDK

Refer to the VCF SDK Java GitHub samples for complete code examples.

Pro-Tips

  • Improve your API learning curve by utilizing OpenAPI specification documentation. By importing OpenAPI specification in postman or similar API client tool you can quickly use the APIs 
  • Currently, High level cmdlets are not available to provide authorization operation. Use VCF PowerCLI SDK as shown in example. Check out how to use VCF PowerCLI SDK
  • Browse to Global Authorization API Sample with VCF Python SDK and VCF Java SDK

VCF 9.0’s Global Authorization APIs transform vSphere authorization from a manual, error-prone task into an automated, consistent, and scalable process. These APIs empower you to:

  • Automate role and permission.
  • Enforce least privilege access across your environment.
  • Seamlessly integrate access control into your CI/CD and DevOps workflows.

Leverage the PowerCLI, Python, or Java SDKs to build custom automation, modernizing how you manage authorization within your VMware environments and meeting your specific operational needs.

Learning Resources

Demystifying VCF PowerCLI 9.0 SDK

Introducing a Unified VCF SDK 9.0 for Python and Java

Sample Code – Global Authorization APIs with VCF Python SDK 

Sample Code – Global Authorization API with VCF Java SDK