Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

fix(cognito): use unquote instead of unquote_plus for Basic auth credentials _authenticate_client was using unquote_plus to decode client credentials extracted from the Authorization: Basic header. unquote_plus converts '+' to space, which corrupts base64-encoded client secrets that naturally contain '+' characters (~50% of generated secrets). This caused test_oauth2_token_client_auth_basic to fail non-deterministically depending on whether the randomly generated secret contained '+'. Switch to unquote which only decodes %XX sequences, leaving '+' intact. This matches how real OAuth2 clients (and AWS Cognito) handle Basic auth. (#1015)

Johannes Grumböck3516ff5ed75c
diff --git a/ministack/services/cognito.py b/ministack/services/cognito.py
index 80e65cfb..c8d85b09 100644
--- a/ministack/services/cognito.py
+++ b/ministack/services/cognito.py
@@ -63,7 +63,7 @@ import string
import time
import zlib
from datetime import datetime, timezone
-from urllib.parse import parse_qs, quote, unquote_plus, urlencode
+from urllib.parse import parse_qs, quote, unquote, urlencode
from xml.etree.ElementTree import Element, SubElement
from xml.etree.ElementTree import tostring as xml_tostring
@@ -1236,7 +1236,7 @@ def _authenticate_client(headers: dict, form: dict):
# containing "/" or "+" arrives as %2F/%2B and must be decoded to
# match the stored value. The client_secret_post path already gets
# this via parse_qs.
- return unquote_plus(cid), unquote_plus(csec)
+ return unquote(cid), unquote(csec)
except Exception:
pass
return form.get("client_id", ""), form.get("client_secret", "")