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

feat: Improved toolbar authentication (with support for CLI) #22295

Draft
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

benjackwhite
Copy link
Contributor

@benjackwhite benjackwhite commented May 15, 2024

Problem

For the CLI hackathon - adds a secure flow for passing a jwt to the cli to be used.

The outcome of this made me think that we could use this for the toolbar as well, improving the auth flow for it and potentially allowing solutions that don't work well with the hash param state (via posthog.loadToolbar() )

WARNING - As this is auth related we should think slowly before we merge. For now we can demo the tool on this PR.

Changes

  • Adds a new auth flow for exhanging a token in a non-interactive way
  • Removes TemporaryTokenAuthentication in favour of the new JWT based flow

TODO

  • Add scopes support to the token generation
  • Add scopes to the authorizer redirect
  • Load projects from the API so that we can correctly get the projectId for a given token

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

Does this work well for both Cloud and self-hosted?

How did you test this code?

@github-actions github-actions bot temporarily deployed to pr-feat/cli-auth May 15, 2024 16:25 Destroyed
# Conflicts:
#	posthog/api/user.py
@github-actions github-actions bot temporarily deployed to pr-feat/cli-auth May 21, 2024 11:21 Destroyed
@benjackwhite benjackwhite removed the request for review from danielxnj May 22, 2024 09:18
# Conflicts:
#	posthog/api/__init__.py
#	posthog/api/client_auth.py
#	posthog/api/routing.py
#	posthog/jwt.py
#	posthog/urls.py
@marandaneto
Copy link
Member

I will close #22321 in favor of this one

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

12 snapshot changes in total. 0 added, 12 modified, 0 deleted:

  • chromium: 0 added, 12 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

github-actions bot commented May 23, 2024

Size Change: +1.1 kB (+0.1%)

Total Size: 1.06 MB

Filename Size Change
frontend/dist/toolbar.js 1.06 MB +1.1 kB (+0.1%)

compressed-size-action

@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

benjackwhite and others added 2 commits May 31, 2024 09:20
# Conflicts:
#	frontend/__snapshots__/scenes-other-settings--settings-session-timeout-password-only--dark.png
#	frontend/__snapshots__/scenes-other-settings--settings-session-timeout-password-only--light.png
#	frontend/src/scenes/urls.ts
#	posthog/permissions.py
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

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.

None yet

4 participants