api-authentication
/api-authentication
Zabezpiecza uwierzytelnianie API przez JWT, OAuth 2.0 i klucze API w systemach logowania i integracjach usług.
- Autor
- secondsky ↗
- Repozytorium
- claude-skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 26.09.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 2
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 26.09.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Zabezpiecza uwierzytelnianie API przez JWT, OAuth 2.0 i klucze API w systemach logowania i integracjach usług.
Oryginalny opis (EN)
Secure API authentication with JWT, OAuth 2.0, API keys. Use for authentication systems, third-party integrations, service-to-service communication, or encountering token management, security headers, auth flow errors.
Jak działa
- Authentication Methods
- JWT Implementation (Node.js)
- Security Requirements
- Security Headers
- Additional Implementations
- Common Mistakes to Avoid
Podgląd SKILL.md
---
name: api-authentication
description: Secure API authentication with JWT, OAuth 2.0, API keys. Use for authentication systems, third-party integrations, service-to-service communication, or encountering token management, security headers, auth flow errors.
license: MIT
---
# API Authentication
Implement secure authentication mechanisms for APIs using modern standards and best practices.
## Authentication Methods
| Method | Use Case | Security Level |
|--------|----------|----------------|
| JWT | Stateless auth, SPAs | High |
| OAuth 2.0 | Third-party integration | High |
| API Keys | Service-to-service | Medium |
| Session | Traditional web apps | High |
## JWT Implementation (Node.js)
```javascript
const jwt = require('jsonwebtoken');
const generateTokens = (user) => ({
accessToken: jwt.sign(
{ userId: user.id, role: user.role },
process.env.JWT_SECRET,
{ expiresIn: '15m' }
),
refreshToken: jwt.sign(
{ userId: user.id, type: 'refresh' },
process.env.REFRESH_SECRET,
{ expiresIn: '7d' }
)
});
const authMiddleware = (req, res, next) => {
const authHeader = req.headers.authorization;
// Validate authorization header format
if (!authHeader || !authHeader.startsWith('Bearer ')) {
return res.status(401).json({ error: 'Malformed authorization header' });
}
const parts = authHeader.split(' ');
if (parts.length !== 2) {
return res.status(401).json({ error: 'Malformed authorization header' });
}
const token = parts[1];
if (!token) {
return res.status(401).json({ error: 'No token provided' });
}
try {
req.user = jwt.verify(token, process.env.JWT_SECRET);
next();
} catch (err) {
res.status(401).json({ error: 'Invalid token' });
}
};
```
## Security Requirements
- Always use HTTPS
- Store tokens in HttpOnly cookies (not localStorage)
- Hash passwords with bcrypt (cost factor 12+)
- Implement rate limiting on auth endpoints
- Rotate secrets regularly
- Never transmit tokens in URLs
## Security Headers
```javascript
app.use((req, res, next) => {
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('X-Frame-Options', 'DENY');
res.setHeader('Strict-Transport-Security', 'max-age=31536000');
next();
});
```
## Additional Implementations
See [references/python-flask.md](references/python-flask.md) for:
- Flask JWT with role-based access control decorators
- OAuth 2.0 Google integration with Authlib
- API key authentication with secure hashing
## Common Mistakes to Avoid
- Storing plain-text passwords
- Using weak JWT secrets
- Ignoring token expiration
- Disabling HTTPS in production
- Logging sensitive tokens
Pliki w paczce (2)
- SKILL.md 3 KB
- references/python-flask.md 6 KB
Wersje
W bazie nie ma innych skilli o nazwie api-authentication.
Identyczna treść występuje jeszcze w 1 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.
Migawka bazy z 28.10.2026 · wersja paczki 88c5acba07a9 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100building-api-authentication
Buduje bezpieczne systemy uwierzytelniania API z OAuth2, JWT, kluczami API i zarządzaniem sesjami. - 100building-api-authentication
Buduje bezpieczne systemy uwierzytelniania API z OAuth2, JWT, kluczami API i zarządzaniem sesjami. - 100authentication-patterns
Dostarcza wzorce uwierzytelniania dla kluczy API, OAuth i zarządzania tokenami, przy wdrażaniu lub przeglądzie uwierzytelniania usług i obsługi poświadczeń. - 100auth-security
Opisuje dobre praktyki bezpieczeństwa uwierzytelniania OAuth 2.1 i JWT przy implementacji logowania, autoryzacji API i zarządzania tokenami według RFC 9700. - 100auth-and-api-keys
Pomaga projektować uwierzytelnianie API: klucze z prefiksami w stylu Stripe, wybór między kluczami API a OAuth, tokeny JWT, Bearer, rotację kluczy i zakresy uprawnień. - 95api-security-auth-pattern
Projektuje i dokumentuje wzorce uwierzytelniania, autoryzacji i zabezpieczeń API: OAuth 2.0, JWT, klucze API, RBAC, ABAC, CORS, walidacja wejścia i OWASP API Security.