-
Notifications
You must be signed in to change notification settings - Fork 449
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
Add support for custom authentication classes #662
Conversation
fb6e80f
to
68ec471
Compare
Add support for custom authentication classes Added a base Authenticator class that all custom authentication classes will extend. The base Authenticator is analogous to the "None" auth type Sparkmagic supported previously. The Basic and Kerberos authenticator classes extend the base Authenticator class and will replace Sparkmagic's existing implementation of Basic Access and Kerberos Authentication. All authenticators have a get_widgets() function that creates the widgets that authenticator needs in the endpoint tab of the %manage_spark widget. Instead of creating widgets for all the different auth types, AddEndpointWidget just loads all the Custom authentication classes from the configuration file and initializes them. Removed the username and password attributes of the Endpoint class and changed the auth attribute to be the Authenticator instance instead of the current implementation which uses a string ("None", "Basic_Access", "Kerberos"). Changed the auth attribute of the ReliableHttpClient to be the authenticator instance of the endpoint. Each custom authenticator implements a call function that takes a Request object as an argument, and attaches the authenticator's authentication to the given Request object. Added an initialize_auth function to utils.py which accepts a parsed arg_string from a magic command and returns the instance of the authenticator that was specified with the -t flag. Changed all the subcommands in remotesparkmagics.py to add/cleanup/delete the endpoint with the Authenticator instance returned from the initialize auth function. Allowing custom Authentication classes makes it easier for others to add their own custom authenticators without having to upstream a change to Sparkmagic in order to use Sparkmagic with their own authentication type. If several other people wanted to add their own authentication types, this would quickly get out of hand. Another way people to add additional authentication types to Sparkmagic would be to make their new authentication changes into a Sparkmagic fork, but this takes a lot of time and effort to maintain. Adding support for custom authentication classes to Sparkmagic will allow others to add their own custom authenticators by creating a lightweight wrapper project that has Sparkmagic as a dependency and that contains their custom authenticator that extends the base Authenticator class.
244b115
to
03946c1
Compare
This duplicates sparkmagic==0.15.0 with pluggable-auth changes and changes all imports to refer to our local sparkmagic. This is a (hopefully) temporary state of affairs until jupyter-incubator/sparkmagic#662 is merged and makes it into a release.
This duplicates sparkmagic==0.15.0 with pluggable-auth changes and changes all imports to refer to our local sparkmagic. This is a (hopefully) temporary state of affairs until jupyter-incubator/sparkmagic#662 is merged and makes it into a release.
This duplicates sparkmagic==0.15.0 with pluggable-auth changes and changes all imports to refer to our local sparkmagic. This is a (hopefully) temporary state of affairs until jupyter-incubator/sparkmagic#662 is merged and makes it into a release.
This duplicates sparkmagic==0.15.0 with pluggable-auth changes and changes all imports to refer to our local sparkmagic. This is a (hopefully) temporary state of affairs until jupyter-incubator/sparkmagic#662 is merged and makes it into a release.
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.
Really nice PR here! Just added some comments regarding some strange spaces but I will pre-approve this. Hopefully we can have more Authentication classes after this PR. \o/
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.
LGTM -- Thank you for the high-quality PR 🥇
@alexismacaskilll any interest in becoming one of the SparkMagic maintainers? Just need to agree to follow code of conduct, and the development process. |
Sorry for the delay! Yes I am interested in being one of the SparkMagic maintainers. |
Fixes #659 : Add support for custom authentication classes
Added a base Authenticator class that all custom authentication classes will extend. The base Authenticator is analogous to the "None" auth type Sparkmagic supported previously. The Basic and Kerberos authenticator classes extend the base Authenticator class and will replace Sparkmagic's existing implementation of Basic Access and Kerberos Authentication. All authenticators have a get_widgets() function that creates the widgets that authenticator needs in the endpoint tab of the %manage_spark widget. Instead of creating widgets for all the different auth types, AddEndpointWidget just loads all the Custom authentication classes from the configuration file and initializes them. Removed the username and password attributes of the Endpoint class and changed the auth attribute to be the Authenticator instance instead of the current implementation which uses a string ("None", "Basic_Access", "Kerberos"). Changed the auth attribute of the ReliableHttpClient to be the authenticator instance of the endpoint. Each custom authenticator implements a call function that takes a Request object as an argument, and attaches the authenticator's authentication to the given Request object. Added an initialize_auth function to utils.py which accepts a parsed arg_string from a magic command and returns the instance of the authenticator that was specified with the -t flag. Changed all the subcommands in remotesparkmagics.py to add/cleanup/delete the endpoint with the Authenticator instance returned from the initialize auth function.
Allowing custom Authentication classes makes it easier for others to add their own custom authenticators without having to upstream a change to Sparkmagic in order to use Sparkmagic with their own authentication type. If several other people wanted to add their own authentication types, this would quickly get out of hand. Another way people to add additional authentication types to Sparkmagic would be to make their new authentication changes into a Sparkmagic fork, but this takes a lot of time and effort to maintain.
Adding support for custom authentication classes to Sparkmagic will allow others to add their own custom authenticators by creating a lightweight wrapper project that has Sparkmagic as a dependency and that contains their custom authenticator that extends the base Authenticator class.