One of the many major enhancements in VMware Cloud Foundation 4.0 is a switch from basic authentication to token based authentication for the VCF API.
Basic authentication is a header field in the form of Authorization: Basic <credentials>
, where credentials is the base64 encoding of a username and password. The credentials are not encrypted, therefore Basic Authentication is not the industry standard for API authentication.
VCF 4.0 has moved to using token based authentication (JWT Tokens to be exact) for securing the API. The token implementation is as follows:
- An authorized user executes a POST API call to /v1/tokens
- The response contains an access token and a refresh token
- The access token is valid for 1 hour
- The access token is passed in every API call header in the form of
Authorization: Bearer <access token>
- The access token is passed in every API call header in the form of
- The refresh token is valid for 24 hours
- The refresh token is used to request a new access token once it has expired
- The access token is valid for 1 hour
PowerVCF 2.0 abstracts all of this in the following way:
- An authorized user connects to SDDC Manager to request the tokens by running:
Connect-VCFManager -fqdn sfo-vcf01.sfo.rainpole.io -username svc-vcf-api@rainpole.io -password VMw@re1!
- The access & refresh tokens are stored in memory and used when running subsequent API calls. As each API call is executed PowerVCF checks the expiry of the access token. If the access token is about to expire, it uses the refresh token to request a new access token and proceeds with the API call. So the user does not need to worry about token management.
We have also introduced roles that can be assigned to users. Initially we have ADMIN & OPERATOR, with more roles planned for a future release.
ADMIN = Full Administrator Access to all APIs
OPERATOR = All Access except Password Management, User Management, Backup Management
To request an API token you must have a user account that is assigned either the ADMIN or OPERATOR role in SDDC Manager. The default administrator@vsphere.local user is assigned the ADMIN role during bringup but it is advisable to add additional users for performing day to day tasks.
Once you have a user added you can then authenticate with SDDC Manager to retrieve your access & refresh tokens.
Tip: You can connect using the administrator@vsphere.local user to add new users using PowerVCF. You can use the New-VCFUser PowerVCF cmdlet to create the user and assign a role like so:
Connect-VCFManager -fqdn sfo-vcf01.sfo.rainpole.io -username administrator@vsphere.LOCAL -password VMw@re1! New-VCFUser -user vcf-admin@rainpole.io -role ADMIN
Once your user is configured PowerVCF will do the rest when it comes to managing the API access tokens.
3 thoughts on “PowerVCF 2.0 Authentication Changes”