api-security-best-practices
यह क्या करती है
यह टूल आपके APIs (वे 'दरवाज़े' जिनसे आपके प्रोग्राम एक-दूसरे से बात करते हैं) को ज़्यादा सुरक्षित बनाने में मदद करता है। यह जाँचता है कि जानकारी तक सिर्फ़ अधिकृत लोग पहुँच सकें और भेजा गया डेटा सही हो, ताकि आम हमलों को रोका जा सके।
कब इस्तेमाल करें
- ✓अपने API में कोई नया सुरक्षित फीचर बनाते समय।
- ✓यह समीक्षा करते समय कि कौन-सा डेटा किसे एक्सेस कर सकता है।
- ✓API के गलत इस्तेमाल की जाँच करते समय।
Skill का लिंक
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/api-security-best-practices/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“इस नए API route की सुरक्षा जाँचो, ताकि सिर्फ़ authenticated यूज़र्स इसे एक्सेस कर सकें और भेजा गया डेटा valid हो।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
यह टूल जाँचता है कि आपका API भेजने वाले की पहचान कैसे करता है (authentication) और क्या उस व्यक्ति को वह काम करने की अनुमति है जो वह माँग रहा है (authorization)। यह यह भी देखता है कि प्राप्त डेटा सुरक्षित और अपेक्षित है या नहीं।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
API Security Best Practices
Review the request boundary from caller identity through authorization, validated input, storage and observable response. Preserve the application's actual identity provider and data model rather than introducing a second authentication system.
When to Use
Use when adding a protected endpoint, reviewing object access, replacing permissive request parsing, or investigating an API abuse path. For a concrete defect, start with the failing route and its callers; do not deploy unrelated security infrastructure.
Inputs and prerequisites
Record the routes, caller/tenant model, identity provider, token contract, runtime and locked dependency versions, database schema, proxy topology and authorized test scope. Use synthetic identities in a test environment. Existing task authorization carries forward; production scans, account writes and message sends need their own authority. The Node examples below are integration sketches for Express, jsonwebtoken and Zod; application/database adapters are deliberately named rather than presented as a full runnable service. Confirm APIs against the installed versions before integrating.
1. Authenticate the exact token contract
Prefer the established provider/session middleware. When the service owns an HMAC JWT contract, require a strong server-owned key, a fixed algorithm, exact issuer and audience, and required runtime claims. Do not infer permissions from a decoded token before signature verification. Never accept a caller-selected verification algorithm.
const jwt = require('jsonwebtoken');
// Illustrative first-party access-token contract; not a third-party OAuth adapter.
const ACCESS_POLICY = {
algorithms: ['HS256'], issuer: 'example-auth', audience: 'example-api'
};
function verifyAccessToken(token, signingKey) {
const claims = jwt.verify(token, signingKey, ACCESS_POLICY);
if (!claims || typeof claims !== 'object' ||
typeof claims.sub !== 'string' || !claims.sub ||
typeof claims.tenantId !== 'string' || !claims.tenantId ||
!Number.isSafeInteger(claims.exp) || !Number.isSafeInteger(claims.iat) ||
claims.exp <= claims.iat) {
throw new Error('Invalid access claims');
}
return { subject: claims.sub, tenantId: claims.tenantId };
}
function readBearer(header) {
if (typeof header !== 'string' || header.length > 8192) return null;
const match = /^Bearer ([A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+)$/i.exec(header);
return match ? match[1] : null;
}
Issue access tokens with the same issuer/audience/algorithm and a short application- approved expiration. Handle verification failure as a generic 401 without echoing the token or exception. Expiration alone does not revoke a token; define revocation or short-lived sessions according to the actual threat model. A service using asymmetric provider keys needs the provider's discovery/JWKS validation and key-rotation policy, not this HMAC example. Never reuse an access token as a refresh token.
Refresh sessions
Use the provider's supported session flow or a server-side opaque refresh design: store only a digest, expiry, user/session family and revocation state. In one atomic transaction consume the old active token and create the replacement. Concurrent reuse must not issue two successors; defined reuse handling revokes the affected family. Check current user status and permissions when issuing new access tokens. Bind refresh to the intended client/session and protect cookie-based requests against CSRF. Do not log tokens, store them plaintext in a database, or return a refresh token through a URL. Test simultaneous refresh, expiry, replay, revocation and transaction failure before calling the flow complete. No database transaction adapter is bundled here.
2. Authorize the resource and operation
Authentication identifies the caller; authorization decides the exact operation on an object and tenant. A role name does not automatically grant cross-tenant access. Apply the owner/tenant predicate in the database mutation to avoid a check-then-write race, and allowlist writable properties. Use 404/403 consistently with the product's resource-disclosure policy.
// Prisma-style sketch; id and tenant types must match your actual schema.
async function deleteOwnedPost(prisma, postId, principal) {
const result = await prisma.post.deleteMany({
…
अक्सर पूछे जाने वाले सवाल
authentication क्या है?
यह जाँचने की प्रक्रिया है कि कोई यूज़र या प्रोग्राम वही है जो वह होने का दावा करता है। आम तौर पर यह पासवर्ड, टोकन या key से होता है।
authorization क्या है?
यह जाँचने की प्रक्रिया है कि प्रमाणित यूज़र या प्रोग्राम को कोई खास काम करने या कोई संसाधन एक्सेस करने की अनुमति है या नहीं।
इनपुट डेटा की validation क्यों ज़रूरी है?
इससे सुनिश्चित होता है कि सिर्फ़ सुरक्षित और अपेक्षित फॉर्मेट का डेटा ही प्रोसेस हो। इससे गलत डेटा से होने वाली errors और उस डेटा का फायदा उठाने वाले हमले रुकते हैं।
जानकारी
लेखक का मूल विवरण
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
लोकप्रियता
- GitHub स्टार
- 48k
- रैंकिंग में स्थान
- #3779
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
00-andruia-consultant
48kआपके एजेंट को AI प्रोजेक्ट शुरू करने या उन्हें बेहतर बनाने में मदद करता है। यह code का विश्लेषण करता है, tools सुझाता है और स्पेनिश भाषा में action plan बनाता है।
007
48kआपका एजेंट security audit और threat modeling करता है। यह प्रोजेक्ट को हमलों और कमजोरियों से बचाने में काम आता है।
10-andruia-skill-smith
48kआपके एजेंट को AI tools बनाने या उन्हें बेहतर करने में मदद करता है। यह तय करता है कि tools कैसे काम करेंगे, documentation लिखता है और structure की जांच करता है।
20-andruia-niche-intelligence
48kआपका एजेंट किसी खास industry का summary बनाता है। भरोसेमंद स्रोतों की मदद से यह प्रोजेक्ट का संदर्भ, नियम, इस्तेमाल के तरीके और जोखिम समझने में मदद करता है।
मिलती-जुलती skills
reverse-engineer-anything
422kयह आपके एजेंट को REA टूल से शिप हुई ऐप्स और पैकेज को अंदर से समझने, वर्ज़न की तुलना करने या दोबारा बनाने में मदद करती है।
1password
394kयह आपके एजेंट को 1Password CLI सेट करने, साइन इन करने और सीक्रेट्स की वैल्यू चैट में छापे बिना उन्हें पढ़ने या इस्तेमाल करने में मदद करती है।
healthcheck
394kयह आपके एजेंट को उस कंप्यूटर या सर्वर का सुरक्षा ऑडिट करने देती है जिस पर OpenClaw चलता है, जिसमें SSH, firewall, अपडेट और बैकअप शामिल हैं, और फिर सुरक्षित सुधार सुझाती है।