- Create a service account with no permissions for federation.
- If you do not attach a service account to compute resources or use the default service account, we recommend creating a new service account for the compute resources. Create a service account to attach to compute resources and impersonate the federation service account.
- Create an authorization policy to allow the federation service account to authenticate to Endor Labs.
- Provision the compute resources with the appropriate permissions.
- Test Keyless authentication.
Create GCP service accounts and authorization policies
To create your service accounts, first export your GCP project name as an environment variable:endorlabs-federation:
endorlabs-federation account. We’ll call this endorlabs-compute-service.
This is needed if you don’t already have service accounts for your compute resources. If you do, you need to modify the existing permissions to allow the existing service account to create a federation token.
Step 2: Create a keyless authentication service account to assign to compute resources called endorlabs-compute-service:
endorlabs-compute-service permissions to impersonate the endorlabs-federation account to authenticate to Endor Labs through OIDC.
Step 3: Assign the serviceAccountOpenIdTokenCreator role to the endorlabs-compute-service service account:
endorlabs-federation to your Endor Labs tenant:
Use the following command to create an authorization policy in Endor Labs.
Make sure to replace
<your-tenant> with your Endor Labs tenant name and <insert-your-project> with your GCP project name in the following command.Provision and test keyless authentication for GKE workloads
Prerequisites
The following prerequisites are required to setup keyless authentication on GKE workloads:- Workload identity is enabled on the target GKE cluster. See the GCP documentation on using workload identity for instructions on migrating existing cluster node pools or creating new clusters to use GCP workload identity.
- The gcloud auth plugin is installed and operational on your machine. See the GCP instructions on enabling the gcloud auth plugin for more details.
- The kubectl CLI is installed. See the Kubernetes documentation for instructions.
Procedure
- (Optional) Create a GKE cluster with workload identity enabled if you do not already have a GKE cluster
- Authenticate to the GKE cluster
- (Optional) Create a namespace for Endor Labs scans
- Create a Kubernetes service account to impersonate your GKE compute service account
- Bind your Kubernetes service account to your GCP compute service account
- Annotate your Kubernetes service account with your GCP service account to complete your binding
- Test a scanning workload using keyless authentication
Set up and test keyless authentication in GKE
The following instructions require you to export the following environment variables to appropriately run:- The GCP Project as PROJECT
- The GKE cluster as CLUSTER_NAME
Make sure to replace
<insert-your-project> in the following command with your GCP project name.If you have created a different service account name replace endorlabs-compute-service with the appropriate service account name.
Provision and Test Keyless Authentication for GCP Virtual Machine Instances
The following high-level procedure describes the required steps to use keyless authentication with a GCP virtual machine instance: Procedure:- Create a virtual machine instance with the appropriate scopes
- Download and install endorctl on the virtual machine instance
- Launch a test scan with keyless authentication
Set up and Test Keyless authentication on a GCP virtual machine instance
The following instructions require you to export the following environment variables to appropriately run:- The GCP Project as PROJECT
endorlabs-compute-service@$PROJECT.iam.gserviceaccount.com and the scope https://www.googleapis.com/auth/cloud-platform:
Step 1: To create a virtual machine instance with the appropriate scopes run the following command:
endorctl. See our documentation for instructions on downloading the latest version
To scan with keyless authentication you must use the flag --gcp-service-account=endorlabs-federation@<insert-your-project>.iam.gserviceaccount.com for federated access to Endor Labs such as in the below example: