Skip to content

feat: add GitHub App authentication support#5327

Merged
erka merged 3 commits into
v2from
rd/v2/github-app
Feb 7, 2026
Merged

feat: add GitHub App authentication support#5327
erka merged 3 commits into
v2from
rd/v2/github-app

Conversation

@erka

@erka erka commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

closes #5322

@codecov

codecov Bot commented Jan 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.96330% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.66%. Comparing base (f238264) to head (efc9676).
⚠️ Report is 3 commits behind head on v2.

Files with missing lines Patch % Lines
internal/storage/environments/environments.go 0.00% 20 Missing ⚠️
internal/credentials/credentials.go 73.77% 12 Missing and 4 partials ⚠️
...nal/coss/storage/environments/git/github/github.go 7.69% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v2    #5327      +/-   ##
==========================================
+ Coverage   60.54%   60.66%   +0.11%     
==========================================
  Files         138      138              
  Lines       13594    13681      +87     
==========================================
+ Hits         8231     8299      +68     
- Misses       4664     4680      +16     
- Partials      699      702       +3     
Flag Coverage Δ
integrationtests 34.44% <0.00%> (-0.17%) ⬇️
unittests 52.07% <55.96%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erka
erka force-pushed the rd/v2/github-app branch from b1318cb to 3e28514 Compare January 28, 2026 23:54
@erka
erka force-pushed the rd/v2/github-app branch 2 times, most recently from b0a23ee to c633edd Compare January 29, 2026 15:19
@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

👋 Hi @erka! Thanks for your contribution to this project.

It looks like one or more of your commits are missing a DCO (Developer Certificate of Origin) sign-off. The DCO is a simple way for you to certify that you have the right to submit this code under the project's license.

How to fix this:

# For future commits, use the -s flag
git commit -s -m "Your commit message"

# To sign off on existing commits in this PR
git rebase HEAD~$(git rev-list --count origin/v2..HEAD) --signoff
git push --force-with-lease

The -s flag adds this line to your commit message:
Signed-off-by: Your Name <[email protected]>

📋 View the failing DCO check for more details

For more information about the DCO, visit: https://developercertificate.org/

1 similar comment
@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

👋 Hi @erka! Thanks for your contribution to this project.

It looks like one or more of your commits are missing a DCO (Developer Certificate of Origin) sign-off. The DCO is a simple way for you to certify that you have the right to submit this code under the project's license.

How to fix this:

# For future commits, use the -s flag
git commit -s -m "Your commit message"

# To sign off on existing commits in this PR
git rebase HEAD~$(git rev-list --count origin/v2..HEAD) --signoff
git push --force-with-lease

The -s flag adds this line to your commit message:
Signed-off-by: Your Name <[email protected]>

📋 View the failing DCO check for more details

For more information about the DCO, visit: https://developercertificate.org/

@erka
erka force-pushed the rd/v2/github-app branch 4 times, most recently from 2af4041 to 0ff83bc Compare February 5, 2026 22:45
@erka erka added the v2 Flipt v2 label Feb 5, 2026
@erka erka added the needs docs Requires documentation updates label Feb 5, 2026
@erka
erka marked this pull request as ready for review February 5, 2026 23:17
@erka
erka requested a review from a team as a code owner February 5, 2026 23:17
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 5, 2026
@dosubot

dosubot Bot commented Feb 5, 2026

Copy link
Copy Markdown

Documentation Updates

1 document(s) were updated by changes in this PR:

Flipt SCM Providers and Git Integration
View Changes
@@ -10,15 +10,40 @@
 Each provider supports both cloud-hosted and self-hosted instances. For self-hosted deployments, specify the provider’s API URL in your environment configuration.
 
 ## Authentication Methods
