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

MYRIAD-244 Add https/ssl support for Myriad REST APIs and UI #95

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

Conversation

yufeldman
Copy link

This is a PR to cover enabling ssl for Myriad UI and REST APIs. It heavily relies on Hadoop/YARN since it is plugin to RM anyway.

}
ret = listener;
}

ret.setName("Myriad");
ret.setHost("0.0.0.0");
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to be careful here, some people may prefer to only bind to one interface.

Copy link
Author

Choose a reason for hiding this comment

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

Could you elaborate - I did not quite understand your comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

In the case of machines with multiple network interfaces each will have a separate ip address, it's sometimes preferable to only bind to only one ip. Cases include: 1 ip is used to admin, 1 nic is public, etc. I think it's fine for now but we may wish to revisit (I think I'd like it to bind to exactly the same ip(s) as the resourcemanager, though others may disagree).

Copy link
Author

Choose a reason for hiding this comment

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

Aah, I was thinking you were commenting on my changes. Yes - we could bind it on RM host/ip - I think it is actually host not IP though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I noticed it without paying attention to when it was created. Let's make a mental note but shelve for now.

if (keyStore != null) {
listener.setKeystore(keyStore);
listener.setKeystoreType(sslConf.get("ssl.server.keystore.type", "jks"));
listener.setPassword(getPassword(sslConf, WEB_APP_KEYSTORE_PASSWORD_KEY));
Copy link
Contributor

Choose a reason for hiding this comment

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

getPassword has the potential to return null, how does listener.setPassword handle this? Should we throw a more informative exception earlier or pass a sane value?

Copy link
Author

Choose a reason for hiding this comment

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

It is true that if password is null it will actually prompt for password, so we rely on Hadoop configuration to supply it. We could certainly give at least a warning on what may happen

Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth a log.warn("No password found in config if you don't want prompted please set ..."), would help debugging if running the RM in Marathon.

@@ -20,6 +20,7 @@ servedBinaryPath: /tmp/myriadBinary
mesosMaster: 10.0.2.15:5050
haEnabled: false
checkpoint: false
isSSLEnabled: false
Copy link
Contributor

Choose a reason for hiding this comment

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

Add to src/main/resources/myriad-default.conf as minimal documentaion.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to documenting new config options

@@ -0,0 +1,63 @@
<?xml version="1.0"?>
Copy link
Contributor

Choose a reason for hiding this comment

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

should this have an Apache Header?

Copy link
Contributor

Choose a reason for hiding this comment

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

Most poms have:

<!-- ~ Licensed to the Apache Software Foundation (ASF) under one or more 
    ~ contributor license agreements. See the NOTICE file distributed with ~ 
    this work for additional information regarding copyright ownership. ~ The 
    ASF licenses this file to You under the Apache License, Version 2.0 ~ (the 
    "License"); you may not use this file except in compliance with ~ the License. 
    You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 
    ~ ~ Unless required by applicable law or agreed to in writing, software ~ 
    distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT 
    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the 
    License for the specific language governing permissions and ~ limitations 
    under the License. -->

@@ -18,26 +18,84 @@
package org.apache.myriad.webapp;
Copy link
Contributor

Choose a reason for hiding this comment

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

Apache header

Copy link
Author

Choose a reason for hiding this comment

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

It does have header, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad, I'm blaming github.

@DarinJ
Copy link
Contributor

DarinJ commented Nov 4, 2016

Again minor nits, I think the headers have to be resolved before the merge.

@yufeldman
Copy link
Author

Will update PR with headers and other comments

@yufeldman
Copy link
Author

@DarinJ - wonder if you have more comments to this PR?


String trustStore = sslConf.get("ssl.server.truststore.location");

if (trustStore != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a config parameter to check as opposed to a null check? I think the former is a better design as the user will have to explicitly state whether he/she wants to enable SSL authentication and we'll perform checks based upon that as opposed to checking for null

Copy link
Author

Choose a reason for hiding this comment

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

we do have config param to enable SSL and this code is executed only is check is satisfied. sslConf is hadoop Configuration object, not a Myriad one so it will be as good as turning on SSL in RM UI/REST

static String getPassword(Configuration conf, String alias) {
String password = null;
try {
char[] passchars = conf.getPassword(alias);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a config parameter to check as opposed to a null check? I think the former is a better design as the user will have to explicitly state whether he/she wants to enable SSL authentication and we'll perform checks based upon that as opposed to checking for null

password = new String(passchars);
}
} catch (IOException ioe) {
password = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is returning a null password going to cause a difficult-to-debug NPE elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

A lot of @hokiegeek2 suggestions could be alleviated with guava's optional.

Copy link
Author

Choose a reason for hiding this comment

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

Those params are hadoop Configuration params, not Myriad ones and I don't think we should duplicate them in Myriad configuration.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with not duplicating parameters.

@DarinJ
Copy link
Contributor

DarinJ commented Jan 3, 2017

Tested, a few caveats with self-signed certs and mesos but I think we should merge.

Copy link
Contributor

@adam-mesos adam-mesos left a comment

Choose a reason for hiding this comment

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

ASF doesn't like owning binaries (like ssl_keystore and ssl_truststore). Is there any way these can be generated or retrieved as part of the build process?
A few minor nits beyond that, and a +1 on adding docs.

@@ -253,6 +257,9 @@ public Boolean isHAEnabled() {
return Optional.fromNullable(haEnabled).or(DEFAULT_HA_ENABLED);
}

public Boolean isSSLEnabled() {
return Optional.fromNullable(isSSLEnabled).or(DEFAULT_SSL_ENABLED);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: needs blank line after

password = null;
}
if (password == null) {
LOGGER.warn("No password found in config as property: {}. If you don't want prompted please set ...", alias);
Copy link
Contributor

Choose a reason for hiding this comment

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

"If you don't want to be prompted..."

@@ -20,6 +20,7 @@ servedBinaryPath: /tmp/myriadBinary
mesosMaster: 10.0.2.15:5050
haEnabled: false
checkpoint: false
isSSLEnabled: false
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to documenting new config options

<property>
<name>ssl.server.truststore.location</name>
<value>${tmptest.dir}/ssl_truststore</value>
<description>Truststore to be used by webservers. Must be specified.
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of "Must be specified", how about "Required"?

<property>
<name>ssl.server.truststore.password</name>
<value>myriad</value>
<description>Optional. Default value is "".
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the default "" or "myriad"?

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.

4 participants