-
Notifications
You must be signed in to change notification settings - Fork 439
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
Kerberos authentication support #355
Changes from all commits
59360e6
f4cd1af
a72c81b
0ef38e6
fd63ccb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# Distributed under the terms of the Modified BSD License. | ||
from sparkmagic.controllerwidget.abstractmenuwidget import AbstractMenuWidget | ||
from sparkmagic.livyclientlib.endpoint import Endpoint | ||
import sparkmagic.utils.constants as constants | ||
|
||
|
||
class AddEndpointWidget(AbstractMenuWidget): | ||
|
@@ -32,24 +33,42 @@ def __init__(self, spark_controller, ipywidget_factory, ipython_display, endpoin | |
value='password', | ||
width=widget_width | ||
) | ||
self.auth = self.ipywidget_factory.get_dropdown( | ||
options={constants.AUTH_KERBEROS: constants.AUTH_KERBEROS, constants.AUTH_BASIC: constants.AUTH_BASIC, | ||
constants.NO_AUTH: constants.NO_AUTH}, | ||
description=u"Auth type:" | ||
) | ||
|
||
# Submit widget | ||
self.submit_widget = self.ipywidget_factory.get_submit_button( | ||
description='Add endpoint' | ||
) | ||
|
||
self.auth.on_trait_change(self._show_correct_endpoint_fields) | ||
|
||
self.children = [self.ipywidget_factory.get_html(value="<br/>", width=widget_width), | ||
self.address_widget, self.user_widget, self.password_widget, | ||
self.address_widget, self.auth, self.user_widget, self.password_widget, | ||
self.ipywidget_factory.get_html(value="<br/>", width=widget_width), self.submit_widget] | ||
|
||
for child in self.children: | ||
child.parent_widget = self | ||
|
||
self._show_correct_endpoint_fields() | ||
|
||
def run(self): | ||
endpoint = Endpoint(self.address_widget.value, self.user_widget.value, self.password_widget.value) | ||
endpoint = Endpoint(self.address_widget.value, self.auth.value, self.user_widget.value, self.password_widget.value) | ||
self.endpoints[self.address_widget.value] = endpoint | ||
self.ipython_display.writeln("Added endpoint {}".format(self.address_widget.value)) | ||
|
||
# We need to call the refresh method because drop down in Tab 2 for endpoints wouldn't refresh with the new | ||
# value otherwise. | ||
self.refresh_method() | ||
|
||
def _show_correct_endpoint_fields(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you try this signature on trait change? Did it work? I would have expected it to throw and for the fields not to be updated if the signature of the method were wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested it and works fine. |
||
if self.auth.value == constants.NO_AUTH or self.auth.value == constants.AUTH_KERBEROS: | ||
self.user_widget.layout.display = 'none' | ||
self.password_widget.layout.display = 'none' | ||
else: | ||
self.user_widget.layout.display = 'flex' | ||
self.password_widget.layout.display = 'flex' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ def manage_spark(self, line, local_ns=None): | |
@argument("-u", "--url", type=str, default=None, help="URL for Livy endpoint") | ||
@argument("-a", "--user", type=str, default="", help="Username for HTTP access to Livy endpoint") | ||
@argument("-p", "--password", type=str, default="", help="Password for HTTP access to Livy endpoint") | ||
@argument("-t", "--auth", type=str, help="Auth type for HTTP access to Livy endpoint. [Kerberos, None, Basic Auth]") | ||
@argument("-l", "--language", type=str, default=None, | ||
help="Language for Livy session; one of {}".format(', '.join([LANG_PYTHON, LANG_SCALA, LANG_R]))) | ||
@argument("command", type=str, default=[""], nargs="*", help="Commands to execute.") | ||
|
@@ -78,7 +79,7 @@ def spark(self, line, cell="", local_ns=None): | |
add | ||
Add a Livy session given a session name (-s), language (-l), and endpoint credentials. | ||
The -k argument, if present, will skip adding this session if it already exists. | ||
e.g. `%spark add -s test -l python -u https://sparkcluster.net/livy -a u -p -k` | ||
e.g. `%spark add -s test -l python -u https://sparkcluster.net/livy -t Kerberos -a u -p -k` | ||
config | ||
Override the livy session properties sent to Livy on session creation. All session creations will | ||
contain these config settings from then on. | ||
|
@@ -112,7 +113,7 @@ def spark(self, line, cell="", local_ns=None): | |
# info | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to update the documentation in the comment above to add the |
||
if subcommand == "info": | ||
if args.url is not None: | ||
endpoint = Endpoint(args.url, args.user, args.password) | ||
endpoint = Endpoint(args.url, args.auth, args.user, args.password) | ||
info_sessions = self.spark_controller.get_all_sessions_endpoint_info(endpoint) | ||
self._print_endpoint_info(info_sessions) | ||
else: | ||
|
@@ -128,7 +129,7 @@ def spark(self, line, cell="", local_ns=None): | |
|
||
name = args.session | ||
language = args.language | ||
endpoint = Endpoint(args.url, args.user, args.password) | ||
endpoint = Endpoint(args.url, args.auth, args.user, args.password) | ||
skip = args.skip | ||
|
||
properties = conf.get_session_properties(language) | ||
|
@@ -142,15 +143,15 @@ def spark(self, line, cell="", local_ns=None): | |
if args.id is None: | ||
self.ipython_display.send_error("Must provide --id or -i option to delete session at endpoint from URL") | ||
return | ||
endpoint = Endpoint(args.url, args.user, args.password) | ||
endpoint = Endpoint(args.url, args.auth, args.user, args.password) | ||
session_id = args.id | ||
self.spark_controller.delete_session_by_id(endpoint, session_id) | ||
else: | ||
self.ipython_display.send_error("Subcommand 'delete' requires a session name or a URL and session ID") | ||
# cleanup | ||
elif subcommand == "cleanup": | ||
if args.url is not None: | ||
endpoint = Endpoint(args.url, args.user, args.password) | ||
endpoint = Endpoint(args.url, args.auth, args.user, args.password) | ||
self.spark_controller.cleanup_endpoint(endpoint) | ||
else: | ||
self.spark_controller.cleanup() | ||
|
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.
Calling initially to display right display elements initially as per the auth type.