Skip to content

feat: allow reading github integrations with personal API key - #38921

Merged
jonathanlab merged 4 commits into
masterfrom
integrations-personal-api
Oct 1, 2025
Merged

jonathanlab merged 4 commits into
masterfrom
integrations-personal-api

Conversation

@jonathanlab

@jonathanlab jonathanlab commented Oct 1, 2025 •

Copy link
Copy Markdown
Contributor

Problem

To allow Github Repository selection for a task in our tasks product, we need to expose the Github integration.

Changes

API keys with scope integration:read can now:

  • List Github integrations
  • Retrieve details per Github integration
  • Retrieve available Github repositories for that integration

I constrained this to only allowing Github related reads by limiting the queryset.

How did you test this code?

Manually

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Changelog: (features only) Is this feature complete?

@jonathanlab
jonathanlab requested a review from joshsny October 1, 2025 12:45

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we add some permissions tests here?

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions

github-actions Bot commented Oct 1, 2025 •

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 3.06 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 3.06 MB

compressed-size-action

@jonathanlab
jonathanlab requested a review from joshsny October 1, 2025 13:19

@joshsny joshsny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great!


def safely_get_queryset(self, queryset):
if isinstance(self.request.successful_authenticator, PersonalAPIKeyAuthentication):
return queryset.filter(kind="github")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we want to only return github integrations?

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.

I don't know how diligent people have been when separating config and sensitive_config on the Organization model for different integrations, so just reducing blast radius by only exposing our use case

@jonathanlab
jonathanlab merged commit 1a7f20e into master Oct 1, 2025
1 check passed
@jonathanlab
jonathanlab deleted the integrations-personal-api branch October 1, 2025 15:00
MarconLP added a commit that referenced this pull request Apr 29, 2026
PR #38921 narrowed the integrations endpoint to only return GitHub
integrations when authenticated via personal API key (and #40246
extended the same restriction to OAuth access tokens). The intent was
to scope the surface to GitHub for the Tasks product, but the side
effect was that any other tool authenticating via API key — MCP,
future products, custom scripts — could no longer read Slack, Stripe,
Hubspot, or any other integration kind despite holding the
`integration:read` scope.

Drop the kind filter so the endpoint returns whatever the scope
permission grants. The serializer already excludes `sensitive_config`,
so this change exposes the same metadata-only view (id, kind, config,
created_at, errors, display_name) for all kinds rather than just
github.

Per #38921 (comment).
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