Skip to content

Conversation

danielroe
Copy link
Contributor

@danielroe danielroe commented Jul 1, 2023

This adds a new @unkey/nuxt module. It currently does two things:

  1. it registers a useUnkey() helper that allows access to an automatically configured unkey instance. (Root key can be passed in module config or at runtime via NUXT_UNKEY_TOKEN variable.)
  2. It automatically verifies any API requests with an Authorization: Bearer xxx header.

These features can be granularly enabled.

Testing:

To test this module, you can run the following steps:

pnpm i
cd packages/nuxt
pnpm dev:prepare
cat 'NUXT_UNKEY_TOKEN=xxxxxx' > playground/.env
pnpm nuxi dev playground

curl http://localhost:3000/api/test
curl http://localhost:3000/api/test --header 'Authorization: Bearer some-token'

TODO:

  • get feedback on API and UX
  • add documentation
  • add test suite (once decision has been taken on test runner for project)

I'm also happy to add linting, etc, but didn't see any decisions taken on this at a project level

@vercel
Copy link

vercel bot commented Jul 1, 2023

@danielroe is attempting to deploy a commit to the Unkey Team on Vercel.

A member of the Team first needs to authorize it.

@gitguardian
Copy link

gitguardian bot commented Jul 6, 2023

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id Secret Commit Filename
- Bearer Token ab4d0da packages/nuxt/test/index.spec.ts View secret
- Bearer Token 0591ae7 packages/nuxt/test/index.spec.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@vercel
Copy link

vercel bot commented Jul 6, 2023

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

Name Status Preview Comments Updated (UTC)
unkey ❌ Failed (Inspect) Jul 6, 2023 8:06pm

@chronark chronark merged commit 6979192 into unkeyed:main Jul 6, 2023
@danielroe danielroe deleted the feat/nuxt branch July 6, 2023 20:44
glamboyosa pushed a commit to glamboyosa/unkey that referenced this pull request Jul 19, 2023
* feat: add new `@unkey/nuxt` module

* fix: correct key

* fix: handle key-not-found 404s

* chore: add example `.env` file

* chore: update build command + add node types

* fix: ensure context augmentation happens for server routes too

* style: lint/format nuxt package

* fix: allow using `useUnkey` until it supports undefined token

* test: add basic test suite

* ci: add test/build + turbo workflow

* docs: add nuxt docs

* chore: use env variable for testing
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