Bases: BaseSecurity
API Key Header security class.
in_value: Literal['header'] = 'header'
Bases: BaseModel
API Key Header security parameters class.
Source code in fastagency/api/openapi/security.py
| def apply(
self,
q_params: dict[str, Any],
body_dict: dict[str, Any],
security: BaseSecurity,
) -> None:
api_key_header: APIKeyHeader = security # type: ignore[assignment]
if "headers" not in body_dict:
body_dict["headers"] = {}
body_dict["headers"][api_key_header.name] = self.value
|
Source code in fastagency/api/openapi/security.py
| def get_security_class(self) -> type[BaseSecurity]:
return APIKeyHeader
|
Source code in fastagency/api/openapi/security.py
| def accept(self, security_params: "BaseSecurityParameters") -> bool:
return isinstance(self, security_params.get_security_class())
|
get_security_class(
type: str, schema_parameters: dict[str, Any]
) -> BaseSecurityType
Source code in fastagency/api/openapi/security.py
| @classmethod
def get_security_class(
cls, type: str, schema_parameters: dict[str, Any]
) -> BaseSecurityType:
sub_classes = cls.__subclasses__()
for sub_class in sub_classes:
if sub_class.is_supported(type, schema_parameters):
return sub_class
logger.error(
f"Unsupported type '{type}' and schema_parameters '{schema_parameters}' combination"
)
return UnsuportedSecurityStub
|
get_security_parameters(
schema_parameters: dict[str, Any]
) -> str
Source code in fastagency/api/openapi/security.py
| @classmethod
def get_security_parameters(cls, schema_parameters: dict[str, Any]) -> str:
return f"{cls.__name__}(name=\"{schema_parameters.get('name')}\")"
|
Source code in fastagency/api/openapi/security.py
| @classmethod
def is_supported(cls, type: str, schema_parameters: dict[str, Any]) -> bool:
return cls.type == type and cls.in_value == schema_parameters.get("in")
|