MCPcopy
hub / github.com/fastapi/fastapi / __call__

Method __call__

fastapi/security/http.py:202–219  ·  view source on GitHub ↗
(  # type: ignore
        self, request: Request
    )

Source from the content-addressed store, hash-verified

200 return {"WWW-Authenticate": "Basic"}
201
202 async def __call__( # type: ignore
203 self, request: Request
204 ) -> HTTPBasicCredentials | None:
205 authorization = request.headers.get("Authorization")
206 scheme, param = get_authorization_scheme_param(authorization)
207 if not authorization or scheme.lower() != "basic":
208 if self.auto_error:
209 raise self.make_not_authenticated_error()
210 else:
211 return None
212 try:
213 data = b64decode(param).decode("ascii")
214 except (ValueError, UnicodeDecodeError, binascii.Error) as e:
215 raise self.make_not_authenticated_error() from e
216 username, separator, password = data.partition(":")
217 if not separator:
218 raise self.make_not_authenticated_error()
219 return HTTPBasicCredentials(username=username, password=password)
220
221
222class HTTPBearer(HTTPBase):

Callers

nothing calls this directly

Calls 4

getMethod · 0.45

Tested by

no test coverage detected