-Authentication is configured per provider using credentials in your Flipt configuration. Supported methods include Personal Access Tokens (PAT), API tokens, and SSH keys. The recommended authentication format varies by provider:
-
-| Provider         | Recommended Auth Method | Basic Auth Format                      | Notes                              |
-|------------------|------------------------|----------------------------------------|------------------------------------|
-| GitHub           | Personal Access Token   | Username: token, Password: (empty)     |                                    |
-| GitLab           | Personal Access Token   | Username: oauth2, Password: token      |                                    |
-| Bitbucket        | API Token              | Username: (not used), Token: api_token | App passwords deprecated Sept 2025 |
-| Azure DevOps     | Personal Access Token   | Username: username, Password: PAT      |                                    |
-| Gitea            | Personal Access Token   | Username: token, Password: (empty)     |                                    |
+Authentication is configured per provider using credentials in your Flipt configuration. Supported methods include Personal Access Tokens (PAT), API tokens, SSH keys, and (for GitHub) GitHub App authentication. The recommended authentication format varies by provider:
+
+| Provider         | Recommended Auth Method         | Basic Auth Format                      | Notes                              |
+|------------------|-------------------------------|----------------------------------------|------------------------------------|
+| GitHub           | Personal Access Token or GitHub App | Username: token, Password: (empty)     | GitHub App authentication supported |
+| GitLab           | Personal Access Token          | Username: oauth2, Password: token      |                                    |
+| Bitbucket        | API Token                     | Username: (not used), Token: api_token | App passwords deprecated Sept 2025 |
+| Azure DevOps     | Personal Access Token          | Username: username, Password: PAT      |                                    |
+| Gitea            | Personal Access Token          | Username: token, Password: (empty)     |                                    |
+
+**GitHub App Authentication:**
+
+Flipt supports authenticating to GitHub and GitHub Enterprise using a GitHub App. This is recommended for organizations that require granular permissions and improved security over personal access tokens. To use GitHub App authentication, create a GitHub App with the necessary permissions (typically `contents` and `pull-requests`), install it on your repository, and generate a private key.
+
+Configure your credentials in Flipt as follows:
+
+```yaml
+credentials:
+  github_app:
+    type: github_app
+    github_app:
+      client_id: <your-github-app-client-id>
+      installation_id: <your-github-app-installation-id>
+      private_key_path: "/path/to/private-key.pem" # or use private_key_bytes instead
+      # api_url: "https://github.company.com/api/v3" # for GitHub Enterprise (optional)
+```
+
+- `client_id`: The App's Client ID (from GitHub App settings)
+- `installation_id`: The installation ID for your repository/organization
+- `private_key_path`: Path to the PEM-encoded private key file for the App
+- `private_key_bytes`: (alternative to private_key_path) The PEM-encoded private key as a string
+- `api_url`: (optional) The GitHub API URL for GitHub Enterprise
+
+You must provide exactly one of `private_key_path` or `private_key_bytes`. If both are provided, Flipt will return an error.
 
 **SSH Remote URL Normalization and Port Handling:**
 
@@ -28,7 +53,7 @@
 
 **Provider Requirements:**
 
-- **GitHub:** PAT with `contents` and `pull-requests` scopes.
+- **GitHub:** PAT with `contents` and `pull-requests` scopes, or GitHub App with equivalent permissions.
 - **GitLab:** PAT with `api`, `read_repository`, and `write_repository` scopes.
 - **Bitbucket Cloud:** API tokens (recommended) with repository and pull request scopes. App passwords deprecated June 2026.
 - **Bitbucket Server/Data Center:** Access tokens with repository and pull request permissions.
@@ -42,7 +67,16 @@
   github:
     type: access_token
     access_token: <your-personal-access-token>
-```
+  github_app:
+    type: github_app
+    github_app:
+      client_id: <your-github-app-client-id>
+      installation_id: <your-github-app-installation-id>
+      private_key_path: "/path/to/private-key.pem"
+```
+
+You can reference either credential in your storage backend configuration depending on your organization's requirements.
+
 
 ## Pull Request Creation and Management
 Flipt v2 models pull request workflows through its "merge proposals" feature. When you create a branch of an environment, Flipt uses Git to create a complete copy of the base environment. Merge proposals allow you to review and approve changes before merging, mirroring workflows found in GitHub Pull Requests, GitLab Merge Requests, and Bitbucket Pull Requests. Merge proposals require a Pro license.
@@ -176,7 +210,6 @@
 ```
 
 ### SSH Remote URL Normalization and Port Support
-
 When configuring a storage backend with SSH credentials, Flipt supports specifying the `remote` URL in any of the following formats:
 
 - HTTPS: `https://github.com/org/repo.git`

How did I do? Any feedback?  Join Discord

erka added 2 commits February 6, 2026 20:15
Signed-off-by: Roman Dmytrenko <[email protected]>

@markphelps markphelps left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks great just one question

return fmt.Sprintf("%s - %s/%d", g.Name(), g.ClientID(), g.InstallationID())
}

func (g *GitHubAppCredentials) SetAuth(r *http.Request) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what calls this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the implementation of go-git githttp.AuthMethod interface.

Comment thread internal/credentials/credentials.go Outdated
logger: logger,
clientID: c.ClientID,
installationID: c.InstallationID,
privateKey: privateKey,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we need to store the privateKey on the struct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

great catch!

Signed-off-by: Roman Dmytrenko <[email protected]>
@erka
erka force-pushed the rd/v2/github-app branch from 05b3c42 to efc9676 Compare February 6, 2026 23:14

@markphelps markphelps left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ship it! i'll include the PRs merged today in a new 2.6 release and work on docs. ty!!

@erka
erka merged commit 492ce41 into v2 Feb 7, 2026
28 of 29 checks passed
@erka
erka deleted the rd/v2/github-app branch February 7, 2026 05:25
@github-project-automation github-project-automation Bot moved this to Done in Flipt V2 Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs docs Requires documentation updates size:XL This PR changes 500-999 lines, ignoring generated files. v2 Flipt v2

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Feat : Support for Github app tokens for Authentication

2 participants