Repository navigation
feat: GitHub App authentication - #43
Merged
Merged
Conversation
Besides a token, the plugin can now authenticate as a GitHub App installation (app_id, installation_id, and private_key_file or private_key), using short-lived installation tokens that ghinstallation renews. The same HTTP client backs the REST and GraphQL clients. A token still wins when set, so existing configs are unaffected. Re-implements #3 on the current master (go-github v93, the GraphQL client), adding validation of partial app credentials, plain-PEM inline keys, tests and docs. Co-authored-by: Gustavo Carvalho <gustavo@externalsecrets.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This was referenced Oct 28, 2026
gusfcarvalho
previously approved these changes
Oct 28, 2026
The agent sends plugin config over gRPC as a flat map<string, string>, which the plugin decodes into PluginConfig with the embedded, squashed AuthConfig. These tests send Configure through go-plugin's in-process gRPC harness: the token config every deployment sends today, a GitHub App config (with the empty keys agent configs declare for environment injection), and incomplete app credentials. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gusfcarvalho
approved these changes
Oct 28, 2026
alpoi
added a commit
to compliance-framework/plugin-dependabot
that referenced
this pull request
Oct 28, 2026
## Summary Lets the plugin authenticate as a **GitHub App installation** as an alternative to a token. Organizations can govern apps centrally, and the plugin only holds short-lived installation tokens, which [ghinstallation](https://github.com/bradleyfalzon/ghinstallation) renews as they expire. This is the same change as compliance-framework/plugin-github-repositories#43, which re-implements @gusfcarvalho's compliance-framework/plugin-github-repositories#3. It uses the same config keys: ```yaml plugins: dependabot: config: app_id: "123456" installation_id: "78901234" private_key_file: /etc/ccf/github-app.pem # or private_key: <PEM or base64 PEM> organization: octocat ``` ## Changes - `auth.go`: `AuthConfig` is embedded in `PluginConfig` (`mapstructure:",squash"`, so the keys stay flat) and carried on `ParsedConfig.Auth`, which replaces `ParsedConfig.Token`. It validates the credentials and builds the authenticated `http.Client` behind the go-github client. - Behaviour for existing configs is unchanged: - `token` still wins when set. - With no credentials at all, the plugin still calls GitHub unauthenticated, as before. - Only *incomplete* app credentials are a `Configure` error (for example `GitHub App authentication needs installation_id`). - `main_integration_test.go`: the `PluginConfig` literals now set `AuthConfig{Token: ...}`. - Tests for validation, the token, file, base64 and PEM paths, bad input, and decoding of the agent's flat config map. README: an authentication section with a GitHub App setup guide. - **Underscores, not hyphens,** unlike `included-repositories` and the plugin's other keys. The agent fills plugin config from `CCF_*` environment variables by uppercasing the key and replacing dots only, so a hyphenated `app-id` would need `CCF_PLUGINS_DEPENDABOT_CONFIG_APP-ID`, which shells can't set. local-dev and the hosted demo pass credentials this way, for example `CCF_PLUGINS_DEPENDABOT_CONFIG_PRIVATE_KEY`. The README notes this. ## Wiring - **gRPC round trip:** `auth_grpc_test.go` sends `Configure` through go-plugin's in-process gRPC harness (`TestPluginGRPCConn` with `runner.RunnerV2GRPCPlugin`), the same path the agent uses. The agent sends config as a flat `map<string, string>`, and the plugin decodes it after the gRPC hop, so the embedded `AuthConfig` (`mapstructure:",squash"`) never affects the wire format. The tests cover the token-only config every deployment sends today, an app config with the empty keys agent configs declare, and incomplete app credentials. Without `squash` they fail. - **local-dev:** compliance-framework/local-dev#135 declares the app keys in the showcase agent config (the agent only fills keys the file declares from `CCF_*` environment variables) and teaches the `demo-go-check-github` pre-flight about app credentials. ## Testing - `go vet ./...`, `go vet -tags integration ./...` and `go test ./...` pass. - golangci-lint v2.11.4 with the shared config reports nothing in the changed lines. The seven warnings it prints are already on `main`. - I haven't run it against a real GitHub App installation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Gustavo Carvalho <gustavo@externalsecrets.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
alpoi
added a commit
to compliance-framework/plugin-github-settings
that referenced
this pull request
Oct 28, 2026
## Summary Lets the plugin authenticate as a **GitHub App installation** as an alternative to a token. Organizations can govern apps centrally, and the plugin only holds short-lived installation tokens, which [ghinstallation](https://github.com/bradleyfalzon/ghinstallation) renews as they expire. This is the same change as compliance-framework/plugin-github-repositories#43, which re-implements @gusfcarvalho's compliance-framework/plugin-github-repositories#3. The config keys are the same: ```yaml plugins: github: config: app_id: "123456" installation_id: "78901234" private_key_file: /etc/ccf/github-app.pem # or private_key: <PEM or base64 PEM> organization: test-org ``` ## Changes - `auth.go`: `AuthConfig` (embedded in `PluginConfig` with `mapstructure:",squash"`, so the keys stay flat), validation, and the authenticated `http.Client` behind the go-github client. That client also carries the IP allow-list GraphQL query. - `Validate` now accepts a token *or* complete app credentials, and names any missing key (for example `GitHub App authentication needs installation_id`). `token` still wins when set, so existing configs behave as before. - Tests for validation, the token, file, base64 and PEM paths, bad input, and decoding of the agent's flat config map. README: a GitHub App section. - IP allow-list collection can't work with app tokens; GitHub doesn't allow it, as the README already said. The new section repeats that next to the app settings. ## Wiring - **gRPC round trip:** `auth_grpc_test.go` sends `Configure` through go-plugin's in-process gRPC harness (`TestPluginGRPCConn` with `runner.RunnerV2GRPCPlugin`), the same path the agent uses. The agent sends config as a flat `map<string, string>`, and the plugin decodes it after the gRPC hop, so the embedded `AuthConfig` (`mapstructure:",squash"`) never affects the wire format. The tests cover the token-only config every deployment sends today, an app config with the empty keys agent configs declare, and incomplete app credentials. Without `squash` they fail. - **local-dev:** compliance-framework/local-dev#135 declares the app keys in the showcase agent config (the agent only fills keys the file declares from `CCF_*` environment variables) and teaches the `demo-go-check-github` pre-flight about app credentials. ## Testing - `go vet ./...` and `go test ./...` pass. - golangci-lint v2.11.4 with the shared config reports 0 issues. - I haven't run it against a real GitHub App installation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Gustavo Carvalho <gustavo@externalsecrets.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets the plugin authenticate as a GitHub App installation as an alternative to a token. Organizations can govern apps centrally, and the plugin only holds short-lived installation tokens, which ghinstallation renews as they expire.
This re-implements #3 by @gusfcarvalho, which has conflicts with
master. Since then, go-github has moved from v71 to v93 and the plugin gained a GraphQL client. The config keys are unchanged from #3:Changes
auth.go:AuthConfig(embedded inPluginConfigwithmapstructure:",squash", so the keys stay flat), validation, and one authenticatedhttp.Clientthat backs both the REST and the GraphQL client.tokenstill takes precedence when set, so existing configs behave exactly as before.Differences from #3
GitHub App authentication needs installation_id), and rejects setting bothprivate_key_fileandprivate_key.private_keyaccepts plain PEM as well as base64-encoded PEM.Wiring
auth_grpc_test.gosendsConfigurethrough go-plugin's in-process gRPC harness (TestPluginGRPCConnwithrunner.RunnerV2GRPCPlugin), the same path the agent uses. The agent sends config as a flatmap<string, string>, and the plugin decodes it after the gRPC hop, so the embeddedAuthConfig(mapstructure:",squash") never affects the wire format. The tests cover the token-only config every deployment sends today, an app config with the empty keys agent configs declare, and incomplete app credentials. Withoutsquashthey fail.CCF_*environment variables) and teaches thedemo-go-check-githubpre-flight about app credentials.Testing
go vet ./...andgo test ./...pass.GetSBOM/github.Ptr, oneQF1002) are already onmaster.Closes #3.
🤖 Generated with Claude Code