Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion mcp_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
# OAuth scopes
SCOPES = ["openid", "profile", "email", "User.Read"]

security = HTTPBearer()
security = HTTPBearer(auto_error=False)

# Development API Key (for testing only)
DEV_API_KEY = os.getenv("DEV_API_KEY", "dev-test-key-12345")
Expand Down Expand Up @@ -511,6 +511,11 @@ def validate_token(self, token: str) -> Dict[str, Any]:

def get_current_user(credentials: HTTPAuthorizationCredentials = Depends(security)):
"""Dependency to get current authenticated user"""
if credentials is None:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Missing token"
)
auth_service = MCPAuthService(os.getenv("BASE_URL", "http://localhost:8000"))
return auth_service.validate_token(credentials.credentials)

Expand Down