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

Support SCIM views with custom authentication mechanisms #78

Closed
PIG208 opened this issue Jul 14, 2022 · 4 comments · Fixed by #82
Closed

Support SCIM views with custom authentication mechanisms #78

PIG208 opened this issue Jul 14, 2022 · 4 comments · Fixed by #82

Comments

@PIG208
Copy link

PIG208 commented Jul 14, 2022

login_requried was added to SCIMView.dispatch in f791a44, marking all requests to the SCIM views required for authentication.

This ties with authentication based on the request.user object added by Django's AuthenticationMiddleware, therefore requiring us to actually have a User object representing an authenticated client.

This is not necessarily the case when there isn't a corresponding AUTH_USER_MODEL that can be associated with the SCIM client. login_required ensures the presence of user which is_authenticated, but it does not have anything to do directly with the views themselves.

A current workaround is to create a class preventing to be AUTH_USER_MODEL, that implements is_authenticated. This breaks type-safety and Django's expectation for request.user. But it would be better if django-scim2 actually supports custom authentication methods for the SCIM views.

Additional context can be found here.

@logston
Copy link
Collaborator

logston commented Jul 15, 2022

This is not necessarily the case when there isn't a corresponding AUTH_USER_MODEL that can be associated with the SCIM client.

Great point. A use case where unauthenticated requests are permitted was not considered when developing this package. Also, a use case where a non-Django (ie. AUTH_USER_MODEL) could authenticate to the views was not considered.

Do you have a suggested implementation? My initial reaction is to abstract away the .dispatch middleware and allow for a custom authn middleware before .dispatch is processed, as I believe you've suggested.

@PIG208
Copy link
Author

PIG208 commented Jul 15, 2022

Thank you! That sounds like a reasonable approach.

@andersk
Copy link
Contributor

andersk commented Jul 26, 2022

#82 still only supports predicates that are a function of AUTH_USER_MODEL objects (request.user). We want to authenticate SCIM views with a bearer token, not with Django’s user system, so that doesn’t help our use case. We need to use a predicate that’s a function of request, not a function of request.user.

@logston
Copy link
Collaborator

logston commented Jul 27, 2022

@andersk, please review #84 to ensure it meets your needs.

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