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

Apply SCIMAuthCheckMiddleware directly to SCIMView.dispatch #85

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

andersk
Copy link
Contributor

@andersk andersk commented Jul 27, 2022

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.

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 the AUTH_CHECK_MIDDLEWARE setting to a custom subclass of SCIMAuthCheckMiddleware.

@logston What do you think about this strategy?

Copy link
Collaborator

@logston logston left a 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',
Copy link
Collaborator

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.

Copy link
Contributor Author

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).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes.

@andersk andersk changed the base branch from logston/update-custom-authentication to master October 8, 2022 06:45
@andersk
Copy link
Contributor Author

andersk commented Oct 8, 2022

(Rebased onto master so this isn’t entangled with #84.)

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>
@logston logston merged commit b3abe0f into 15five:master Oct 28, 2022
@js-truework
Copy link

@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.

@logston
Copy link
Collaborator

logston commented Nov 4, 2022

Yep, just pushed. @caleb15 do you mind reviewing this: #95

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

Successfully merging this pull request may close these issues.

3 participants