(self, value)
| 196 | return self.authorization_value |
| 197 | |
| 198 | def set_authorization(self, value): |
| 199 | self.authorization_value = value |
| 200 | if value is not None: |
| 201 | invalid_value = ( |
| 202 | "You should use a value like ('Basic', ('user', 'password'))" |
| 203 | " OR ('Bearer', 'token') OR ('JWT', 'token')" |
| 204 | ) |
| 205 | if isinstance(value, (list, tuple)) and len(value) == 2: |
| 206 | authtype, val = value |
| 207 | if authtype == 'Basic' and val and \ |
| 208 | isinstance(val, (list, tuple)): |
| 209 | val = ':'.join(list(val)) |
| 210 | val = b64encode(to_bytes(val)).strip() |
| 211 | val = val.decode('latin1') |
| 212 | elif authtype in ('Bearer', 'JWT') and val and \ |
| 213 | isinstance(val, (str, str)): |
| 214 | val = val.strip() |
| 215 | else: |
| 216 | raise ValueError(invalid_value) |
| 217 | value = str(f'{authtype} {val}') |
| 218 | else: |
| 219 | raise ValueError(invalid_value) |
| 220 | self.extra_environ.update({ |
| 221 | 'HTTP_AUTHORIZATION': value, |
| 222 | }) |
| 223 | else: |
| 224 | if 'HTTP_AUTHORIZATION' in self.extra_environ: |
| 225 | del self.extra_environ['HTTP_AUTHORIZATION'] |
| 226 | |
| 227 | authorization = property(get_authorization, set_authorization) |
| 228 |
nothing calls this directly
no test coverage detected