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
-
7
1
from typing import Literal
8
2
9
3
from pydantic import BaseModel , ValidationError
@@ -19,8 +13,6 @@ class ErrorResponse(BaseModel):
19
13
class OAuthError (Exception ):
20
14
"""
21
15
Base class for all OAuth errors.
22
-
23
- Corresponds to OAuthError in src/server/auth/errors.ts
24
16
"""
25
17
26
18
error_code : ErrorCode
@@ -39,8 +31,6 @@ def error_response(self) -> ErrorResponse:
39
31
class InvalidRequestError (OAuthError ):
40
32
"""
41
33
Invalid request error.
42
-
43
- Corresponds to InvalidRequestError in src/server/auth/errors.ts
44
34
"""
45
35
46
36
error_code = "invalid_request"
@@ -49,8 +39,6 @@ class InvalidRequestError(OAuthError):
49
39
class InvalidClientError (OAuthError ):
50
40
"""
51
41
Invalid client error.
52
-
53
- Corresponds to InvalidClientError in src/server/auth/errors.ts
54
42
"""
55
43
56
44
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
-
7
1
import logging
8
2
from dataclasses import dataclass
9
3
from 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
-
7
1
from dataclasses import dataclass
8
2
from typing import Any
9
3
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
-
7
1
import secrets
8
2
import time
9
3
from 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
-
7
1
from dataclasses import dataclass
8
2
from typing import Literal
9
3
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
-
7
1
import base64
8
2
import hashlib
9
3
import 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
-
7
1
import time
8
2
from typing import Any , Callable
9
3
@@ -65,8 +59,6 @@ class RequireAuthMiddleware:
65
59
66
60
This will validate the token with the auth provider and store the resulting
67
61
auth info in the request state.
68
-
69
- Corresponds to bearerAuthMiddleware in src/server/auth/middleware/bearerAuth.ts
70
62
"""
71
63
72
64
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
-
7
1
import time
8
2
9
3
from pydantic import BaseModel
14
8
15
9
16
10
class 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
23
12
24
13
client_id : str
25
14
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
-
7
1
from dataclasses import dataclass
8
2
from typing import Any
9
3
@@ -72,8 +66,6 @@ def create_auth_router(
72
66
"""
73
67
Create a Starlette router with standard MCP authorization endpoints.
74
68
75
- Corresponds to mcpAuthRouter in src/server/auth/router.ts
76
-
77
69
Args:
78
70
provider: OAuth server provider
79
71
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
-
7
1
from pydantic import BaseModel
8
2
9
3
10
4
class 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
-
17
5
token : str
18
6
client_id : str
19
7
scopes : list [str ]
You can’t perform that action at this time.
0 commit comments