🌐
GitHub
github.com › google-github-actions › auth
GitHub - google-github-actions/auth: A GitHub Action for authenticating to Google Cloud. · GitHub
Workload Identity Federation is ... a long-lived credential and establishes a trust delegation relationship between a particular GitHub Actions workflow invocation and permissions on Google Cloud....
Starred by 1.3K users
Forked by 293 users
Languages   TypeScript 98.8% | JavaScript 1.2%
🌐
GitHub
github.com › marketplace › actions › azure-ad-workload-identity-federation
Azure AD Workload Identity Federation - GitHub Marketplace
This GitHub action acquires access tokens (JWTs) for federated Azure AD workload identities that have configured GitHub as Open ID Connect (OIDC) credential provider.
🌐
Firefly
firefly.ai › academy › setting-up-workload-identity-federation-between-github-actions-and-google-cloud-platform
Firefly | Setting Up Workload Identity Federation Between GitHub Actions and Google Cloud Platform
Workload Identity Federation, or WIF, is a way to authenticate non-GCP systems, such as GitHub Actions, GitLab CI/CD, Bitbucket Pipelines, and other third-party CI/CD tools, with Google Cloud services without using long-lived service account keys.
🌐
Microsoft Learn
learn.microsoft.com › en-us › entra › workload-id › workload-identity-federation
Workload Identity Federation - Microsoft Entra Workload ID | Microsoft Learn
You use workload identity federation to configure a user-assigned managed identity or app registration in Microsoft Entra ID to trust tokens from an external identity provider (IdP), such as GitHub or Google.
🌐
Databricks
docs.databricks.com › local development tools › authentication › authenticate using oauth token federation › enable token federation for ci/cd › github actions
Enable workload identity federation for GitHub Actions | Databricks on AWS
5 days ago - Subject claim: (Optional) The JWT claim that contains the workload identity (sub) value from the OIDC token. For GitHub, leave the field as sub, which encodes the repository, branch, tag, pull/merge request, or environment that triggered the workflow. To authenticate as a reusable workflow rather than the calling repository, see Authenticate using a reusable workflow. For example, the following Databricks CLI command creates a federation policy for an organization named my-org and a Databricks service principal numeric ID of 5581763342009999:
🌐
Google
docs.cloud.google.com › iam › identity and access management (iam) › configure workload identity federation with deployment pipelines
Configure Workload Identity Federation with deployment pipelines | Identity and Access Management (IAM) | Google Cloud Documentation
After you configure a workload identity pool to trust your GitHub repository, you can let workflows in that repository use their GitHub OIDC token to obtain short-lived Google Cloud credentials. You don't need to make any configuration changes in your GitLab account. After you configure a workload identity pool to trust your GitLab group, you can enable Workload Identity Federation for individual CI/CD jobs.
🌐
Google Cloud
cloud.google.com › blog › products › identity-security › enabling-keyless-authentication-from-github-actions
Enabling keyless authentication from GitHub Actions | Google Cloud Blog
December 7, 2021 - Whereas a JSON service account key is either accessible or inaccessible, Workload Identity Federation can be configured to selectively allow authentication based on properties in the downstream OIDC tokens. For GitHub Actions, that means you can, for example, restrict authentication to certain repositories, usernames, branch names, or published claims.
🌐
GitHub
github.com › aip-dev › google.aip.dev › blob › master › aip › auth › 4117.md
External Account Credentials (Workload Identity Federation)
In order to use workload identity ... are needed to configure workload identity pools, providers, service account impersonation and generate the JSON configuration file to be used by the auth libraries....
Author   aip-dev
Find elsewhere
🌐
GitHub
docs.github.com › en › actions › security-for-github-actions › security-hardening-your-deployments › configuring-openid-connect-in-google-cloud-platform
Configuring OpenID Connect in Google Cloud Platform - GitHub Docs
This guide gives an overview of how to configure GCP to trust GitHub's OIDC as a federated identity, and includes a workflow example for the google-github-actions/auth action that uses tokens to authenticate to GCP and access resources.
🌐
Medium
medium.com › google-cloud › workload-identity-federation-for-github-provider-a3db226fc52b
Workload Identity Federation for Github Provider | by Nguyen Hai-Truong | Google Cloud - Community | Medium
November 22, 2024 - A Workload Identity Pool is used to manage external identities outside the GCP environment. The following command will create a new pool named: github-wif-pool · gcloud iam workload-identity-pools create github-wif-pool \ --location="global" ...
Top answer
1 of 1
1

Issue with Google Drive API Authentication using GitHub Actions

I created my workload identity pool according to the Google GitHub Actions Auth documentation without any service account. Then I tried to connect to Google Drive, which requires an OAuth 2.0 access token. I used the following configuration:

- name: Authenticate with Google Cloud
    uses: 'google-github-actions/auth@v2'
    with:
        project_id: 'my-project'
        workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'

- name: Upload files to Google Drive
    uses: 'Burak-Atak/drive-upload@master'
    with:
      google_credentials_file_path: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}
      files_to_create: "app.spec"
      drive_folder_id: "242fgdfg345345"
      files_to_update: "requirements.txt"
      file_ids_to_update: "asdas3534fdgg"

However, I got the following error with below code:

def authenticate_google(self):
    credentials, project_id = load_credentials_from_file(
        os.environ["GOOGLE_APPLICATION_CREDENTIALS"],
        scopes=[
            'https://www.googleapis.com/auth/drive.file',
            'https://www.googleapis.com/auth/drive',
            'https://www.googleapis.com/auth/drive.metadata'
        ]
    )

    return build("drive", "v3", credentials=credentials)
