Security: verify client_secret in authorization_code flow + shared token store
- Token exchange now requires valid client_secret (was missing) - Access tokens stored in shared .active_tokens.json (cross-process) - nginx rate limiting on /authorize and /token (10r/m, burst=5) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -172,9 +172,10 @@ async def oauth_token(request: Request):
|
||||
if not _verify_pkce(code_verifier, code_data["code_challenge"], code_data["code_challenge_method"]):
|
||||
return JSONResponse({"error": "invalid_grant", "error_description": "PKCE verification failed"}, status_code=400)
|
||||
|
||||
user = client_id
|
||||
if user not in _load_tokens():
|
||||
return JSONResponse({"error": "invalid_client"}, status_code=401)
|
||||
# Verify client_secret at token exchange
|
||||
user = _resolve_client(client_id, client_secret)
|
||||
if not user:
|
||||
return JSONResponse({"error": "invalid_client", "error_description": "Invalid client credentials"}, status_code=401)
|
||||
|
||||
elif grant_type == "client_credentials":
|
||||
user = _resolve_client(client_id, client_secret)
|
||||
|
||||
Reference in New Issue
Block a user