mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-23 14:04:18 +02:00
Expose OAuth token management parameters in all providers (#2222)
All OAuth providers and OIDCProxy now expose jwt_signing_key, token_encryption_key, and client_storage parameters for production deployments requiring persistent token management across server restarts.
This commit is contained in:
parent
562e51b378
commit
980d0516a7
13 changed files with 296 additions and 0 deletions
|
|
@ -135,6 +135,42 @@ When you run the client for the first time:
|
|||
The client caches tokens locally, so you won't need to re-authenticate for subsequent runs unless the token expires or you explicitly clear the cache.
|
||||
</Info>
|
||||
|
||||
## Production Configuration
|
||||
|
||||
<VersionBadge version="2.13.0" />
|
||||
|
||||
For production deployments with persistent token management across server restarts, configure `jwt_signing_key`, `token_encryption_key`, and `client_storage`:
|
||||
|
||||
```python server.py
|
||||
import os
|
||||
from fastmcp import FastMCP
|
||||
from fastmcp.server.auth.providers.github import GitHubProvider
|
||||
from key_value.aio.stores.redis import RedisStore
|
||||
|
||||
# Production setup with persistent token storage
|
||||
auth_provider = GitHubProvider(
|
||||
client_id="Ov23liAbcDefGhiJkLmN",
|
||||
client_secret="github_pat_...",
|
||||
base_url="https://your-production-domain.com",
|
||||
|
||||
# Production token management
|
||||
jwt_signing_key=os.environ["JWT_SIGNING_KEY"], # Secret for signing JWT tokens
|
||||
token_encryption_key=os.environ["TOKEN_ENCRYPTION_KEY"], # Secret for encrypting tokens at rest
|
||||
client_storage=RedisStore( # Persistent storage for client registrations
|
||||
host=os.environ["REDIS_HOST"],
|
||||
port=int(os.environ["REDIS_PORT"])
|
||||
)
|
||||
)
|
||||
|
||||
mcp = FastMCP(name="Production GitHub App", auth=auth_provider)
|
||||
```
|
||||
|
||||
<Note>
|
||||
All three parameters (`jwt_signing_key`, `token_encryption_key`, and `client_storage`) work together to ensure tokens and client registrations survive server restarts. Store secrets in environment variables and use a persistent storage backend like Redis or PostgreSQL for distributed deployments.
|
||||
|
||||
For complete details on these parameters, see the [OAuth Proxy documentation](/servers/auth/oauth-proxy#configuration-parameters).
|
||||
</Note>
|
||||
|
||||
## Environment Variables
|
||||
|
||||
<VersionBadge version="2.12.1" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue