Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

csoc-foundation/WIF

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Action for Azure AD Workload Identity JWTs

This GitHub action acquires access tokens (JWTs) for federated Azure AD workload identities that have configured GitHub as Open ID Connect (OIDC) credential provider.

The access tokens can be used for any kind of API access or usage, like Microsoft Graph. The retrieved access token is stored as environment variable ACCESS_TOKEN within the GitHub Action workflow and can also be consumed from PowerShell.

WIF Overview

Usage

This action requires two mandatory inputs:

  • Azure AD Tenant ID
  • Azure AD App Registration Client ID

You can also pass the inputs via GitHub repository secrets to the GitHub action. Make sure to add the id-token permissions to your GitHub action.

Example workflow:

on: [push]

permissions:
  id-token: write
  contents: read

jobs:
  hello_world_job:
    runs-on: ubuntu-latest
    name: WIF Example
    steps:
      - name: Azure AD Workload Identity Federation
        uses: nicolonsky/WIF@v0.0.1
        with:
          tenant_id: '30204efd-acb7-41a7-9fe9-233cec0556c1'
          client_id: '504fd139-6825-4e25-ad7a-627f100ab466'
      - name: Do some Stuff
        run: |
          Install-Module -Name Microsoft.Graph.Authentication
          Connect-MgGraph -AccessToken $env:ACCESS_TOKEN
          Invoke-MgGraphRequest -Uri '/beta/organization' | Select-Object -ExpandProperty value
        shell: pwsh

Azure AD setup

  • In Azure AD you need to create an app registration:

    • Screenshot 2023-01-23 at 13 49 57
  • Add the desired permissions and do not forget to grant admin consent:

    • Screenshot 2023-01-23 at 13 50 50
    • Screenshot 2023-01-23 at 13 51 13
  • Add federated credentials:

    • Screenshot 2023-01-23 at 13 51 24
  • Specifiy your GitHub repository information

    • Screenshot 2023-01-23 at 13 52 18
  • Copy your tenant and client id

    • Screenshot 2023-01-23 at 13 53 13

Development

Building the action:

ncc build index.js -o dist

Ressources

About

GitHub workload identity federation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%