You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by aledsage <gi...@git.apache.org> on 2014/08/07 17:44:38 UTC
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
GitHub user aledsage opened a pull request:
https://github.com/apache/incubator-brooklyn/pull/112
BROOKLYN-15: support sha256 passwords for web-console
@sjcorbett @grkvlt can you please review?
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/aledsage/incubator-brooklyn feature/hashed-webconsole-password
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-brooklyn/pull/112.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #112
----
commit a6be95c9f5de5f16caf5b8a361f116ebb442f7be
Author: Aled Sage <al...@gmail.com>
Date: 2014-08-07T15:42:16Z
BROOKLYN-15: support sha256 passwords for web-console
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#issuecomment-51587152
Thanks @sjcorbett - great comments. Was not sure about the automation case. A `--password` is bad practice because it is visible to anyone doing `ps`, and ends up in bash history etc. Reading from stdin is a little less bad. A great discussion of this at http://stackoverflow.com/a/715681/1393883.
I'll add support for stdin to help user "circumvent 35 years of Unix security"!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#discussion_r15986075
--- Diff: usage/cli/src/main/java/brooklyn/cli/Main.java ---
@@ -200,6 +203,57 @@ public Void call() throws Exception {
}
}
+ @Command(name = "generate-password", description = "Generates a hashed web-console password")
+ public static class GeneratePasswordCommand extends BrooklynCommandCollectingArgs {
+
+ @Option(name = { "--user" }, title = "username", required = true)
+ public String user;
+
+ @Override
+ public Void call() throws Exception {
+ System.out.println(BANNER);
+ System.out.println("Version: " + BrooklynVersion.get());
+ System.out.println("Website: http://brooklyn.incubator.apache.org");
+ System.out.println("Source: https://github.com/apache/incubator-brooklyn");
+ System.out.println();
+ System.out.println("Copyright 2011-2014 The Apache Software Foundation.");
+ System.out.println("Licensed under the Apache 2.0 License");
+ System.out.println();
+
+ Console console = System.console();
+ if (console == null) {
+ System.err.println("No console; cannot get password securely from standard input; aborting");
+ }
+ System.out.print("Enter password: ");
+ System.out.flush();
+ char[] chars = console.readPassword();
+ if (Strings.isBlank(new String(chars))) {
+ System.err.println("Password must not be blank; aborting");
+ return null;
+ }
+
+ System.out.print("Re-enter password: ");
+ System.out.flush();
+ char[] chars2 = console.readPassword();
+ if (!Arrays.equals(chars, chars2)) {
+ System.err.println("Passwords did not match; aborting");
+ return null;
+ }
+
+ String salt = Identifiers.makeRandomId(4);
+ String sha256password = PasswordHasher.sha256(salt, new String(chars));
+
+ System.out.println();
+ System.out.println("Please enter the following into your brooklyn.properies:");
--- End diff --
Would prefer the line to be phrased "Please add the following to your brooklyn.properties".
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#discussion_r15986181
--- Diff: usage/cli/src/main/java/brooklyn/cli/Main.java ---
@@ -200,6 +203,57 @@ public Void call() throws Exception {
}
}
+ @Command(name = "generate-password", description = "Generates a hashed web-console password")
+ public static class GeneratePasswordCommand extends BrooklynCommandCollectingArgs {
+
+ @Option(name = { "--user" }, title = "username", required = true)
+ public String user;
+
+ @Override
+ public Void call() throws Exception {
+ System.out.println(BANNER);
+ System.out.println("Version: " + BrooklynVersion.get());
+ System.out.println("Website: http://brooklyn.incubator.apache.org");
+ System.out.println("Source: https://github.com/apache/incubator-brooklyn");
+ System.out.println();
+ System.out.println("Copyright 2011-2014 The Apache Software Foundation.");
+ System.out.println("Licensed under the Apache 2.0 License");
+ System.out.println();
+
+ Console console = System.console();
+ if (console == null) {
+ System.err.println("No console; cannot get password securely from standard input; aborting");
+ }
+ System.out.print("Enter password: ");
+ System.out.flush();
+ char[] chars = console.readPassword();
+ if (Strings.isBlank(new String(chars))) {
+ System.err.println("Password must not be blank; aborting");
+ return null;
+ }
+
+ System.out.print("Re-enter password: ");
+ System.out.flush();
+ char[] chars2 = console.readPassword();
+ if (!Arrays.equals(chars, chars2)) {
+ System.err.println("Passwords did not match; aborting");
+ return null;
+ }
+
+ String salt = Identifiers.makeRandomId(4);
+ String sha256password = PasswordHasher.sha256(salt, new String(chars));
+
+ System.out.println();
+ System.out.println("Please enter the following into your brooklyn.properies:");
--- End diff --
Also, properties is misspelt.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#issuecomment-51586207
Is it worth allowing username/password to be given as command line arguments? As it stands the command can't be automated, which will be a pain to someone eventually.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/incubator-brooklyn/pull/112
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#issuecomment-51605631
Incorporated review comments and rebased. I'm happy to merge this, and for the conversation about `--stdin` and `--password` to continue on the mailing list.
@sjcorbett is merging ok with you?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#issuecomment-51587601
Perhaps it's worth getting everyone else's opinions on a `--password` flag. @ahgittin, @grkvlt?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#issuecomment-51586652
A handful of comments. The missing return should definitely be included and I'd be keen to see non-zero exit codes when it aborts. I think adding a --password flag is useful but unnecessary now. Tests pass.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#discussion_r15986171
--- Diff: usage/cli/src/main/java/brooklyn/cli/Main.java ---
@@ -200,6 +203,57 @@ public Void call() throws Exception {
}
}
+ @Command(name = "generate-password", description = "Generates a hashed web-console password")
+ public static class GeneratePasswordCommand extends BrooklynCommandCollectingArgs {
+
+ @Option(name = { "--user" }, title = "username", required = true)
+ public String user;
+
+ @Override
+ public Void call() throws Exception {
+ System.out.println(BANNER);
+ System.out.println("Version: " + BrooklynVersion.get());
+ System.out.println("Website: http://brooklyn.incubator.apache.org");
+ System.out.println("Source: https://github.com/apache/incubator-brooklyn");
+ System.out.println();
+ System.out.println("Copyright 2011-2014 The Apache Software Foundation.");
+ System.out.println("Licensed under the Apache 2.0 License");
+ System.out.println();
+
+ Console console = System.console();
+ if (console == null) {
+ System.err.println("No console; cannot get password securely from standard input; aborting");
+ }
+ System.out.print("Enter password: ");
+ System.out.flush();
+ char[] chars = console.readPassword();
+ if (Strings.isBlank(new String(chars))) {
+ System.err.println("Password must not be blank; aborting");
+ return null;
--- End diff --
Can we exit with a non-zero code when we abort?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#discussion_r15986017
--- Diff: usage/cli/src/main/java/brooklyn/cli/Main.java ---
@@ -200,6 +203,57 @@ public Void call() throws Exception {
}
}
+ @Command(name = "generate-password", description = "Generates a hashed web-console password")
+ public static class GeneratePasswordCommand extends BrooklynCommandCollectingArgs {
+
+ @Option(name = { "--user" }, title = "username", required = true)
+ public String user;
+
+ @Override
+ public Void call() throws Exception {
+ System.out.println(BANNER);
+ System.out.println("Version: " + BrooklynVersion.get());
+ System.out.println("Website: http://brooklyn.incubator.apache.org");
+ System.out.println("Source: https://github.com/apache/incubator-brooklyn");
+ System.out.println();
+ System.out.println("Copyright 2011-2014 The Apache Software Foundation.");
+ System.out.println("Licensed under the Apache 2.0 License");
+ System.out.println();
--- End diff --
Do we need to print all this info?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#discussion_r15986103
--- Diff: usage/rest-server/src/main/java/brooklyn/rest/security/PasswordHasher.java ---
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+package brooklyn.rest.security;
+
+import com.google.common.base.Charsets;
+import com.google.common.hash.HashCode;
+import com.google.common.hash.Hashing;
+
+public class PasswordHasher {
--- End diff --
Could consider including the MD5 part of `Jboss7SshDriver.hashPassword` here too.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#discussion_r15993881
--- Diff: usage/cli/src/main/java/brooklyn/cli/Main.java ---
@@ -200,6 +205,76 @@ public Void call() throws Exception {
}
}
+ @Command(name = "generate-password", description = "Generates a hashed web-console password")
+ public static class GeneratePasswordCommand extends BrooklynCommandCollectingArgs {
+
+ @Option(name = { "--user" }, title = "username", required = true)
+ public String user;
+
+ @Option(name = { "--stdin" }, title = "read password from stdin, instead of console",
+ description = "Before using stdin, read http://stackoverflow.com/a/715681/1393883 for discussion of security!")
+ public boolean useStdin;
+
+ @Override
+ public Void call() throws Exception {
+ checkCanReadPassword();
+
+ System.out.print("Enter password: ");
+ System.out.flush();
+ String password = readPassword();
+ if (Strings.isBlank(password)) {
+ throw new UserFacingException("Password must not be blank; aborting");
+ }
+
+ System.out.print("Re-enter password: ");
+ System.out.flush();
+ String password2 = readPassword();
+ if (!password.equals(password2)) {
+ throw new UserFacingException("Passwords did not match; aborting");
+ }
+
+ String salt = Identifiers.makeRandomId(4);
+ String sha256password = PasswordHasher.sha256(salt, new String(password));
+
+ System.out.println();
+ System.out.println("Please add the following to your brooklyn.properies:");
--- End diff --
Typo: properies
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#discussion_r15986050
--- Diff: usage/cli/src/main/java/brooklyn/cli/Main.java ---
@@ -200,6 +203,57 @@ public Void call() throws Exception {
}
}
+ @Command(name = "generate-password", description = "Generates a hashed web-console password")
+ public static class GeneratePasswordCommand extends BrooklynCommandCollectingArgs {
+
+ @Option(name = { "--user" }, title = "username", required = true)
+ public String user;
+
+ @Override
+ public Void call() throws Exception {
+ System.out.println(BANNER);
+ System.out.println("Version: " + BrooklynVersion.get());
+ System.out.println("Website: http://brooklyn.incubator.apache.org");
+ System.out.println("Source: https://github.com/apache/incubator-brooklyn");
+ System.out.println();
+ System.out.println("Copyright 2011-2014 The Apache Software Foundation.");
+ System.out.println("Licensed under the Apache 2.0 License");
+ System.out.println();
+
+ Console console = System.console();
+ if (console == null) {
+ System.err.println("No console; cannot get password securely from standard input; aborting");
--- End diff --
Missing return.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-brooklyn pull request: BROOKLYN-15: support sha256 passw...
Posted by sjcorbett <gi...@git.apache.org>.
Github user sjcorbett commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/112#discussion_r15993884
--- Diff: docs/use/guide/management/index.md ---
@@ -175,11 +175,33 @@ This configuration could look like:
{% highlight properties %}
brooklyn.webconsole.security.users=admin
-brooklyn.webconsole.security.user.admin.password=password
+brooklyn.webconsole.security.user.admin.salt=OHDf
+brooklyn.webconsole.security.user.admin.sha256=91e16f94509fa8e3dd21c43d69cadfd7da6e7384051b18f168390fe378bb36f9
{% endhighlight %}
The `users` line should contain a comma-separated list. The special value `*` is accepted to permit all users.
+To generate this, the brooklyn CLI can be used:
+{% highlight bash %}
+brooklyn generate-password --user admin
+
+Enter password:
+Re-enter password:
+
+Please enter the following into your brooklyn.properies:
--- End diff --
Message doesn't match real output.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---