-
Notifications
You must be signed in to change notification settings - Fork 8
GitHub Setup
Insights Explorer primarily interfaces with GitHub on behalf of the logged-in user, but there are some actions performed with a service account. The service account can be any user with admin permissions on the default org. This service account must be configured prior to running Insights Explorer.
The following tasks use the service account:
- Syncing a repository to Insights Explorer
- Automatically adding users to the default org
- Querying information about users, repositories, collaborators
With the exception of adding users to the default org, these tasks all deal with reading data. Creating or editing Insights is always performed on behalf of a specific user.
The service account must be configured in two environment variables:
-
GITHUB_SERVICE_ACCOUNT
: Provides the GitHub user name of the service account -
GITHUB_ACCESS_TOKEN
: Provides a GitHub Personal Access Token owned by the service account
-
Login to GitHub as the user you want to act as the service account
-
Go to the Settings / Developer settings / Personal access tokens page
-
Click the
Generate new token
button -
Provide a note & set the expiration. If you select anything other than
No expiration
you will have to regenerate the token and update Insights Explorer when it expires. -
Select the following scopes:
repo
admin:org
read:user
user:email
admin:repo_hook
-
Click
Generate token
at the bottom of the page -
Copy and paste the token into your Insights Explorer configuration.
GITHUB_SERVICE_ACCOUNT=username
GITHUB_ACCESS_TOKEN=ghp_************************************
If you ever need to come back and update the token scopes, you can update without regenerating the token. If you ever regenerate the token, you will need to update Insights Explorer and restart it.
Insights Explorer creates new Insights in a configured GitHub organization (GITHUB_DEFAULT_ORG
). This org must be configured prior to running Insights Explorer; there is no default value.
If you already have a GitHub organization, you can connect Insights Explorer to it. Otherwise, you will need to create a new organization.
🎯 Tip: If you want to try out Insights Explorer, creating a new test organization will make it easier to clean up afterwards instead of using an existing org.
The following process is written for GitHub.com, but is applicable for either GitHub.com or GitHub Enterprise Server, although the interface might look slightly different.
- Open GitHub.com and ensure you are logged in. In the top right, click on the
+
button and selectNew organization
-
Select a pricing plan for the new organization depending on your needs. Insights Explorer works with the free option.
-
Fill out the organization form, including a unique name & contact email.
-
Once the organization is created, you can update the org profile, add additional users, etc.
-
Finally, use the name of the org to configure the
GITHUB_DEFAULT_ORG
environment variable in Insights Explorer.
GITHUB_DEFAULT_ORG=insights-explorer-rocks
Two important points about permissions and your new Organization:
-
In order to create a new Insight, a user must be a member of the org with permission to create new repositories. Insights Explorer uses the Personal Access Token of the logged in user to create repositories, rather than a service account.
-
In order to edit an existing Insight, a user must have write permission to the repository. This permission can either be inherited from the org, or they can be added as an outside collaborator directly on a repository.
OAuth2 is a protocol that lets external applications request authorization to private details in a user's GitHub account without accessing their password.
GitHub can be used as an OAuth provider for Insights Explorer. This means GitHub takes care of authenticating users, and securely passes that information back to Insights Explorer. IEX does not use this OAuth app to perform actions on behalf of the user; it only uses it to identify the user.
To configure this, a new GitHub OAuth app must be created. This app can be owned by a user or an organization. We recommend creating it on the default org used by Insights Explorer.
-
Open the Organization settings and go to the Settings / Developer settings / OAuth Apps page
-
Click the
New OAuth App
button -
Fill out the App form with meaningful values for name, homepage, and description.
-
Set the Authorization Callback URL to
auth/callback
on your Insights Explorer instance:- If you are planning run locally with Docker or Docker Compose, set it to http://localhost:3001/auth/callback
- If you are planning run locally from source (e.g.
npm start
), set it to http://localhost:3000/auth/callback - If you have deployed Insights Explorer with a dedicated URL or IP address, set it accordingly with a path of
auth/callback
-
Create the App.
-
Once created, you must generate a new client secret using the
Generate new client secret
button. -
Copy both the Client ID and Client Secret into your Insights Explorer configuration:
OAUTH_CLIENT_ID=***************
OAUTH_CLIENT_SECRET=*******************