-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
494 additions
and
204 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM jupyter/base-notebook:ae885c0a6226 | ||
FROM jupyter/base-notebook | ||
|
||
ARG dev_mode=false | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.16.0' | ||
__version__ = '0.17.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.16.0' | ||
__version__ = '0.17.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
__version__ = '0.16.0' | ||
__version__ = '0.17.0' | ||
|
||
from sparkmagic.serverextension.handlers import load_jupyter_server_extension | ||
|
||
|
||
def _jupyter_server_extension_paths(): | ||
return [{ | ||
"module": "sparkmagic" | ||
}] | ||
return [{"module": "sparkmagic"}] | ||
|
||
|
||
def _jupyter_nbextension_paths(): | ||
return [] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
"""Class for implementing a basic access authenticator for SparkMagic""" | ||
|
||
from sparkmagic.livyclientlib.exceptions import BadUserDataException | ||
from hdijupyterutils.ipywidgetfactory import IpyWidgetFactory | ||
from requests.auth import HTTPBasicAuth | ||
from .customauth import Authenticator | ||
|
||
class Basic(HTTPBasicAuth, Authenticator): | ||
"""Basic Access authenticator for SparkMagic""" | ||
def __init__(self, parsed_attributes=None): | ||
"""Initializes the Authenticator with the attributes in the attributes | ||
parsed from a %spark magic command if applicable, or with default values | ||
otherwise. | ||
Args: | ||
self, | ||
parsed_attributes (IPython.core.magics.namespace): The namespace object that | ||
is created from parsing %spark magic command. | ||
""" | ||
if parsed_attributes is not None: | ||
if parsed_attributes.user is '' or parsed_attributes.password is '': | ||
new_exc = BadUserDataException("Need to supply username and password arguments for "\ | ||
"Basic Access Authentication. (e.g. -a username -p password).") | ||
raise new_exc | ||
self.username = parsed_attributes.user | ||
self.password = parsed_attributes.password | ||
else: | ||
self.username = 'username' | ||
self.password = 'password' | ||
HTTPBasicAuth.__init__(self, self.username, self.password) | ||
Authenticator.__init__(self, parsed_attributes) | ||
|
||
def get_widgets(self, widget_width): | ||
"""Creates and returns a list with an address, username, and password widget | ||
Args: | ||
widget_width (str): The width of all widgets to be created. | ||
Returns: | ||
Sequence[hdijupyterutils.ipywidgetfactory.IpyWidgetFactory]: list of widgets | ||
""" | ||
ipywidget_factory = IpyWidgetFactory() | ||
|
||
self.user_widget = ipywidget_factory.get_text( | ||
description='Username:', | ||
value=self.username, | ||
width=widget_width | ||
) | ||
|
||
self.password_widget = ipywidget_factory.get_text( | ||
description='Password:', | ||
value=self.password, | ||
width=widget_width | ||
) | ||
|
||
widgets = [self.user_widget, self.password_widget] | ||
return Authenticator.get_widgets(self, widget_width) + widgets | ||
|
||
def update_with_widget_values(self): | ||
"""Updates url, username, and password to be the value of their respective widgets.""" | ||
Authenticator.update_with_widget_values(self) | ||
self.username = self.user_widget.value | ||
self.password = self.password_widget.value | ||
|
||
def __eq__(self, other): | ||
if not isinstance(other, Basic): | ||
return False | ||
return self.url == other.url and self.username == other.username and \ | ||
self.password == other.password | ||
|
||
def __call__(self, request): | ||
return HTTPBasicAuth.__call__(self, request) | ||
|
||
def __hash__(self): | ||
return hash((self.username, self.password, self.url, self.__class__.__name__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Base class for implementing an authentication provider for SparkMagic""" | ||
|
||
from hdijupyterutils.ipywidgetfactory import IpyWidgetFactory | ||
from sparkmagic.utils.constants import WIDGET_WIDTH | ||
|
||
class Authenticator(object): | ||
"""Base Authenticator for all Sparkmagic authentication providers.""" | ||
|
||
def __init__(self, parsed_attributes=None): | ||
"""Initializes the Authenticator with the attributes in the attributes | ||
parsed from a %spark magic command if applicable, or with default values | ||
otherwise. | ||
Args: | ||
self, | ||
parsed_attributes (IPython.core.magics.namespace): The namespace object that | ||
is created from parsing %spark magic command. | ||
""" | ||
if parsed_attributes is not None: | ||
self.url = parsed_attributes.url | ||
else: | ||
self.url = 'http://example.com/livy' | ||
self.widgets = self.get_widgets(WIDGET_WIDTH) | ||
|
||
def get_widgets(self, widget_width): | ||
"""Creates and returns an address widget | ||
Args: | ||
widget_width (str): The width of all widgets to be created. | ||
Returns: | ||
Sequence[hdijupyterutils.ipywidgetfactory.IpyWidgetFactory]: list of widgets | ||
""" | ||
ipywidget_factory = IpyWidgetFactory() | ||
|
||
self.address_widget = ipywidget_factory.get_text( | ||
description='Address:', | ||
value='http://example.com/livy', | ||
width=widget_width | ||
) | ||
widgets = [self.address_widget] | ||
return widgets | ||
|
||
def update_with_widget_values(self): | ||
"""Updates url to be value in address widget.""" | ||
self.url = self.address_widget.value | ||
|
||
def __call__(self, request): | ||
"""subclasses should override""" | ||
return None | ||
|
||
def __eq__(self, other): | ||
if not isinstance(other, Authenticator): | ||
return False | ||
return self.url == other.url | ||
|
||
def __hash__(self): | ||
return hash((self.url, self.__class__.__name__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Class for implementing a Kerberos authenticator for SparkMagic""" | ||
|
||
from requests_kerberos import HTTPKerberosAuth | ||
import sparkmagic.utils.configuration as conf | ||
from .customauth import Authenticator | ||
|
||
|
||
class Kerberos(HTTPKerberosAuth, Authenticator): | ||
"""Kerberos authenticator for SparkMagic""" | ||
|
||
def __init__(self, parsed_attributes=None): | ||
"""Initializes the Authenticator with the attributes in the attributes | ||
parsed from a %spark magic command if applicable, or with default values | ||
otherwise. | ||
Args: | ||
self, | ||
parsed_attributes (IPython.core.magics.namespace): The namespace object that | ||
is created from parsing %spark magic command. | ||
""" | ||
HTTPKerberosAuth.__init__(self, **conf.kerberos_auth_configuration()) | ||
Authenticator.__init__(self, parsed_attributes) | ||
|
||
def __call__(self, request): | ||
return HTTPKerberosAuth.__call__(self, request) | ||
|
||
def __hash__(self): | ||
return hash((self.url, self.__class__.__name__)) |
Oops, something went wrong.