Skip to content

Commit ad4db3b

Browse files
committed
Org & README updates
1 parent c8be728 commit ad4db3b

8 files changed

+33
-106
lines changed

README.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
# Create GitHub App Token
1+
# Create GitHub App Token using AWS KMS
22

33
[![test](https://github.com/actions/create-github-app-token/actions/workflows/test.yml/badge.svg)](https://github.com/actions/create-github-app-token/actions/workflows/test.yml)
44

5-
GitHub Action for creating a GitHub App installation access token using AWS KMS in order to safely store the GitHub repositry private key.
5+
GitHub Action for generating a GitHub App installation access token using AWS KMS in order to safely store the GitHub App private key. This is a fork of vanilla [create-github-app-token](https://github.com/actions/create-github-app-token) action. Unlike the vanilla version, the GitHub App private key is not stored as a secret in GitHub but it is imported in AWS KMS instead as an asymmetric sign-verify customer-managed key. Once imported, it can no longer be retrieved from AWS KMS. However, AWS KMS is capable of signing messages using the key, such as the JWT token used to generate the GitHub App installation access token.
6+
7+
In the vanilla action, the runner has direct access to sensitive information (i.e. the GitHub App private key). In case the runner gets compromised, a malicious actor could potentially get access to sensitive information and run arbitrary API calls, only limited by the GitHub App scope.
8+
9+
This action mitigates this risk by importing the sensitive information in a very secure location (AWS KMS) which does not allow the retrieval of the sensitive information.
10+
11+
>[!IMPORTANT]
12+
>Neither this action, nor AWS is responsible for securing access to your AWS account. See the [shared responsibility model](https://docs.aws.amazon.com/whitepapers/latest/aws-risk-and-compliance/shared-responsibility-model.html). It is highly advised to use temporary AWS credentials scoped to the least privilege when accessing AWS API in order to sign the JWT token.
13+
>Using AWS KMS will generate extra costs in your AWS bill.
14+
615

716
## Usage
817

918
In order to use this action, you need to:
1019

1120
1. [Register new GitHub App](https://docs.github.com/apps/creating-github-apps/setting-up-a-github-app/creating-a-github-app)
1221
2. [Store the App's ID in your repository environment variable](https://docs.github.com/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows) or [secret](https://docs.github.com/actions/security-guides/encrypted-secrets?tool=webui#creating-encrypted-secrets-for-a-repository) (example: `APP_ID`)
13-
3. [Import the App's private key in your AWS Account KMS service, under customer-managed keys of type assymetric, sign-verify](https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys-create-cmk.html)
14-
4. [Store the above KMS Key ID as a repository secret](https://docs.github.com/actions/security-guides/encrypted-secrets?tool=webui#creating-encrypted-secrets-for-a-repository) (example `KMS_KEY_ID`). Once stored in AWS KMS, the GitHub private key can no longer be retieved from AWS. AWS API can only by asked to sign/verify using the respective key. This substantially improves the security posture, because the key is no longer accessible.
22+
3. [Import the App's private key in your AWS Account KMS service, under customer-managed keys of type asymmetric, sign-verify, RSA 2048](https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys-create-cmk.html). Once imported in AWS KMS, the GitHub private key can no longer be retrieved from AWS. AWS API can only by asked to sign/verify using the respective key. This substantially improves the security posture, because the key is no longer accessible.
23+
4. [Store the above KMS Key ID as a repository secret](https://docs.github.com/actions/security-guides/encrypted-secrets?tool=webui#creating-encrypted-secrets-for-a-repository) (example `KMS_KEY_ID`)
1524
5. [Store the AWS role to be assumed by the action as a repository secret](https://docs.github.com/actions/security-guides/encrypted-secrets?tool=webui#creating-encrypted-secrets-for-a-repository) (example `ROLE_TO_ASSUME`)
1625
6. [Store the AWS session name as an environment_variable](https://docs.github.com/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows) (example `ROLE_SESSION_NAME`)
1726
7. [Store the AWS region name as an environment_variable](https://docs.github.com/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows) (example `AWS_REGION`)
@@ -373,7 +382,7 @@ GitHub App slug.
373382

374383
The action creates an installation access token using [the `POST /app/installations/{installation_id}/access_tokens` endpoint](https://docs.github.com/rest/apps/apps?apiVersion=2022-11-28#create-an-installation-access-token-for-an-app).
375384

376-
The action uses the GitHub private key stored in AWS KMS so sign a JWT token and uses this token subsequently for autheticating each GitHub API call, including the one above. Once stored in AWS KMS, the GitHub private key can no longer be retieved from AWS. AWS API can only by asked to sign/verify using the respective key. This substantially improves the security posture, because the action will no longer access the private key anymore, but ask AWS API to sign/verify instead.
385+
The action uses the GitHub private key stored in AWS KMS so sign a JWT token and uses this token subsequently for authenticating each GitHub API call, including the one above. Once stored in AWS KMS, the GitHub private key can no longer be retrieved from AWS. AWS API can only by asked to sign/verify using the respective key. This substantially improves the security posture, because the action will no longer access the private key anymore, but ask AWS API to sign/verify instead.
377386

378387
By default,
379388

package-lock.json

+1-89
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,11 @@
5050
}
5151
]
5252
]
53-
}
53+
},
54+
"main": "main.js",
55+
"directories": {
56+
"lib": "lib",
57+
"test": "tests"
58+
},
59+
"author": ""
5460
}

tests/main-missing-kms-key-id.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
process.env.GITHUB_REPOSITORY_OWNER = "lepadatu-org";
2-
process.env.GITHUB_REPOSITORY = "lepadatu-org/create-github-app-token-aws";
1+
process.env.GITHUB_REPOSITORY_OWNER = "lepadatu-actions";
2+
process.env.GITHUB_REPOSITORY = "lepadatu-actions/create-github-app-token-aws";
33
process.env["INPUT_APP-ID"] = "123456";
44

55
// Verify `main` exits with an error when neither the `kms-key-id` nor `kms_key_id` input is set.

tests/main-token-get-installation-access-token-fail-response.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ await test((mockPool) => {
1111
method: "POST",
1212
headers: {
1313
accept: "application/vnd.github.v3+json",
14-
"user-agent": "lepadatu-org/create-github-app-token-aws",
14+
"user-agent": "lepadatu-actions/create-github-app-token-aws",
1515
// Intentionally omitting the `authorization` header.
1616
},
1717
})

tests/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import { MockAgent, setGlobalDispatcher } from "undici";
44

55
export const DEFAULT_ENV = {
6-
GITHUB_REPOSITORY_OWNER: "lepadatu-org",
7-
GITHUB_REPOSITORY: "lepadatu-org/create-github-app-token-aws",
6+
GITHUB_REPOSITORY_OWNER: "lepadatu-actions",
7+
GITHUB_REPOSITORY: "lepadatu-actions/create-github-app-token-aws",
88
// inputs are set as environment variables with the prefix INPUT_
99
// https://docs.github.com/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
1010
"INPUT_GITHUB-API-URL": "https://api.github.com",

tests/snapshots/index.js.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Generated by [AVA](https://avajs.dev).
2424

2525
> stdout
2626
27-
`owner and repositories set, creating token for repositories "lepadatu-org/create-github-app-token-aws" owned by "lepadatu-org"␊
27+
`owner and repositories set, creating token for repositories "lepadatu-actions/create-github-app-token-aws" owned by "lepadatu-actions"␊
2828
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
2929
3030
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
@@ -93,7 +93,7 @@ Generated by [AVA](https://avajs.dev).
9393

9494
> stdout
9595
96-
`owner and repositories set, creating token for repositories "lepadatu-org/create-github-app-token-aws" owned by "lepadatu-org"␊
96+
`owner and repositories set, creating token for repositories "lepadatu-actions/create-github-app-token-aws" owned by "lepadatu-actions"␊
9797
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
9898
9999
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
@@ -132,7 +132,7 @@ Generated by [AVA](https://avajs.dev).
132132

133133
> stdout
134134
135-
`owner and repositories set, creating token for repositories "lepadatu-org/create-github-app-token-aws,actions/toolkit" owned by "lepadatu-org"␊
135+
`owner and repositories set, creating token for repositories "lepadatu-actions/create-github-app-token-aws,actions/toolkit" owned by "lepadatu-actions"␊
136136
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
137137
138138
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
@@ -151,7 +151,7 @@ Generated by [AVA](https://avajs.dev).
151151

152152
> stdout
153153
154-
`owner and repositories set, creating token for repositories "lepadatu-org/create-github-app-token-aws" owned by "lepadatu-org"␊
154+
`owner and repositories set, creating token for repositories "lepadatu-actions/create-github-app-token-aws" owned by "lepadatu-actions"␊
155155
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
156156
157157
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
@@ -170,7 +170,7 @@ Generated by [AVA](https://avajs.dev).
170170

171171
> stdout
172172
173-
`repositories not set, creating token for all repositories for given owner "lepadatu-org"␊
173+
`repositories not set, creating token for all repositories for given owner "lepadatu-actions"␊
174174
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
175175
176176
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
@@ -228,7 +228,7 @@ Generated by [AVA](https://avajs.dev).
228228

229229
> stdout
230230
231-
`owner not set, creating owner for given repositories "lepadatu-org/create-github-app-token-aws" in current owner ("lepadatu-org")␊
231+
`owner not set, creating owner for given repositories "lepadatu-actions/create-github-app-token-aws" in current owner ("lepadatu-actions")␊
232232
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
233233
234234
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊

tests/snapshots/index.js.snap

-2 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)