You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+59-6Lines changed: 59 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -68,16 +68,20 @@ See the [Sending Local Data to Spark notebook](examples/Send%20local%20data%20to
68
68
jupyter serverextension enable --py sparkmagic
69
69
70
70
## Authentication Methods
71
-
72
-
Sparkmagic supports:
73
-
74
-
* No auth
71
+
Sparkmagic supports:
72
+
* No auth
75
73
* Basic authentication
76
74
* Kerberos
77
75
76
+
The [Authenticator](sparkmagic/sparkmagic/auth/customauth.py) is the mechanism for authenticating to Livy. The base
77
+
Authenticator used by itself supports no auth, but it can be subclassed to enable authentication via other methods.
78
+
Two such examples are the [Basic](sparkmagic/sparkmagic/auth/basic.py) and [Kerberos](sparkmagic/sparkmagic/auth/kerberos.py) Authenticators.
79
+
80
+
### Kerberos Authenticator
81
+
78
82
Kerberos support is implemented via the [requests-kerberos](https://github.com/requests/requests-kerberos) package. Sparkmagic expects a kerberos ticket to be available in the system. Requests-kerberos will pick up the kerberos ticket from a cache file. For the ticket to be available, the user needs to have run [kinit](https://web.mit.edu/kerberos/krb5-1.12/doc/user/user_commands/kinit.html) to create the kerberos ticket.
79
83
80
-
### Kerberos Configuration
84
+
####Kerberos Configuration
81
85
82
86
By default the `HTTPKerberosAuth` constructor provided by the `requests-kerberos` package will use the following configuration
83
87
```python
@@ -97,7 +101,56 @@ but this will not be right configuration for every context, so it is able to pas
97
101
"send_cbt": true
98
102
}
99
103
}
100
-
```
104
+
```
105
+
106
+
### Custom Authenticators
107
+
108
+
You can write custom Authenticator subclasses to enable authentication via other mechanisms. All Authenticator subclasses
109
+
should override the `Authenticator.__call__(request)` method that attaches HTTP Authentication to the given Request object.
110
+
111
+
Authenticator subclasses that add additional class attributes to be used for the authentication, such as the [Basic] (sparkmagic/sparkmagic/auth/basic.py) authenticator which adds `username` and `password` attributes, should override the `__hash__`, `__eq__`, `update_with_widget_values`, and `get_widgets` methods to work with these new attributes. This is necessary in order for the Authenticator to use these attributes in the authentication process.
112
+
113
+
#### Using a Custom Authenticator with Sparkmagic
114
+
115
+
If your repository layout is:
116
+
117
+
.
118
+
├── LICENSE
119
+
├── README.md
120
+
├── customauthenticator
121
+
│ ├── __init__.py
122
+
│ ├── customauthenticator.py
123
+
└── setup.py
124
+
125
+
Then to pip install from this repository, run: `pip install git+https://git_repo_url/#egg=customauthenticator`
126
+
127
+
After installing, you need to register the custom authenticator with Sparkmagic so it can be dynamically imported. This can be done in two different ways:
128
+
1. Edit the configuration file at [`~/.sparkmagic/config.json`](config.json) with the following settings:
This adds your `CustomAuthenticator` class in `customauthenticator.py` to Sparkmagic. `Custom_Auth` is the authentication type that will be displayed in the `%manage_spark` widget's Auth type dropdown as well as the Auth type passed as an argument to the -t flag in the `%spark add session` magic.
142
+
143
+
2. Modify the `authenticators` method in [`sparkmagic/utils/configuration.py`](sparkmagic/sparkmagic/utils/configuration.py) to return your custom authenticator:
0 commit comments