|
1 | 1 | import base64 |
2 | 2 | import logging |
| 3 | +from urllib.parse import unquote_plus |
3 | 4 |
|
4 | 5 | from cryptojwt.exception import BadSignature |
5 | 6 | from cryptojwt.exception import Invalid |
@@ -62,7 +63,7 @@ def basic_authn(authn): |
62 | 63 | _tok = as_bytes(authn[6:]) |
63 | 64 | # Will raise ValueError type exception if not base64 encoded |
64 | 65 | _tok = base64.b64decode(_tok) |
65 | | - part = as_unicode(_tok).split(":") |
| 66 | + part = [unquote_plus(p) for p in as_unicode(_tok).split(":")] |
66 | 67 | if len(part) == 2: |
67 | 68 | return dict(zip(["id", "secret"], part)) |
68 | 69 | else: |
@@ -280,19 +281,14 @@ def verify_client( |
280 | 281 |
|
281 | 282 | # store what authn method was used |
282 | 283 | if auth_info.get("method"): |
283 | | - if ( |
284 | | - endpoint_context.cdb[client_id].get("auth_method") |
285 | | - and request.__class__.__name__ |
286 | | - in endpoint_context.cdb[client_id]["auth_method"] |
287 | | - ): |
288 | | - endpoint_context.cdb[client_id]["auth_method"][ |
289 | | - request.__class__.__name__ |
290 | | - ] = auth_info["method"] |
| 284 | + _request_type = request.__class__.__name__ |
| 285 | + _used_authn_method = endpoint_context.cdb[client_id].get("auth_method") |
| 286 | + if _used_authn_method: |
| 287 | + endpoint_context.cdb[client_id]["auth_method"][_request_type] = auth_info["method"] |
291 | 288 | else: |
292 | 289 | endpoint_context.cdb[client_id]["auth_method"] = { |
293 | | - request.__class__.__name__: auth_info["method"] |
| 290 | + _request_type: auth_info["method"] |
294 | 291 | } |
295 | | - |
296 | 292 | elif not client_id and get_client_id_from_token: |
297 | 293 | if not _token: |
298 | 294 | logger.warning("No token") |
|
0 commit comments