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: manage user API tokens #6

Merged
merged 17 commits into from
May 8, 2024
Merged

feat: manage user API tokens #6

merged 17 commits into from
May 8, 2024

Conversation

sdankel
Copy link
Member

@sdankel sdankel commented May 2, 2024

  • Adds the ability for logged in users to create, view, and revoke API tokens
  • Refactors the session token handling to use a session cookie instead of local storage
  • Replaces use of fetch with axios for more ergonomic http calls
  • Also set up typed axios so we have strongly typed API calls on the typescript side.
  • Adds rocket request guards for the two times of authentication: session-based and API token-based. This makes it easy to indicate which requests require which authentication and have standard error handling around authentication.

You can test using one of the API tokens with curl:

curl 'http://localhost:8080/publish' \
  -H 'Authorization: Bearer <API Token>' \
  -H 'Origin: http://localhost:3000' \
  --data-raw '{"name":"my-pkg", "version": "1.2.3"}'

The server should print Publishing: Json(PublishRequest { name: "my-pkg", version: "1.2.3" }) for token: "<name>" if it's a valid token, and respond with 401 Unauthorized if not.

May-01-2024 18-44-49

Copy link

vercel bot commented May 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
forc-pub ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 7, 2024 3:07am

@sdankel sdankel marked this pull request as ready for review May 2, 2024 20:01
@sdankel sdankel requested a review from a team May 2, 2024 20:01
Copy link
Member

@kayagokalp kayagokalp left a comment

Choose a reason for hiding this comment

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

Looks nice! I haven't done so much full-stack dev in the past but looks really clean to me :) Couldn't test locally yet I am having some trouble with docker sadly as soon as I can run it, will place a review. Hopefully today 🙏

Copy link
Member

@JoshuaBatty JoshuaBatty left a comment

Choose a reason for hiding this comment

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

I can't seem to get postgres working locally to test this out. I think the code looks good so i'm approving to hold this up.

@sdankel sdankel merged commit 164a66a into master May 8, 2024
11 checks passed
@sdankel sdankel deleted the sophie/api-tokens branch May 8, 2024 14:17
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

3 participants