googleapiclient.errors.HttpError: <HttpError 401 when requesting https://www.googleapis.com/upload/drive/v3/files?fields=id&alt=json&uploadType=multipart returned "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.". Details: "[{'message': 'Invalid Credentials', 'domain': 'global', 'reason': 'authError', 'location': 'Authorization', 'locationType': 'header'}]">

I realized I should use OAuth 2.0 for the Google Drive API. Then I changed my configuration to this:

- name: Authenticate with Google Cloud
  uses: google-github-actions/auth@v2
  with:
    workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
    project_id: '<PROJECT_ID>'
    service_account: '<PROJECT_ID>@<PROJECT_ID>.iam.gserviceaccount.com'
    token_format: 'access_token'
    access_token_lifetime: '60s'
    access_token_scopes: 'https://www.googleapis.com/auth/drive.file,https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/drive.metadata'

- name: Upload files to Google Drive
    uses: 'Burak-Atak/drive-upload@master'
    with:
      google_credentials_file_path: ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}
      files_to_create: "app.spec"
      drive_folder_id: "242fgdfg345345"
      files_to_update: "requirements.txt"
      file_ids_to_update: "asdas3534fdgg"

After this change, I started to get the following error even though I have the Service Account Token Creator and Owner roles in my service account:

google-github-actions/auth failed with: failed to generate Google Cloud OAuth 2.0 Access Token for <PROJECT_ID>@<PROJECT_ID>.iam.gserviceaccount.com: {
  "error": {
    "code": 403,
    "message": "Permission 'iam.serviceAccounts.getAccessToken' denied on resource (or it may not exist).",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "IAM_PERMISSION_DENIED",
        "domain": "iam.googleapis.com",
        "metadata": {
          "permission": "iam.serviceAccounts.getAccessToken"
        }
      }
    ]
  }
}

Solution

I figured out that I should add a service account to my workload pool. Check the "Connected service accounts" part in the Google Cloud Console. If there is no connected service account, you should add one.

🌐
GitHub
github.com › pfnet-research › gcp-workload-identity-federation-webhook
GitHub - pfnet-research/gcp-workload-identity-federation-webhook: This webhook is for mutating pods that will require GCP Workload Identity Federation access from Kubernetes Cluster.
This webhook is for mutating pods that will require GCP Workload Identity Federation access from Kubernetes Cluster. - pfnet-research/gcp-workload-identity-federation-webhook
Starred by 50 users
Forked by 15 users
Languages   Go 86.6% | Makefile 9.1% | Smarty 3.0% | Dockerfile 1.3% | Go 86.6% | Makefile 9.1% | Smarty 3.0% | Dockerfile 1.3%
🌐
GitHub
github.com › Azure › azure-workload-identity
GitHub - Azure/azure-workload-identity: Azure AD Workload Identity uses Kubernetes primitives to associate managed identities for Azure resources and identities in Azure Active Directory (AAD) with pods. · GitHub
Azure AD Workload Identity is the next iteration of Azure AD Pod Identity that enables Kubernetes applications to access Azure cloud resources securely with Azure Active Directory based on annotated service accounts.
Starred by 335 users
Forked by 108 users
Languages   Go 90.1% | Shell 4.7% | Makefile 3.7%
🌐
GitHub
github.com › salrashid123 › workload_federation_cloudrun_gcf
GitHub - salrashid123/workload_federation_cloudrun_gcf: Authenticating using Workload Identity Federation to Cloud Run, Cloud Functions · GitHub
Configure GCP Workload Identity with that OIDC provider · Deploy a Cloud Run application which requires Authentication. Use Workload Federation and IAM API to exchange the ambient OIDC token from step 1 for a Google-issued OIDC token
Author   salrashid123
🌐
GitHub
github.com › signalfx › gcp_workload_identity_federation
GitHub - signalfx/gcp_workload_identity_federation · GitHub
This repository provides tools to set up Workload Identity Federation in Google Cloud Platform (GCP) for granting access to Splunk integrations.
Starred by 2 users
Forked by 2 users
Languages   Python 53.8% | HCL 46.2%
🌐
Medium
mahendranp.medium.com › gcp-workload-identity-federation-with-github-actions-1d320f62417c
GCP: Enabling keyless authentication from GitHub Actions | by Mahendran | Medium
March 4, 2024 - Workload Identity Federation (WIF) is a pivotal method for utilizing an external authentication system to authorize access to Google Cloud Platform (GCP) resources such as AWS, Azure, GitHub or with any identity provider (IdP) that supports ...
🌐
GitHub
github.com › MicrosoftDocs › entra-docs › blob › main › docs › workload-id › workload-identity-federation.md
entra-docs/docs/workload-id/workload-identity-federation.md at main · MicrosoftDocs/entra-docs
Set up a user-assigned managed identity as a federated identity credential on an app registration. Read the workload identity overview to learn how to configure a Kubernetes workload to get an access token from Microsoft identity provider and ...
Author   MicrosoftDocs
🌐
DEV Community
dev.to › massimobonanni › azure-workload-identity-federation-and-github-actions-pf7
Azure Workload Identity Federation and GitHub Actions - DEV Community
May 2, 2023 - This approach was born to trust tokens from external identity provider, such as GitHub or Google (or other in the future). You first create a relationship between the identity (that can be a managed identity or an App registration) and the external identity provider. Once this relationship is created, every time the workload wants to authenticate itself against AzureAD, it retrieves a token from the external IdP and, uses it to request access token from AAD.