File tree Expand file tree Collapse file tree 11 files changed +1
-96
lines changed
Expand file tree Collapse file tree 11 files changed +1
-96
lines changed Original file line number Diff line number Diff line change 1- """
2- OAuth error classes for MCP authorization.
3-
4- Corresponds to TypeScript file: src/server/auth/errors.ts
5- """
6-
71from typing import Literal
82
93from pydantic import BaseModel , ValidationError
@@ -19,8 +13,6 @@ class ErrorResponse(BaseModel):
1913class OAuthError (Exception ):
2014 """
2115 Base class for all OAuth errors.
22-
23- Corresponds to OAuthError in src/server/auth/errors.ts
2416 """
2517
2618 error_code : ErrorCode
@@ -39,8 +31,6 @@ def error_response(self) -> ErrorResponse:
3931class InvalidRequestError (OAuthError ):
4032 """
4133 Invalid request error.
42-
43- Corresponds to InvalidRequestError in src/server/auth/errors.ts
4434 """
4535
4636 error_code = "invalid_request"
@@ -49,8 +39,6 @@ class InvalidRequestError(OAuthError):
4939class InvalidClientError (OAuthError ):
5040 """
5141 Invalid client error.
52-
53- Corresponds to InvalidClientError in src/server/auth/errors.ts
5442 """
5543
5644 error_code = "invalid_client"
Original file line number Diff line number Diff line change 1- """
2- Handler for OAuth 2.0 Authorization endpoint.
3-
4- Corresponds to TypeScript file: src/server/auth/handlers/authorize.ts
5- """
6-
71import logging
82from dataclasses import dataclass
93from typing import Literal
Original file line number Diff line number Diff line change 1- """
2- Handler for OAuth 2.0 Authorization Server Metadata.
3-
4- Corresponds to TypeScript file: src/server/auth/handlers/metadata.ts
5- """
6-
71from dataclasses import dataclass
82from typing import Any
93
Original file line number Diff line number Diff line change 1- """
2- Handler for OAuth 2.0 Dynamic Client Registration.
3-
4- Corresponds to TypeScript file: src/server/auth/handlers/register.ts
5- """
6-
71import secrets
82import time
93from dataclasses import dataclass
Original file line number Diff line number Diff line change 1- """
2- Handler for OAuth 2.0 Token Revocation.
3-
4- Corresponds to TypeScript file: src/server/auth/handlers/revoke.ts
5- """
6-
71from dataclasses import dataclass
82from typing import Literal
93
Original file line number Diff line number Diff line change 1- """
2- Handler for OAuth 2.0 Token endpoint.
3-
4- Corresponds to TypeScript file: src/server/auth/handlers/token.ts
5- """
6-
71import base64
82import hashlib
93import time
Original file line number Diff line number Diff line change 1- """
2- Bearer token authentication middleware for ASGI applications.
3-
4- Corresponds to TypeScript file: src/server/auth/middleware/bearerAuth.ts
5- """
6-
71import time
82from typing import Any , Callable
93
@@ -65,8 +59,6 @@ class RequireAuthMiddleware:
6559
6660 This will validate the token with the auth provider and store the resulting
6761 auth info in the request state.
68-
69- Corresponds to bearerAuthMiddleware in src/server/auth/middleware/bearerAuth.ts
7062 """
7163
7264 def __init__ (self , app : Any , required_scopes : list [str ]):
Original file line number Diff line number Diff line change 1- """
2- Client authentication middleware for ASGI applications.
3-
4- Corresponds to TypeScript file: src/server/auth/middleware/clientAuth.ts
5- """
6-
71import time
82
93from pydantic import BaseModel
148
159
1610class ClientAuthRequest (BaseModel ):
17- """
18- Model for client authentication request body.
19-
20- Corresponds to ClientAuthenticatedRequestSchema in
21- src/server/auth/middleware/clientAuth.ts
22- """
11+ # TODO: mix this directly into TokenRequest
2312
2413 client_id : str
2514 client_secret : str | None = None
Original file line number Diff line number Diff line change 1- """
2- Router for OAuth authorization endpoints.
3-
4- Corresponds to TypeScript file: src/server/auth/router.ts
5- """
6-
71from dataclasses import dataclass
82from typing import Any
93
@@ -72,8 +66,6 @@ def create_auth_router(
7266 """
7367 Create a Starlette router with standard MCP authorization endpoints.
7468
75- Corresponds to mcpAuthRouter in src/server/auth/router.ts
76-
7769 Args:
7870 provider: OAuth server provider
7971 issuer_url: Issuer URL for the authorization server
Original file line number Diff line number Diff line change 1- """
2- Authorization types for MCP server.
3-
4- Corresponds to TypeScript file: src/server/auth/types.ts
5- """
6-
71from pydantic import BaseModel
82
93
104class AuthInfo (BaseModel ):
11- """
12- Information about a validated access token, provided to request handlers.
13-
14- Corresponds to AuthInfo in src/server/auth/types.ts
15- """
16-
175 token : str
186 client_id : str
197 scopes : list [str ]
You can’t perform that action at this time.
0 commit comments