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

Add support for custom authentication classes #662

Merged
merged 5 commits into from
Oct 11, 2020

Conversation

amacaskill
Copy link
Contributor

@amacaskill amacaskill commented Aug 14, 2020

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.

amacaskill and others added 2 commits August 19, 2020 14:46
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.
JerryLeiDing pushed a commit to GoogleCloudDataproc/dataprocmagic that referenced this pull request Sep 11, 2020
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.
JerryLeiDing pushed a commit to GoogleCloudDataproc/dataprocmagic that referenced this pull request Sep 11, 2020
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.
JerryLeiDing pushed a commit to GoogleCloudDataproc/dataprocmagic that referenced this pull request Sep 11, 2020
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.
JerryLeiDing pushed a commit to GoogleCloudDataproc/dataprocmagic that referenced this pull request Sep 11, 2020
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.
Copy link
Collaborator

@PedroRossi PedroRossi left a 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/

Copy link
Collaborator

@devstein devstein left a 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 🥇

@devstein devstein merged commit 9b6487a into jupyter-incubator:master Oct 11, 2020
@itamarst
Copy link
Contributor

@alexismacaskilll any interest in becoming one of the SparkMagic maintainers? Just need to agree to follow code of conduct, and the development process.

@amacaskill
Copy link
Contributor Author

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

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.

Add pluggable authentication support
4 participants