Skip to content

feat: support passing multiple trustedRepositories#41

Open
blimmer wants to merge 4 commits into
aripalo:mainfrom
blimmer:support-multiple-repos
Open

feat: support passing multiple trustedRepositories#41
blimmer wants to merge 4 commits into
aripalo:mainfrom
blimmer:support-multiple-repos

Conversation

@blimmer
Copy link
Copy Markdown

@blimmer blimmer commented Nov 10, 2023

This PR introduces a new API that allows passing multiple subjects via the trustedRepositories property.

Fixes #35

@sonarqubecloud
Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 3 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
22.0% 22.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Comment thread src/role.ts
readonly trustedRepositories?: TrustedRepository[];
}

export interface TrustedRepository {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TrustedRepository takes the same top-level owner/repo and optionally filter props.

Comment thread src/role.ts
*
* @default - required if top-level owner/repo/filter not set
*/
readonly trustedRepositories?: TrustedRepository[];
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up for discussion - would it be clearer to deprecate / remove the top-level properties and force people to use trustedRepostories instead?

Comment thread src/role.ts

if (!trustedRepositoriesSet && (props.owner === undefined || props.repo === undefined)) {
cdk.Annotations.of(scope).addError("If you don't provide `trustedRepositories`, you must provide `owner` and `repo`.");
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decided to deprecate the top-level properties, we could annotate the deprecated properties here.

Comment thread src/role.ts
...roleProps,
assumedBy: new iam.WebIdentityPrincipal(provider.openIdConnectProviderArn, {
StringLike: {
'ForAnyValue:StringLike': {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be safe even if just one property is passed. From the docs:

ForAnyValue – This qualifier tests whether at least one member of the set of request context key values matches at least one member of the set of context key values in your policy condition. The context key returns true if any one of the context key values in the request matches any one of the context key values in the policy. For no matching context key or a null dataset, the condition returns false.

If we think people might be worried about seeing a cdk diff with this, we could optionally use ForAnyValue only when multiple repos are passed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When setting this up manually, StringLike also worked. As there is only one key in this map there should be no difference. The array of values is automatically evaluated as an OR

@blimmer blimmer marked this pull request as ready for review November 11, 2023 00:00
@blimmer
Copy link
Copy Markdown
Author

blimmer commented Nov 11, 2023

Quality gate seems to be complaining about the tests having duplication...

@blimmer
Copy link
Copy Markdown
Author

blimmer commented Jan 19, 2024

Hey @aripalo - any chance we can get this reviewed? If this isn't the direction you want to go with this repo, I might fork and publish a separate package. TYIA for your time and this great project!

@oxc
Copy link
Copy Markdown

oxc commented Sep 21, 2024

@blimmer, did you publish a fork after all? I would be interested in using it.

@blimmer
Copy link
Copy Markdown
Author

blimmer commented Sep 22, 2024

Hey @oxc. I didn't publish a fork. I'd really like to see if @aripalo would be open to integrating this behavior to have a single canonical project for this purpose. However, if they don't have bandwidth to review the PR, I can look into publishing a namespaced fork (e.g., @blimmer/aws-cdk-github-oidc.

@hoegertn
Copy link
Copy Markdown

@aripalo we can also consider integrating this within the https://github.com/open-constructs/aws-cdk-library

@blimmer
Copy link
Copy Markdown
Author

blimmer commented Jan 25, 2025

Since I haven't received a response to this PR for quite some time, I've decided to create my own replacement construct for this library: https://github.com/blimmer/cdk-github-oidc.

My library fixes this issue and all other outstanding issues for this repo. @aripalo, please feel free to archive this repo and point people at mine if you'd like.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 2, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
22.0% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: allow setting an array of filters (subjects)

3 participants