-
Notifications
You must be signed in to change notification settings - Fork 0
HIDP-51 Add middleware to handle ui_locales #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
HIDP-51 Investigate bug regarding ui_locales querystring param
The AT project sends a param that indicates the preferred client locale, this makes DOT (or the underlying library) crash. Investigate why, report an issue and fix it locally/upstream. |
|
I know this solution works, but I want to hold off with merging it. Two reasons:
|
|
I was able to reproduce and have reported the issue upstream: django-oauth/django-oauth-toolkit#1468 |
c5f1c08 to
80b2d78
Compare
80b2d78 to
33d71fb
Compare
|
I've updated the PR to make this middleware independent of Django's language cookie and |
33d71fb to
4025505
Compare
|
Will this PR be reverted when the two PR's in oAuthToolkit and oAuthLib are merged and released? Or do we always want to use the cookie hidp_language in HIdP? |
|
The language selection/activation will remain. The workaround can be removed if things are fixed upstream. We will probably keep the cookie around, as it’s the easiest way to make sure the translation stays active during the authentication/registration process (KeyCloak does something similar). We might find a better way to do this later, but for now I think this is the best option. |
When the user is redirected to any view of HIdP, the preferred language should be taken into account. However, there are multiple ways and places where users can define their preferred language, so it's hard for us to determine what takes precedence.
The solution we came up with was to use the
ui_localesquery param as source of truth when it is available, as it likely comes from the browser. We check it in middleware and set thedjango_languagecookie based on that.An added benefit is that all of HIdP's views are also translated to comply with the browser language (if the language is supported)
There was also a related bug in Django Oauth Toolkit, that is fixed with this middleware.