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

OIDC not working with GitHub App #930

Open
AlissonRS opened this issue Nov 25, 2023 · 4 comments
Open

OIDC not working with GitHub App #930

AlissonRS opened this issue Nov 25, 2023 · 4 comments
Labels
bug Something isn't working p2

Comments

@AlissonRS
Copy link

Describe the bug

When trying to configure aws credentials setting the GITHUB_TOKEN env var using a GitHub App token, the action fails to fetch credentials with the error below:

It looks like you might be trying to authenticate with OIDC. Did you mean to set the id-token permission? If you are not trying to authenticate with OIDC and the action is working successfully, you can ignore this message.

The GitHub App is installed in the Organization and has the permissions required.

If I don't set the GITHUB_TOKEN and instead just add the usual permissions with id-token on the job, it works fine, but adding a permissions on the job makes it not possible to set GITHUB_TOKEN for other steps that need the GitHub App token instead of the temp token created by the workflow.

My workaround was to split my workflow into multiple jobs, so now I have an isolated job for configure-aws-credentials and other steps related to AWS (e.g. push docker image to ECR), but this is a bit tedious as now I need to checkout the code for every job, properly share outputs, using a single job was more convenient.

Another idea would be to just use assume role with static IAM credentials (e.g. access key and secret), but that's not the recommended way.

Expected Behavior

It should be able to fetch credentials using a GitHub App token from a workflow under the GitHub repo that was setup in the Identity Provider on AWS side.

Current Behavior

It fails to find the credentials.

Reproduction Steps

The workflow looks like this:

    steps:
      - name: Generate a token
        id: generate_token
        uses: actions/create-github-app-token@v1
        with:
          app-id: ${{ secrets.APP_ID }}
          private-key: ${{ secrets.APP_PRIVATE_KEY }}

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        env:
          GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
        with:
          role-to-assume: ${{ vars.AWS_GITHUB_ROLE_ARN }}
          aws-region: us-east-1

Possible Solution

I think by overriding the GITHUB_TOKEN, somehow AWS thinks the request is not coming from the authorized GitHub Repo, so perhaps this is a matter of actions/create-github-app-token@v1 having to support a way to generate a token on behalf of the organization (or user that triggered the workflow?).

So it's not clear if this issue can be fixed on this action.

Additional Information/Context

No response

@AlissonRS AlissonRS added bug Something isn't working needs-triage This issue still needs to be triaged labels Nov 25, 2023
@tim-finnigan
Copy link
Contributor

Thanks for reaching out. This looks like it may be related to past issues such as #373. Are the comments here or here helpful? Not sure if https://github.com/actions/create-github-app-token or somewhere else might be a better place for this discussion.

@tim-finnigan tim-finnigan added response-requested Waiting on additional info and feedback. Will move to 'closing-soon' in 5 days. and removed needs-triage This issue still needs to be triaged labels Nov 29, 2023
@AlissonRS
Copy link
Author

@tim-finnigan thanks for the quick reply.

I'm afraid my issue is not related to the links you shared, as that one is not related to using GitHub App for authentication, they are using public repo forks, and I'm using private repos without forks.

I posted here insteadd of the "create-github-app-token" repo because that error message is coming from this action, also other actions work fine with the token generated by the "create-github-app-token" action.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to 'closing-soon' in 5 days. label Nov 29, 2023
@AlissonRS
Copy link
Author

AlissonRS commented Nov 29, 2023

@tim-finnigan I went through this action's code, and figured that you validate if the ACTIONS_ID_TOKEN_REQUEST_TOKEN env var is set, otherwise the @actions/core action would fail anyway since it requires those packages.

So I logged an issue on create-github-app-token to better understand, maybe they just need to set this env var - as well as ACTIONS_ID_TOKEN_REQUEST_URL - so all of this works seamlessly.

I let this issue opened so you can see my comment, but feel free to close it.

Thanks for your help!!!

Copy link

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.

@AlissonRS AlissonRS reopened this Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2
Projects
None yet
Development

No branches or pull requests

2 participants