- JWT Authentication - Enterprise-grade authentication with JWKS support for production
- Development Authentication - Simple token-based authentication for development and testing
- OAuth Server - Full OAuth 2.0 authorization server functionality
- Remote Authentication - Distributed authentication across multiple resource servers
- API Key Authentication - Pass-through authentication to upstream APIs
auth.py
file in your project root, providing clean separation from other build logic.
JWT Authentication
Overview
JWT authentication provides enterprise-grade security with JWKS (JSON Web Key Set) support. This is the recommended approach for production environments where you need standards-compliant token validation.Configuration
Configure JWT authentication in your project’sauth.py
:
Environment Variables
Set these environment variables in your.env
file:
How it Works
- Token Validation: Golf validates JWTs against the JWKS endpoint
- Standards Compliance: Full RFC 7519 JWT validation
- Scope Verification: Ensures tokens have required scopes
Development Authentication
Overview
Development authentication provides a simple token-based system perfect for development and testing environments. You can define custom tokens with specific client IDs and scopes.Configuration
Configure development authentication in your project’sauth.py
:
Using Development Tokens
Pass tokens via the Authorization header:OAuth Server Configuration
Overview
Golf v0.2.0 can act as a complete OAuth 2.0 authorization server, not just validate tokens. This mode allows your MCP server to issue JWT tokens to clients and provide full OAuth 2.0 endpoints for authorization, token issuance, and revocation.Configuration
Configure OAuth server mode in your project’sauth.py
:
Environment Variables
Configure runtime URL overrides in your.env
file:
Remote Authentication Configuration
Overview
Remote authentication allows you to distribute authentication across multiple resource servers while maintaining centralized token validation. This is useful for microservices architectures where multiple services need to validate tokens from the same authorization servers.Configuration
Environment Variables
API Key Authentication
Overview
Golf provides a simple API key pass-through authentication mechanism that allows MCP servers to extract API keys from request headers and forward them to upstream services. The actual authentication happens at the destination API level, not within the MCP server.Configuration
Configure API key extraction in your project’sauth.py
: