[cwclientlib,signedrequests] Authentication fails when the locales of the client and servers are different
Bug
Authentication fails when the locales of the client and servers are different
Step to reproduce
- Take a cubicweb instance with signedrequests installed. Assume the server is configured in english.
- execute the following script:
import locale
from cwclientlib import cwproxy_for
locale.setlocale(locale.LC_TIME, "fr_FR.UTF-8")
PROXY = cwproxy_for("https://MYSERVER.COM")
PROXY.execute("Any X LIMIT 1")
this will fail with an Authentication Error, with cwclientlib 1.2.2 and signedrequests 1.1.0 (latest versions as this time).
Removing the locale.setlocale(locale.LC_TIME, "fr_FR.UTF-8")
make the authentication right (assuming the token and cwclientlibrc etc are well configured).
Expected behavior
No Authentication Error regarding the locales value.
Suggested steps to fix
-
Change the format of the sent Date through the headers (here). It currently contains the weekday and month as string, written in the user's locale (hence the issue). We could use simply use
datetime.utcnow().isoformat()
. -
Change the way the date is parsed in
signedrequests
(here). We could usedatetime.fromisoformat
.
Retro-compatibility
To discuss.