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

Add support for Github App Authentication #12

Merged
merged 4 commits into from
Oct 12, 2021

Conversation

petracvv
Copy link
Contributor

Description

This PR adds support for using Github App authentication at either the Org level or Repository level. To avoid adding dependencies on another interpreted language, I opted to implement the JWT signing and token retrieval in shell based on Github's docs and some helpful stack overflow articles.

The documentation update is only a minor edit of (https://github.com/actions-runner-controller/actions-runner-controller#deploying-using-github-app-authentication). I wasn't exactly certain how to attribute that (I added a section to the Credits section of the README) so any advice there is welcome.

If this PR is accepted, I plan on making one to the Helm chart to support this as well.

Related Issue(s)

There is no related issue in this repository; however there is one in the Helm Chart repository (redhat-actions/openshift-actions-runner-chart#4).

I guess I should have opened an issue here as well. Hopefully it's not too onerous to have the discussion in the PR instead.

Checklist

  • This PR includes a documentation change
  • This PR does not need a documentation change

  • This PR includes test changes (I didn't see any functionality tests)
  • This PR's changes are already tested

  • This change is not user-facing
  • This change is a patch change
  • This change is a minor change
  • This change is a major (breaking) change

Changes made

An overview of the changes:

  • Added support for GITHUB_APP_ID, GITHUB_APP_INSTALL_ID, and GITHUB_APP_PEM environmental variables
  • Added a get_github_app_token sh function to authenticate and retrieve a token tied to a Github App.
  • Updated the registration script to support authentication using the Github App method. If both Github App and PAT credentials are available, registration will prefer Github App authentication. Added a sh function for unregistration via github app auth.
  • Updated the entrypoint.sh to register the correct unregistration function and to detect if github app authentication is present.
  • Updated the Containerfile for the new environment variables and to pull in the new sh function and dependency (openssl)

Questions

I had a question about why you are using /bin/sh in all your registration scripts since /bin/bash is available in the Fedora image the runner is based on. I was unable to use process redirection ( <() ) in my github app token function because that is a bash-specific feature but the workaround (dumping credentials to a tmp directory then removing it) is not ideal. Would switching to /bin/bash be reasonable?

Otherwise please let me know if I can improve anything with this implementation or if you think it's better to just use a python script instead of shell for the JWT generation ( I have a version of this locally with a python implementation too).

@divyansh42 divyansh42 requested a review from tetchel September 27, 2021 03:01
@tetchel
Copy link
Contributor

tetchel commented Sep 29, 2021

This is amazing! I will take some time this week to test it out.

Copy link
Contributor

@tetchel tetchel left a comment

Choose a reason for hiding this comment

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

This is awesome. All these reviews are fairly minor because I am excited to get this in.

Thank you especially for documenting this change so well. Even if it is just adopted from elsewhere.

@petracvv
Copy link
Contributor Author

Ok. I think I got everything you wanted. Let me know if I missed anything!

@petracvv
Copy link
Contributor Author

One thing I'm noticing is your markdown link checker in your tests is failing on the placeholder links for creating the github app with the appropriate permissions. Is there a way to add exceptions to that?

@tetchel
Copy link
Contributor

tetchel commented Oct 12, 2021

@tetchel tetchel merged commit a0418b6 into redhat-actions:main Oct 12, 2021
@petracvv
Copy link
Contributor Author

Great! Thanks for the merge.

@petracvv petracvv deleted the github_actions branch October 12, 2021 18:05
tetchel pushed a commit to redhat-actions/openshift-actions-runner-chart that referenced this pull request Oct 14, 2021
@tetchel
Copy link
Contributor

tetchel commented Oct 14, 2021

I've released v1.2 with this change in (for the chart, it's v1.1), and rolled forward v1 to include it too.

@petracvv
Copy link
Contributor Author

Awesome! Thanks for all your help with reviews.

@tetchel
Copy link
Contributor

tetchel commented Oct 15, 2021

thank you for the best unsolicited contribution we've had so far! :)

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