Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing in token to Personal API Key requests #5044

Merged
merged 8 commits into from
Jul 16, 2021

Conversation

yakkomajuri
Copy link
Contributor

@yakkomajuri yakkomajuri commented Jul 8, 2021

Changes

Minimum possible change to address #4849.

With this change, when using personal API keys, you can specify a project to fetch data on by passing the project api key (token) as a query param.

Supporting changes needed:

  • Updating plugins that use Personal API Keys to use this mechanism
  • Docs

#4764 introduced _get_team_from_request but only the feature flags queryset was updated to leverage this. Now all endpoints will have their queryset filtered by this team.

Checklist

  • All querysets/queries filter by Organization, by Team, and by User
  • Django backend tests
  • Jest frontend tests
  • Cypress end-to-end tests
  • Migrations are safe to run at scale (e.g. PostHog Cloud) – present proof if not obvious
  • New/changed UI is decent on smartphones (viewport width around 360px)

@timgl timgl temporarily deployed to posthog-pr-5044 July 8, 2021 14:42 Inactive
@posthog-bot
Copy link
Contributor

Hey @yakkomajuri! 👋
This pull request seems to contain no description. Please add useful context, rationale, and/or any other information that will help make sense of this change now and in the distant Mars-based future.

@yakkomajuri yakkomajuri marked this pull request as draft July 8, 2021 14:54
@yakkomajuri yakkomajuri temporarily deployed to posthog-pr-5044 July 8, 2021 16:59 Inactive
@yakkomajuri yakkomajuri marked this pull request as ready for review July 8, 2021 17:16
@yakkomajuri yakkomajuri temporarily deployed to posthog-pr-5044 July 8, 2021 17:17 Inactive
@yakkomajuri yakkomajuri requested a review from timgl July 8, 2021 17:41
@yakkomajuri yakkomajuri temporarily deployed to posthog-pr-5044 July 12, 2021 14:34 Inactive
@yakkomajuri yakkomajuri requested a review from Twixes July 13, 2021 11:06
posthog/api/routing.py Outdated Show resolved Hide resolved
@yakkomajuri yakkomajuri temporarily deployed to posthog-pr-5044 July 15, 2021 11:38 Inactive
Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

Code looks good, but: test needed :)

@yakkomajuri
Copy link
Contributor Author

So that's the question - api/feature_flag already has a test for this. Wondering what's the best place to add a "top-level" test? Or would you be for testing each endpoint individually?

@Twixes

@Twixes
Copy link
Member

Twixes commented Jul 15, 2021

IMO good to just have this tested for a few more endpoints (since it's a global feature)

@yakkomajuri yakkomajuri temporarily deployed to posthog-pr-5044 July 15, 2021 17:10 Inactive
@Twixes Twixes temporarily deployed to posthog-pr-5044 July 15, 2021 17:28 Inactive
@Twixes Twixes temporarily deployed to posthog-pr-5044 July 15, 2021 17:58 Inactive
@Twixes
Copy link
Member

Twixes commented Jul 15, 2021

Good to go, just documentation in posthog.com needed.

@yakkomajuri yakkomajuri merged commit 3b8d328 into master Jul 16, 2021
@yakkomajuri yakkomajuri deleted the personal-key-project branch July 16, 2021 13:35
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.

4 participants