-
Notifications
You must be signed in to change notification settings - Fork 27
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
Apply SCIMAuthCheckMiddleware directly to SCIMView.dispatch #85
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small change request but otherwise this looks good. Thanks for the patch.
@@ -229,6 +228,7 @@ | |||
'SCHEME': 'https', | |||
# use default value, this will be overridden by value returned by BASE_LOCATION_GETTER | |||
'NETLOC': 'localhost', | |||
'AUTH_CHECK_MIDDLEWARE': 'app.middleware.CustomSCIMAuthCheckMiddleware', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this back to app.middleware.SCIMAuthCheckMiddleware
. As a developer, I would want to name my class CustomSCIMAuthCheckMiddleware
and have the library's version be either SCIMAuthCheckMiddleware
, BaseSCIMAuthCheckMiddleware
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn’t the library’s version; it’s part of the demo app (demo/app/middleware.py
), and has been since 0759c04. The only thing I changed here is to move it from MIDDLEWARE_CLASSES
to AUTH_CHECK_MIDDLEWARE
.
The library’s version is still django_scim.middleware.SCIMAuthCheckMiddleware
, and developers who want that don’t need to customize AUTH_CHECK_MIDDLEWARE
at all since it’s the default (src/django_scim/settings.py
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes.
(Rebased onto |
This way, the user no longer needs to install our middleware in their project settings; this simplifies configuration and avoids a performance penalty for all non-SCIM requests. Additionally, since SCIMView now has a guarantee that SCIMAuthCheckMiddleware is being used (unless the new AUTH_CHECK_MIDDLEWARE setting is explicitly overridden), it no longer needs to perform its own redundant version of the check. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
@andersk Thanks so much for this change, one of the things I wanted to address in order to use this library was not adding a site-wide middleware, and it looks like you've already beaten me to it! @logston Is there a release schedule for when these changes might be made available on PyPI? I'd love to take advantage of them! I can install from the git repo at a specific hash for now, but would be a bit harder to manage updates that way. |
This way, the user no longer needs to install our middleware in their project settings; this simplifies configuration and avoids a performance penalty for all non-SCIM requests.
Additionally, since
SCIMView
now has a guarantee thatSCIMAuthCheckMiddleware
is being used (unless the newAUTH_CHECK_MIDDLEWARE
setting is explicitly overridden), it no longer needs to perform its own redundant version of the check.With the redundant check removed, we could go further and remove the
GET_IS_AUTHENTICATED_PREDICATE
setting, since the same effect can be achieved by setting theAUTH_CHECK_MIDDLEWARE
setting to a custom subclass ofSCIMAuthCheckMiddleware
.@logston What do you think about this strategy?