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

Support Client Side Cert for Livy #576

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

stonezhong
Copy link

Our livy is deployed in such a way:
It has a whitelist of CNs and require client to present a client side certificate, only client cert whose CN match the whitelist will be allow to access livy.

I am adding 3 configs to kernel_{language}_credentials:
ssl_client_cert, ssl_client_key and ssl_verify

I have the following config:

{
  "kernel_python_credentials" : {
    "username": "my_username",
    "password": "mu_password",
    "url": "https://my_livy_url/",
    "auth": "Basic_Access",
    "ssl_client_cert": "/root/.sparkmagic/sso_client.crt",
    "ssl_client_key":  "/root/.sparkmagic/sso_client.key",
    "ssl_verify":      "/root/.sparkmagic/CombinedDigicertCA.cer"
  },
...

Tested it and the change worked for me.

Copy link
Contributor

@itamarst itamarst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch! This seems like a useful feature.

Nice to have: Besides the inline comments, I'm starting to think that we really need some sort of end-to-end test framework this could run in... but I realize that's a big change given there aren't any at the moment.

Required: At the very minimum, though, I don't think there's any new unittests for the new codepaths, which would be good. And I'd like a bit added to the README explaining how to use this new feature.

Thank you!


def __ne__(self, other):
return not self == other

def __str__(self):
return u"Endpoint({})".format(self.url)

class SSLInfo(object):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a docstring explain what this class does, and what the parameters are.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this seems like a good place to start using attrs (http://www.attrs.org/en/stable/), it'll make this class much much shorter.

@@ -389,7 +389,12 @@ def matplot(self, line, cell="", local_ns=None):
def refresh_configuration(self):
credentials = getattr(conf, 'base64_kernel_' + self.language + '_credentials')()
(username, password, auth, url) = (credentials['username'], credentials['password'], credentials['auth'], credentials['url'])
self.endpoint = Endpoint(url, auth, username, password)
(ssl_client_cert, ssl_client_key, ssl_verify) = (credentials.get('ssl_client_cert'), credentials.get('ssl_client_key'), credentials.get('ssl_verify'),)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we say "TLS" instead of "SSL" everywhere? It's been TLS for 20 years now :)

@@ -61,15 +61,37 @@ def _send_request_helper(self, url, accepted_status_codes, function, data, retry
try:
if self._endpoint.auth == constants.NO_AUTH:
if data is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now has a huge amount of duplicate paths and code, which makes me worry about errors. Can it be simplified? E.g.

if data is not None:
    data = json.dumps(data)

at the top would simplify it quite a lot, and so on.


def __ne__(self, other):
return not self == other

def __str__(self):
return u"Endpoint({})".format(self.url)

class SSLInfo(object):
def __init__(self, client_cert, client_key, ssl_verify):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having two different places where youo set ssl_verify, this and the config, bothers me a little. Is there a reason to have it here and not just rely on the config?

@itamarst itamarst added the awaiting-submitter-response Waiting for answer from person who submitted question label Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-submitter-response Waiting for answer from person who submitted question
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants