(
headers: Dict[str, str],
query_params: Dict[str, List[str]],
scheme_metadata: SecurityMetadata,
security_metadata: SecurityMetadata,
field_name: str,
value: Any,
)
| 147 | |
| 148 | |
| 149 | def _parse_security_scheme_value( |
| 150 | headers: Dict[str, str], |
| 151 | query_params: Dict[str, List[str]], |
| 152 | scheme_metadata: SecurityMetadata, |
| 153 | security_metadata: SecurityMetadata, |
| 154 | field_name: str, |
| 155 | value: Any, |
| 156 | ): |
| 157 | scheme_type = scheme_metadata.scheme_type |
| 158 | sub_type = scheme_metadata.sub_type |
| 159 | |
| 160 | header_name = security_metadata.get_field_name(field_name) |
| 161 | |
| 162 | if scheme_type == "apiKey": |
| 163 | if sub_type == "header": |
| 164 | headers[header_name] = value |
| 165 | elif sub_type == "query": |
| 166 | query_params[header_name] = [value] |
| 167 | else: |
| 168 | raise ValueError("sub type {sub_type} not supported") |
| 169 | elif scheme_type == "openIdConnect": |
| 170 | headers[header_name] = _apply_bearer(value) |
| 171 | elif scheme_type == "oauth2": |
| 172 | if sub_type != "client_credentials": |
| 173 | headers[header_name] = _apply_bearer(value) |
| 174 | elif scheme_type == "http": |
| 175 | if sub_type == "bearer": |
| 176 | headers[header_name] = _apply_bearer(value) |
| 177 | elif sub_type == "basic": |
| 178 | headers[header_name] = value |
| 179 | elif sub_type == "custom": |
| 180 | return |
| 181 | else: |
| 182 | raise ValueError("sub type {sub_type} not supported") |
| 183 | else: |
| 184 | raise ValueError("scheme type {scheme_type} not supported") |
| 185 | |
| 186 | |
| 187 | def _apply_bearer(token: str) -> str: |
no test coverage detected