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

GitHub OIDC trust condition #382

Closed
drey0143143 opened this issue Feb 11, 2022 · 4 comments
Closed

GitHub OIDC trust condition #382

drey0143143 opened this issue Feb 11, 2022 · 4 comments
Labels
duplicate This issue or pull request already exists

Comments

@drey0143143
Copy link

drey0143143 commented Feb 11, 2022

I would like to create a Trust relationship for an AWS Role Federated from GitHub via OIDC
that restrict access to request token based on the 2 conditions below.
a pull request to master in this repo
a push to master in this repo

I currently have the below condition working but struggling to restrict the permissions to the Role in AWS to only a pull request to master (and not to any branch)

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::123456789012:oidc-provider/token.actions.githubusercontent.com"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "ForAnyValue:StringLike": {
                    "token.actions.githubusercontent.com:sub": [
                        "repo:opeville/identity-opeville:ref:refs/heads/master",
                        "repo:opeville/identity-opeville:pull_request"
                    ]
                }
            }
        }
    ]
}
@VariableExp0rt
Copy link

I might be way off with this suggestion, but would it be worth doing this on the GH actions side? Something like

on:
  pull_request_target:
    types:
      - opened
    branches:    
      - 'master'
  push:
    branches:    
      - 'master'

Reference: GH docs

@peterwoodworth peterwoodworth added needs-triage This issue still needs to be triaged duplicate This issue or pull request already exists and removed needs-triage This issue still needs to be triaged labels Oct 4, 2022
@peterwoodworth
Copy link
Contributor

Closing in favor of #390, thanks for the issue submission!

@github-actions
Copy link

⚠️Comment Visibility Warning⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@peterwoodworth
Copy link
Contributor

Sorry, there's another related issue I meant to link to. #454

The last issue I linked isn't a direct duplicate since that feature request won't work for OIDC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants