Skip to content
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

userinfo returns wrong response with django cache enabled #343

Open
ZuSe opened this issue Aug 27, 2019 · 2 comments
Open

userinfo returns wrong response with django cache enabled #343

ZuSe opened this issue Aug 27, 2019 · 2 comments

Comments

@ZuSe
Copy link

ZuSe commented Aug 27, 2019

We have identified some unexpected behavior with any django cache (db or redis) enabled.
Our Ressource-Servers are using the userinfo endpoint to resolve users from the previously shipped Bearer Token (on login)

We are calling the /userinfo/ endpoint with GET and have the token in the header e.g.
curl -X GET
https://accounts.xxxxx.org/oidc/userinfo
-H 'Authorization: Bearer 3c698d49ef13460b9e3933318430c733'
-H 'cache-control: no-cache'

On the first request the userdata (sub, email etc.) is returned as expected.

However, if in the meantime any other user calls the endpoint it can happen that userinfo returns another user which does not own the Bearer token on a second request.
With cache disabled everything works e.g.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}

I have looked in the code but could not figure out how the default django cache should affect the response behavior. Maybe some of you guys got an idea.

Funny sidenote: Using POST indead of GET everything works, but most libs dont support that.

@suutari-ai
Copy link
Contributor

Maybe the view should be decorated with @vary_on_headers('Authorization')? See `https://docs.djangoproject.com/en/2.2/topics/cache/#using-vary-headers for more info about this decorator.

@ZuSe
Copy link
Author

ZuSe commented Aug 27, 2019

Hi @suutari-ai that sounds like a valid option. As far as i can see there is nothing like that in the code atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants