NickLiffen/ghas-enablement

Issue using GitHub App authentication

Closed this issue · 3 comments

We want to use this app with GitHub enterprise and have registered+installed this as a GitHub App under one of our organisations.

The first thing we notice when we try to use GitHub App authentication is that the .env.sample has a key "APP_ID" while the code refers to the key "GITHUB_APP_ID". However, if we change that and we run the application we run into another issue.

The example below gives an idea of which values we entered in our .env file (secrets have been replaced with similar strings of the same length). We retrieved the installation id from the installation URL (https://github.com/<our_organisation>/settings/installations/12345678).

GITHUB_APP_ID=123456
APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIIEowI ... \n-----END RSA PRIVATE KEY-----"
APP_INSTALLATION_ID=12345678
APP_CLIENT_ID=Iv1.7h9ldim2lpmxdryu
APP_CLIENT_SECRET=lgvtg1hzekulfcabat3gn1zksy38xkvf950px

When we try to list the repositories with the above configuration we run into the following issue:

jorsmat@NB-01514:~/repos/ghas-enablement$ node ./lib/src/getRepos.js
  ghas:inform Could not find file: ./bin/organizations.json. Assuming no organizations have been collected. +0ms
  ghas:inform Collecting repositories for liantisit-infra +2ms
  ghas:inform This is org number 1 of 1 +0ms
Error within function (githubAuth) [@octokit/auth-app] installationId option is required for installation authentication.
Error within function (graphQLClient) We failed to generate a token from the credentials provided on the GitHub App. Please re-check the credentails provided.
  ghas:error Error: We failed to generate the graphql Client
  ghas:error     at graphQLClient (/home/jorsmat/repos/ghas-enablement/lib/src/utils/clients/graphql.js:20:15)

If we run the script using a PAT it works as expected.

Looking into this now 👍

@jorsmatthys I have a fix coming in #40 👍

Looks like there was a change to the package. Thanks for logging this 👍

I confirm that it appears to work with GitHub App authentication now :) Thanks for the very quick fix !