मुख्य सामग्री पर जाएँ
Skillpedia
सिक्योरिटी25k · #10088

nocobase-app-plugin-api-keys

यह क्या करती है

यह स्किल NocoBase ऐप में API key access जोड़ती है, ताकि scripts और दूसरे सिस्टम उसकी API कॉल कर सकें। यह उन डेवलपर्स के लिए है जो ऐप को बाहरी tools से जोड़ते हैं।

कब इस्तेमाल करें

  • ✓जब कोई script या integration आपके NocoBase ऐप की API कॉल करना चाहे।
  • ✓जब ऐप द्वारा जारी की गई API key खारिज हो रही हो।
  • ✓जब आपको ऐसी API keys चाहिए जो किसी खास user की तरह, उसके roles के साथ काम करें।

Skill का लिंक

https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-api-keys/skills/nocobase-app-plugin-api-keys/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-api-keys/skills/nocobase-app-plugin-api-keys/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“क्या आप मेरे NocoBase ऐप में API key access जोड़ सकते हैं, ताकि मेरी रात की script उसकी API कॉल कर सके?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

AI API Keys plugin और उसकी database table रजिस्टर करता है। हर key उसके मालिक के session से मेल खाती है, इसलिए script उसी user के roles के साथ काम करती है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

API Keys App Plugin

Use this Skill when an App needs non-interactive callers — a script, a cron job, a third-party integration — to reach its API as a real user, or when a key the App issued is being rejected. The default configuration resolves a key into its owner’s Session and carries that user’s roles. Applications needing scoped credentials must use a separate configuration with enableSessionForAPIKeys: false and enforce their business rules on the server.

This package is Better Auth's API Key plugin plus the apikey migration. apiKey is wrapped only to supply three defaults, all overridable; its name, options and behaviour are Better Auth's, and Better Auth's documentation applies unchanged.

Public surfaces

  • Server plugin: default export of @nocobase/app-plugin-api-keys/server. Contributes the apikey table migration and nothing else.
  • apiKey(options?), plus API_KEY_TABLE_NAME, API_KEY_ERROR_CODES and the option types, from the same entry. Use these rather than adding @better-auth/api-key to the App: the migration here matches the schema this version declares, and taking both from one package keeps them in step.
  • Client registration factory: @nocobase/app-plugin-api-keys/client. It contributes no pages.
  • apiKeyClient, re-exported from @better-auth/api-key/client by the same entry.
  • ApiKeySummary and the expiry helpers, for the App's own key management page. Such a page reads useAuthenticationClient().apiKey, typed through the authentication plugin's AuthClientPluginRegistry, and is declared among the App's own routes.
  • HTTP API: POST /api/auth/api-key/create, GET /api/auth/api-key/list, GET /api/auth/api-key/get, POST /api/auth/api-key/update, and POST /api/auth/api-key/delete. All five act only on the caller's own keys.

The plugin contributes no NocoBase route of its own. The endpoints above are Better Auth's, mounted by Authentication's /api/auth/* handler. Its server registers one thing: the access check that lets a valid key read the App's API document.

Register it

Both halves are required, and each fails differently on its own.

  1. Add the default export to the App's server/plugins.ts and client/plugins.ts.
  2. Add apiKey() to plugins in server/config/auth.ts, and apiKeyClient() to plugins in client/config/auth.ts.
  3. Run pnpm nocobase db apply.

Only step 1 leaves the apikey table created and no endpoints mounted. Only step 2 mounts endpoints against a table that does not exist, and every call fails at the database.

The three defaults

apiKey() supplies enableSessionForAPIKeys: true, rateLimit: { enabled: false } and requireName: true, so an App normally passes nothing.

enableSessionForAPIKeys is the one that has to be set. Better Auth defaults it off, and with it off a key authenticates nothing: keys are still issued, and every request carrying one answers 401. Nothing points at the configuration, so do not override it without meaning to.

rateLimit is off because Better Auth's own default is 10 requests per key per day, which is a quota for issuing keys rather than for using them. Pass { enabled: true, maxRequests: 1000, timeWindow: 60_000 } for a quota the App actually wants.

All three are overridable, and passing all three back reproduces Better Auth's own behaviour exactly.

Call the API with a key

curl -H 'x-api-key: <key>' https://example.com/api/orders

An App route needs no change. auth.required() and auth.optional() resolve the key into the owner's Session, and Authorization then evaluates that user's roles. Read context.get('auth') exactly as for a cookie Session.

Pass apiKeyHeaders: ['x-api-key', 'authorization-key'] to accept a different header.

To find out what the App's API offers, read its OpenAPI document with the same key: GET /api/swagger returns the JSON document and GET /api/swagger/docs the Swagger UI page. A signed-in session or a valid key may read it; anything else gets 401 with error.reason API_DOCS_UNAUTHENTICATED. The API key endpoints are listed there under /api/auth/api-key/..., tagged Authentication.

What a key can reach, and what it cannot

A key is its owner, so it reaches the Better Auth endpoints a Session reaches. Verified against @better-auth/api-key 1.7.1 with only an x-api-key header:

| Endpoint

अक्सर पूछे जाने वाले सवाल

script key कैसे भेजती है?

हर request में वह key x-api-key header में भेजी जाती है।

क्या key की अनुमतियाँ सीमित हो सकती हैं?

डिफ़ॉल्ट सेटअप में नहीं, क्योंकि उसमें मालिक के roles होते हैं। स्किल scoped keys के लिए अलग सेटअप बताती है।

क्या यह login page भी जोड़ता है?

नहीं। यह केवल API key access जोड़ता है।

जानकारी

लेखक का मूल विवरण

Register the API Keys plugin in a NocoBase App, let scripts and integrations call the App's API with an x-api-key header, or work out why a key is rejected.

repo: nocobase/nocobase

लोकप्रियता

GitHub स्टार
25k
रैंकिंग में स्थान
#10088
लाइसेंस
—
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

nocobase-app-development

25k

यह आपके एजेंट को पूर्ण NocoBase 3 व्यावसायिक एप्लिकेशन के लिए पेज, routes, डेटा, अनुमतियाँ और टेस्ट बनाने में मदद करती है।

कोडिंगसामान्य कोडिंग

shadcn

25k

यह आपके एजेंट को वेब प्रोजेक्ट में shadcn/ui कंपोनेंट खोजने, जोड़ने, ठीक करने और स्टाइल करने में मदद करती है, उनके आधिकारिक दस्तावेज़ और registries का उपयोग करके।

कोडिंगवेबसाइट और UI (frontend)

nocobase-app-plugin-development

25k

यह आपके एजेंट को मौजूदा NocoBase 3 ऐप के भीतर plugins बनाने और उनकी देखभाल करने में मदद करती है, जिसमें server, client, database और registration के हिस्से शामिल हैं।

कोडिंगAPI और सर्वर (backend)

nocobase-app-upgrade

25k

यह आपके एजेंट को NocoBase ऐप को नए template रिलीज़ तक अपग्रेड करने में मदद करती है, template के बदलाव लाते हुए आपका अपना काम बनाए रखते हुए।

कोडिंगडिप्लॉय और क्लाउड (DevOps)

मिलती-जुलती skills