Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove distinction between exact and wildcard subjects #3

Merged
merged 1 commit into from
Sep 15, 2022

Conversation

lawliet89
Copy link
Contributor

@lawliet89 lawliet89 commented Sep 15, 2022

  • Creating a StringLike and a StringEquals condition simultaneously
    turns this into an impossible task to fulfil.

Because both are ANDed together.

See https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_multi-value-conditions.html

e.g.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::12345678901:oidc-provider/app.terraform.io"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "app.terraform.io:sub": [
                        "organization:myorg:workspace:workspace:run_phase:apply",
                        "organization:myorg:workspace:workspace:run_phase:plan"
                    ]
                },
                "StringLike": {
                    "app.terraform.io:sub": "organization:sph:workspace:workspace-*:run_phase:*",
                    "app.terraform.io:aud": [
                        "tfc.workload.identity.org",
                        "tfc.workload.identity.myorg"
                    ]
                }
            }
        }
    ]
}

- Creating a `StringLike` and a `StringEquals` condition simultaneously
turns this into an impossible task to fulfil.

See https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_multi-value-conditions.html

e.g.

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::12345678901:oidc-provider/app.terraform.io"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "app.terraform.io:sub": [
                        "organization:myorg:workspace:workspace:run_phase:apply",
                        "organization:myorg:workspace:workspace:run_phase:plan"
                    ]
                },
                "StringLike": {
                    "app.terraform.io:sub": "organization:sph:workspace:workspace-*:run_phase:*",
                    "app.terraform.io:aud": [
                        "tfc.workload.identity.org",
                        "tfc.workload.identity.myorg"
                    ]
                }
            }
        }
    ]
}
```
@lawliet89 lawliet89 merged commit 0ce5ad6 into main Sep 15, 2022
@lawliet89 lawliet89 deleted the rm-wildcard-distinction branch September 15, 2022 10:54
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.

2 participants