Skip to content

Commit

Permalink
feat: add GitHubActionRoleProps.subjectClaims
Browse files Browse the repository at this point in the history
to allow custom subject claims, not just repositories
  • Loading branch information
hertzsprung committed Oct 13, 2023
1 parent 4dfc6c3 commit 583fcee
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/oidc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ export interface GitHubActionRoleProps {
*
* For example, `['owner/repo1', 'owner/repo2'].
*/
readonly repos: string[];
readonly repos?: string[];

/**
* A list of subject claims.
* See https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect
*
* For example, `['repo:owner/repo1:ref:refs/heads/branch1', 'repo:owner/repo1:environment:prod']`
*/
readonly subjectClaims?: string[];

/**
* The name of the Oidc role.
Expand Down Expand Up @@ -110,7 +118,7 @@ export class GitHubActionRole extends Construct {
provider.openIdConnectProviderArn,
{
StringLike: {
[`${rawEndpoint}:sub`]: formatRepos(props.repos),
[`${rawEndpoint}:sub`]: formatRepos(props.repos ?? []).concat(props.subjectClaims ?? []),
},
},
'sts:AssumeRoleWithWebIdentity',
Expand Down

0 comments on commit 583fcee

Please sign in to comment.