-
Notifications
You must be signed in to change notification settings - Fork 304
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
consolidate auth config on IdentityProvider #825
Conversation
One question as I shift the default implementation over to IdentityProvider classes: The current default authentication behavior allows token-based auth and password-based login via the login page form. To what degree do these belong on the base class vs a default PasswordIdentityProvider subclass? Options I see:
My current inclination is 2., because an IdentityProvider without token support is unlikely to make sense. Exactly how tokens are implemented is easy to override. |
Is there a plan to make any changes to the "/login" endpoint? In the current LoginHandler, it has both the general auth methods as well as handling any requests to "/login" if |
8da140e
to
4e4b8cb
Compare
Not to the endpoint itself, but to the Handler, yes. All of the general methods will be deprecated or removed. The question remains exactly how much to break vs deprecate. I think that JupyterHub is really the vast majority of custom auth use in Jupyter server, in which case I think breaking is fine. But if there are significant auth users out there, we can try to keep the 'old way' working via deprecations. It'll be a little tricky, but doable. I think the main case to not keeping it working via deprecation is that because it's security related, complicated deprecations may lead to bugs, and security bugs are bad! |
0a1fc22
to
285ab87
Compare
c772d5d
to
ff1fa6e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #825 +/- ##
==========================================
+ Coverage 71.51% 72.28% +0.77%
==========================================
Files 65 65
Lines 7712 7974 +262
Branches 1289 1332 +43
==========================================
+ Hits 5515 5764 +249
Misses 1804 1804
- Partials 393 406 +13 ☔ View full report in Codecov by Sentry. |
d94fc76
to
1d52b1d
Compare
now that we have a configurable class to represent identity, most of the LoginHandler's custom methods belong there Migrates: - ServerApp.password, token config - all LoginHandler class methods Adds: - LegacyIdentityProvider, LegacyLoginHandler to preserve old behavior with new API, triggered with ServerApp.login_handler_class is overridden, but not identity_provider_class.
mypy understands `isinstance(obj, Awaitable)`, but not `isawaitable(obj)`
45de4d2
to
c965d30
Compare
- JupyterHandler.cookie_name -> IdentityProvider.get_cookie_name(handler) - JupyterHandler.clear_login_cookie -> IdentityProvider.clear_login_cookie - JupyterHandler.force_clear_cookie -> IdentityProvider._force_clear_cookie - ServerApp.cookie_options -> IdentityProvider.cookie_options - ServerApp.get_secure_cookie_kwargs -> IdentityProvider.get_secure_cookie_kwargs - ServerApp.tornado_settings[secure_cookie] -> IdentityProvider.secure_cookie
c965d30
to
7cfbf77
Compare
I've done my best to avoid changing any behavior or introducing new features in this PR. The only changes are meant to consolidate auth-related config and implementations spread across a few places (JupyterHandler, ServerApp, LoginHandler, a couple only settable directly in tornado_settings) onto the new IdentityProvider. Names and defaults are all preserved, with the exceptions:
And a couple of new methods/properties to make implementations more overrideable:
General considerations:
|
for better test coverage, including validate_security
previous implementation was on ServerApp
2ee3e20
to
530b96b
Compare
for more information, see https://pre-commit.ci
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.
Great work! The API changes look sensible to me.
self.tornado_settings["token"] = self.token | ||
|
||
# deprecate accessing these directly, in favor of identity_provider? | ||
self.tornado_settings["cookie_options"] = self.identity_provider.cookie_options |
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.
Maybe only add these if we're using the LegacyIdentityProvider
?
Thank you, @minrk. This looks great. Really appreciate all your work here! |
Following #671, we now have a proper Configurable class for managing authentication. Our previous extension point for this was a custom LoginHandler with various overridable class methods (check password, is login available, etc.).
My rough plan:
Methods to migrate from LoginHandler to IdentityProvider, mostly unchanged (except from classmethod to instancementhod):
Changed methods:
auth_enabled
(auth required at all) andlogin_available
(login handler exists) since it makes sense to have a server with auth enabled, but no login page.New methods:
Config to migrate to IdentityProvider:
BaseHandler methods to migrate to IdentityProvider: