mcpField
A
api-authentication

api-authentication

github.com/aj-geddesSecurity373609 installsUpdated 34w ago
Repository

About api-authentication

A security skill for implementing API authentication with JWT, OAuth 2.0, API keys, and session management. It provides reference guides and practices for protecting authentication flows and credentials.

Key features

  1. 01JWT authentication guidance
  2. 02OAuth 2.0 implementation
  3. 03API key authentication
  4. 04Token refresh and expiration practices
  5. 05Password hashing and rate limiting

Use cases

  1. 01Securing API endpoints
  2. 02Building login and logout flows
  3. 03Managing access and refresh tokens
  4. 04Connecting OAuth 2.0 providers

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill api-authentication

After installing, type/api-authenticationin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
api-key-authentication.md
jwt-authentication.md
oauth-20-implementation.md
python-authentication-implementation.md
scripts/
security-checklist.sh

Details

From the project README

API Authentication

Table of Contents

Overview

Implement comprehensive authentication strategies for APIs including JWT tokens, OAuth 2.0, API keys, and session management with proper security practices.

When to Use

  • Securing API endpoints
  • Implementing user login/logout flows
  • Managing access tokens and refresh tokens
  • Integrating OAuth 2.0 providers
  • Protecting sensitive data
  • Implementing API key authentication

Quick Start

Minimal working example:

// Node.js JWT Implementation
const express = require('express');
const jwt = require('jsonwebtoken');
const bcrypt = require('bcrypt');

const app = express();
const SECRET_KEY = process.env.JWT_SECRET || 'your-secret-key';
const REFRESH_SECRET = process.env.REFRESH_SECRET || 'your-refresh-secret';

// User login endpoint
app.post('/api/auth/login', async (req, res) => {
  try {
    const { email, password } = req.body;

    // Find user in database
    const user = await User.findOne({ email });
    if (!user) {
      return res.status(401).json({ error: 'Invalid credentials' });
    }

    // Verify password
    const isValid = await bcrypt.compare(password, user.password);
    if (!isValid) {
      return res.status(401).json({ error: 'Invalid credentials' });
    }
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
JWT AuthenticationJWT Authentication
OAuth 2.0 ImplementationOAuth 2.0 Implementation
API Key AuthenticationAPI Key Authentication
Python Authentication ImplementationPython Authentication Implementation

Best Practices

✅ DO
  • Use HTTPS for all authentication
  • Store tokens securely (HttpOnly cookies)
  • Implement token refresh mechanism
  • Set appropriate token expiration times
  • Hash and salt passwords
  • Use strong secret keys
  • Validate tokens on every request
  • Implement rate limiting on auth endpoints
  • Log authentication attempts
  • Rotate secrets regularly
❌ DON'T
  • Store passwords in plain text
  • Send tokens in URL parameters
  • Use weak secret keys
  • Store sensitive data in JWT payload
  • Ignore token expiration
  • Disable HTTPS in production
  • Log sensitive tokens
  • Reuse API keys across services
  • Store credentials in code

Comments

Markdown supported