Skip to content

Commit

Permalink
add assertion credential login support
Browse files Browse the repository at this point in the history
  • Loading branch information
adelinn authored Jan 5, 2025
1 parent 5763cc8 commit 7012799
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2025 BCC-forbundets Fellestjenester (norwegian organisation number 928453944)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ This action allows signing a GitHub App token using a key stored in Azure Key Va

Create a private key and upload it to Azure Key Vault.

Note: This action requires that the workflow has already logged in to Azure, either through the `az` CLI or through the `Azure/login` action. Alternatively it also supports loging in using `azurerm` Terraform provider's OIDC login method environment variables.

### Inputs

* `gh-app-client-id` - The Client ID of the GitHub App to sign the token for.
Expand Down
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
const core = require('@actions/core');
const { createHash } = require('crypto');
const { DefaultAzureCredential } = require('@azure/identity');
const { DefaultAzureCredential, ClientAssertionCredential } = require('@azure/identity');
const {
CryptographyClient,
KeyClient,
KnownSignatureAlgorithms
} = require('@azure/keyvault-keys');

try {
const credential = new DefaultAzureCredential();
let credential;
if (process.env.ARM_USE_OIDC == 'true' && process.env.ARM_TENANT_ID && process.env.ARM_CLIENT_ID && process.env.ARM_OIDC_TOKEN) {
const tenantID = process.env.ARM_TENANT_ID;
const clientID = process.env.ARM_CLIENT_ID;
const token = process.env.ARM_OIDC_TOKEN;
credential = new ClientAssertionCredential(tenantID, clientID, () => token);
} else {
credential = new DefaultAzureCredential();
}

const githubAppClientId = core.getInput('gh-app-client-id');
const keyVaultName = core.getInput('key-vault-name');
Expand Down

0 comments on commit 7012799

Please sign in to comment.