A caller cannot see their own usage
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- api, authentication
調査の方向性
Read src/api/auth.ts, src/api/usage.ts, and src/x402/metering.ts to trace how a presented key is authenticated and how enforcement calculates usage. Then inspect the existing Vitest tests and run npm test. Done means callers can see only their own enforcement-matched usage, the response is no-store, and a test verifies one key cannot read another's usage.
索引モデルが issue の本文から書いたものです。
説明
Background
src/api/usage.ts serves /admin/usage/:keyId and /admin/usage, both behind
ADMIN_TOKEN. Usage is metered per key, quotas are enforced per key, and the
only person who cannot see any of it is the person whose key it is.
So a caller discovers their quota by hitting it. For a paid API where exceeding
a quota can mean a 402 or a blocked request, that is the one number they need
in advance.
What to build
- A route a caller reads with their own key, returning their own usage:
requests used against each window, quota remaining, and when it resets. - It must be impossible to read another key's usage through it. The key
presented determines the answer — never a parameter. - Reflect the same numbers the enforcement uses. Two sources of truth here means
a caller is told they have room and then refused. no-storeon the response: it is per-caller, and a shared cache must never
hold it.
Acceptance criteria
- A caller can read their own usage with their own key
- No parameter can make it return another key's usage
- The numbers match what enforcement uses
- The response is
no-store - A test asserts one key cannot see another's usage
Drips Wave · Complexity: Intermediate · 150 points
Repo: Divinity-Labs/Lens. Auth is src/api/auth.ts, key minting
src/api/admin.ts, usage reporting src/api/usage.ts, metering
src/x402/metering.ts, the ApiKey model in prisma/schema.prisma.
Run the tests: npm test. The tests are vitest, not jest. A single file
is npx vitest run src/__tests__/auth.test.ts.
Load test (prices) is already failing on main. Not your PR.
Do not weaken what is already right. Three things are correct today and
should survive every change here:
generateApiKey()islens_plusrandomBytes(24)— 192 bits. Do not
shorten it, and do not make it guessable or sequential.hashApiKey()is an unsalted SHA-256. That is correct for a
high-entropy random key: it must stay fast and deterministic so a lookup is
one indexed query. Do not "improve" it into bcrypt or argon2 — those are for
low-entropy human passwords, and here they would only make every request slow.- Only the hash is ever stored. The plaintext is returned once, at creation,
and never again.
Admin routes carry config: { public: true }. That does not mean public —
it means "skip the API-key hook", because they enforce ADMIN_TOKEN instead.
Removing that flag locks the admin surface behind the keys it exists to mint.
Never elide an address, a key or a token in code, comments, tests or
documentation. Write it in full or not at all — and never write a real key
anywhere.
Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk
- 主要言語
- TypeScript
- スター
- 4
- フォーク
- 71
- 平均マージ
- 2日 8時間
- マージ済み PR(30日)
- 93
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Divinity-Labs/Lens のほかの issue
-
Webhook retries have no jitter, so failures synchronise対応中かも @Richard-tobi が 6 日前に担当しました。 オープンarea:reliability difficulty:easy help wanted points:100 Stellar Wave
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
Divinity-Labs/Lens#341 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Admin routes are public and that is load-bearing対応中かも @sparkysolutions10-pixel が 3 日前に担当しました。 オープンarea:security difficulty:easy help wanted points:100
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
Divinity-Labs/Lens#514 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
The key is accepted only as a bearer token, and nothing says so対応中かも @krsnak が 5 日前に担当しました。 オープンarea:docs difficulty:easy help wanted points:100 Stellar Wave
Divinity-Labs/Lens#512 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
The admin surface has no tests対応中かも @krsnak が 5 日前に担当しました。 オープンarea:testing difficulty:intermediate help wanted points:150 Stellar Wave
Divinity-Labs/Lens#510 · コメント 5 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
An unset ADMIN_TOKEN disables the admin surface silently対応中かも @dev-RAM11 が 3 日前に担当しました。 オープンarea:config difficulty:easy help wanted points:100 Stellar Wave
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
Divinity-Labs/Lens#508 · コメント 6 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
Divinity-Labs/Lens の issue をすべて見る
似ている issue
-
createAI: the ai peer range allows ai@6, which the provider cannot work with対応中かも @akhil9tiet が今日担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
cloudflare/agents#2690 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
[fullsend] E2E: theme — global-header ignores app.branding.fullLogo (RHDHBUGS-3670)対応中かも @fullsend-ai-coder が今日担当しました。 オープンe2e-failure ready-to-code
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
redhat-developer/rhdh-plugin-export-overlays#4503 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
needs triage 📥
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
ethereum/ethereum-org-website#19601 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
cloudscape-design/components#5184 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
agilepathway/label-checker#805 ·
メンテナーはふだん 1 日以内に返信