Skip to content

Commit a855877

Browse files
committed
Simplify bearer auth logic
1 parent 993457b commit a855877

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/mcp/server/auth/middleware/bearer_auth.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ def __init__(
4141
self.provider = provider
4242

4343
async def authenticate(self, conn: HTTPConnection):
44-
if "Authorization" not in conn.headers:
45-
return None
46-
47-
auth_header = conn.headers["Authorization"]
48-
if not auth_header.startswith("Bearer "):
44+
auth_header = conn.headers.get("Authorization")
45+
if not auth_header or not auth_header.startswith("Bearer "):
4946
return None
5047

5148
token = auth_header[7:] # Remove "Bearer " prefix

0 commit comments

Comments
 (0)