Unable to get the transport ssl context from the request. This prevents checking the Client provided certificate and matching up the provided CN against allowed users/server. #2307
Replies: 2 comments 2 replies
-
any update ? |
Beta Was this translation helpful? Give feedback.
-
I agree, and suggest another issue name: Pass underlying transport via Scope["extensions"]In order for an API function to look into properties of the socket/transport that called it, the preferred method is via scope extensions. The basic ASGI call sends scope, along with receive and send callbacks: uvicorn/uvicorn/protocols/http/httptools_impl.py Lines 397 to 401 in 5bf788f Scope, defined in the ASGI spec, allows "extensions" to be defined by implementations. So, I also agree we should set uvicorn/uvicorn/protocols/http/httptools_impl.py Lines 213 to 223 in 5bf788f |
Beta Was this translation helpful? Give feedback.
-
Initial Checks
Discussion Link
Description
Many applications in finance/banking require two way certificate verification. Currently the way we have handled this is by proxying the request and extracting out the client information at nginx or traefik and stuffing it into the headers.
Example Code
From the request we cannot get the transport information and unable to getgetpeercert preventing application-level validation of client certificates.
A possible solution is to pass the transport in the request scope.
In the protocol h11_impl.py we could simply add
after
uvicorn/uvicorn/protocols/http/h11_impl.py
Line 203 in 0efd383
Then at a route level or fastapi middleware we could pull the client certificates to check against an authorization service.
Python, Uvicorn & OS Version
Important
Beta Was this translation helpful? Give feedback.
All reactions