|
|
d1681e |
From bceb9586b96cbf3e0f1747affa6f56cfe29ac140 Mon Sep 17 00:00:00 2001
|
|
|
d1681e |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
d1681e |
Date: Mon, 2 Apr 2018 12:20:47 +0530
|
|
|
d1681e |
Subject: [PATCH 241/260] server/auth: add option for strict authentication
|
|
|
d1681e |
|
|
|
d1681e |
When this option is enabled, we will check for a matching
|
|
|
d1681e |
username and password, if not found then the connection will
|
|
|
d1681e |
be rejected. This also does a checksum validation of volfile
|
|
|
d1681e |
|
|
|
d1681e |
The option is invalid when SSL/TLS is in use, at which point
|
|
|
d1681e |
the SSL/TLS certificate user name is used to validate and
|
|
|
d1681e |
hence authorize the right user. This expects TLS allow rules
|
|
|
d1681e |
to be setup correctly rather than the default *.
|
|
|
d1681e |
|
|
|
d1681e |
This option is not settable, as a result this cannot be enabled
|
|
|
d1681e |
for volumes using the CLI. This is used with the shared storage
|
|
|
d1681e |
volume, to restrict access to the same in non-SSL/TLS environments
|
|
|
d1681e |
to the gluster peers only.
|
|
|
d1681e |
|
|
|
d1681e |
Tested:
|
|
|
d1681e |
./tests/bugs/protocol/bug-1321578.t
|
|
|
d1681e |
./tests/features/ssl-authz.t
|
|
|
d1681e |
- Ran tests on volumes with and without strict auth
|
|
|
d1681e |
checking (as brick vol file needed to be edited to test,
|
|
|
d1681e |
or rather to enable the option)
|
|
|
d1681e |
- Ran tests on volumes to ensure existing mounts are
|
|
|
d1681e |
disconnected when we enable strict checking
|
|
|
d1681e |
|
|
|
d1681e |
backport of upstream https://review.gluster.org/#/c/19921/
|
|
|
d1681e |
|
|
|
d1681e |
>Change-Id: I2ac4f0cfa5b59cc789cc5a265358389b04556b59
|
|
|
d1681e |
>fixes: bz#1570432
|
|
|
d1681e |
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
d1681e |
>Signed-off-by: ShyamsundarR <srangana@redhat.com>
|
|
|
d1681e |
|
|
|
d1681e |
Change-Id: I7fd3194b91ba22d57b851a2a042ff16b9a616a5a
|
|
|
d1681e |
BUG: 1568969
|
|
|
d1681e |
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
d1681e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/136709
|
|
|
d1681e |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
d1681e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
d1681e |
---
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-volgen.c | 16 +++++++-
|
|
|
d1681e |
xlators/protocol/auth/login/src/login.c | 51 ++++++++++++++++++++++----
|
|
|
d1681e |
xlators/protocol/server/src/authenticate.h | 4 +-
|
|
|
d1681e |
xlators/protocol/server/src/server-handshake.c | 2 +-
|
|
|
d1681e |
xlators/protocol/server/src/server.c | 18 +++++++++
|
|
|
d1681e |
xlators/protocol/server/src/server.h | 2 +
|
|
|
d1681e |
6 files changed, 81 insertions(+), 12 deletions(-)
|
|
|
d1681e |
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
|
|
|
d1681e |
index 1c43f24..3926bd3 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
|
|
|
d1681e |
@@ -2341,6 +2341,7 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
|
|
|
d1681e |
char *password = NULL;
|
|
|
d1681e |
char key[1024] = {0};
|
|
|
d1681e |
char *ssl_user = NULL;
|
|
|
d1681e |
+ char *volname = NULL;
|
|
|
d1681e |
char *address_family_data = NULL;
|
|
|
d1681e |
|
|
|
d1681e |
if (!graph || !volinfo || !set_dict || !brickinfo)
|
|
|
d1681e |
@@ -2416,6 +2417,19 @@ brick_graph_add_server (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
|
|
|
d1681e |
if (ret)
|
|
|
d1681e |
return -1;
|
|
|
d1681e |
|
|
|
d1681e |
+ volname = volinfo->is_snap_volume ?
|
|
|
d1681e |
+ volinfo->parent_volname : volinfo->volname;
|
|
|
d1681e |
+
|
|
|
d1681e |
+
|
|
|
d1681e |
+ if (volname && !strcmp (volname, GLUSTER_SHARED_STORAGE)) {
|
|
|
d1681e |
+ memset (key, 0, sizeof (key));
|
|
|
d1681e |
+ snprintf (key, sizeof (key), "strict-auth-accept");
|
|
|
d1681e |
+
|
|
|
d1681e |
+ ret = xlator_set_option (xl, key, "true");
|
|
|
d1681e |
+ if (ret)
|
|
|
d1681e |
+ return -1;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+
|
|
|
d1681e |
if (dict_get_str (volinfo->dict, "auth.ssl-allow", &ssl_user) == 0) {
|
|
|
d1681e |
memset (key, 0, sizeof (key));
|
|
|
d1681e |
snprintf (key, sizeof (key), "auth.login.%s.ssl-allow",
|
|
|
d1681e |
@@ -5841,7 +5855,7 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo,
|
|
|
d1681e |
|
|
|
d1681e |
|
|
|
d1681e |
if (volname && !strcmp (volname, GLUSTER_SHARED_STORAGE) &&
|
|
|
d1681e |
- client_type != GF_CLIENT_TRUSTED) {
|
|
|
d1681e |
+ client_type != GF_CLIENT_TRUSTED) {
|
|
|
d1681e |
/*
|
|
|
d1681e |
* shared storage volume cannot be mounted from non trusted
|
|
|
d1681e |
* nodes. So we are not creating volfiles for non-trusted
|
|
|
d1681e |
diff --git a/xlators/protocol/auth/login/src/login.c b/xlators/protocol/auth/login/src/login.c
|
|
|
d1681e |
index e799dd2..da10d0b 100644
|
|
|
d1681e |
--- a/xlators/protocol/auth/login/src/login.c
|
|
|
d1681e |
+++ b/xlators/protocol/auth/login/src/login.c
|
|
|
d1681e |
@@ -11,6 +11,16 @@
|
|
|
d1681e |
#include <fnmatch.h>
|
|
|
d1681e |
#include "authenticate.h"
|
|
|
d1681e |
|
|
|
d1681e |
+/* Note on strict_auth
|
|
|
d1681e |
+ * - Strict auth kicks in when authentication is using the username, password
|
|
|
d1681e |
+ * in the volfile to login
|
|
|
d1681e |
+ * - If enabled, auth is rejected if the username and password is not matched
|
|
|
d1681e |
+ * or is not present
|
|
|
d1681e |
+ * - When using SSL names, this is automatically strict, and allows only those
|
|
|
d1681e |
+ * names that are present in the allow list, IOW strict auth checking has no
|
|
|
d1681e |
+ * implication when using SSL names
|
|
|
d1681e |
+*/
|
|
|
d1681e |
+
|
|
|
d1681e |
auth_result_t gf_auth (dict_t *input_params, dict_t *config_params)
|
|
|
d1681e |
{
|
|
|
d1681e |
auth_result_t result = AUTH_DONT_CARE;
|
|
|
d1681e |
@@ -27,6 +37,7 @@ auth_result_t gf_auth (dict_t *input_params, dict_t *config_params)
|
|
|
d1681e |
char *tmp = NULL;
|
|
|
d1681e |
char *username_cpy = NULL;
|
|
|
d1681e |
gf_boolean_t using_ssl = _gf_false;
|
|
|
d1681e |
+ gf_boolean_t strict_auth = _gf_false;
|
|
|
d1681e |
|
|
|
d1681e |
username_data = dict_get (input_params, "ssl-name");
|
|
|
d1681e |
if (username_data) {
|
|
|
d1681e |
@@ -35,16 +46,39 @@ auth_result_t gf_auth (dict_t *input_params, dict_t *config_params)
|
|
|
d1681e |
using_ssl = _gf_true;
|
|
|
d1681e |
}
|
|
|
d1681e |
else {
|
|
|
d1681e |
+ ret = dict_get_str_boolean (config_params, "strict-auth-accept",
|
|
|
d1681e |
+ _gf_false);
|
|
|
d1681e |
+ if (ret == -1)
|
|
|
d1681e |
+ strict_auth = _gf_false;
|
|
|
d1681e |
+ else
|
|
|
d1681e |
+ strict_auth = ret;
|
|
|
d1681e |
+
|
|
|
d1681e |
username_data = dict_get (input_params, "username");
|
|
|
d1681e |
if (!username_data) {
|
|
|
d1681e |
- gf_log ("auth/login", GF_LOG_DEBUG,
|
|
|
d1681e |
- "username not found, returning DONT-CARE");
|
|
|
d1681e |
+ if (strict_auth) {
|
|
|
d1681e |
+ gf_log ("auth/login", GF_LOG_DEBUG,
|
|
|
d1681e |
+ "username not found, strict auth"
|
|
|
d1681e |
+ " configured returning REJECT");
|
|
|
d1681e |
+ result = AUTH_REJECT;
|
|
|
d1681e |
+ } else {
|
|
|
d1681e |
+ gf_log ("auth/login", GF_LOG_DEBUG,
|
|
|
d1681e |
+ "username not found, returning"
|
|
|
d1681e |
+ " DONT-CARE");
|
|
|
d1681e |
+ }
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
password_data = dict_get (input_params, "password");
|
|
|
d1681e |
if (!password_data) {
|
|
|
d1681e |
- gf_log ("auth/login", GF_LOG_WARNING,
|
|
|
d1681e |
- "password not found, returning DONT-CARE");
|
|
|
d1681e |
+ if (strict_auth) {
|
|
|
d1681e |
+ gf_log ("auth/login", GF_LOG_DEBUG,
|
|
|
d1681e |
+ "password not found, strict auth"
|
|
|
d1681e |
+ " configured returning REJECT");
|
|
|
d1681e |
+ result = AUTH_REJECT;
|
|
|
d1681e |
+ } else {
|
|
|
d1681e |
+ gf_log ("auth/login", GF_LOG_WARNING,
|
|
|
d1681e |
+ "password not found, returning"
|
|
|
d1681e |
+ " DONT-CARE");
|
|
|
d1681e |
+ }
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
password = data_to_str (password_data);
|
|
|
d1681e |
@@ -62,9 +96,10 @@ auth_result_t gf_auth (dict_t *input_params, dict_t *config_params)
|
|
|
d1681e |
ret = gf_asprintf (&searchstr, "auth.login.%s.%s", brick_name,
|
|
|
d1681e |
using_ssl ? "ssl-allow" : "allow");
|
|
|
d1681e |
if (-1 == ret) {
|
|
|
d1681e |
- gf_log ("auth/login", GF_LOG_WARNING,
|
|
|
d1681e |
+ gf_log ("auth/login", GF_LOG_ERROR,
|
|
|
d1681e |
"asprintf failed while setting search string, "
|
|
|
d1681e |
- "returning DONT-CARE");
|
|
|
d1681e |
+ "returning REJECT");
|
|
|
d1681e |
+ result = AUTH_REJECT;
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
@@ -92,8 +127,10 @@ auth_result_t gf_auth (dict_t *input_params, dict_t *config_params)
|
|
|
d1681e |
* ssl-allow=* case as well) authorization is effectively
|
|
|
d1681e |
* disabled, though authentication and encryption are still
|
|
|
d1681e |
* active.
|
|
|
d1681e |
+ *
|
|
|
d1681e |
+ * Read NOTE on strict_auth above.
|
|
|
d1681e |
*/
|
|
|
d1681e |
- if (using_ssl) {
|
|
|
d1681e |
+ if (using_ssl || strict_auth) {
|
|
|
d1681e |
result = AUTH_REJECT;
|
|
|
d1681e |
}
|
|
|
d1681e |
username_cpy = gf_strdup (allow_user->data);
|
|
|
d1681e |
diff --git a/xlators/protocol/server/src/authenticate.h b/xlators/protocol/server/src/authenticate.h
|
|
|
d1681e |
index 3f80231..5f92183 100644
|
|
|
d1681e |
--- a/xlators/protocol/server/src/authenticate.h
|
|
|
d1681e |
+++ b/xlators/protocol/server/src/authenticate.h
|
|
|
d1681e |
@@ -37,10 +37,8 @@ typedef struct {
|
|
|
d1681e |
volume_opt_list_t *vol_opt;
|
|
|
d1681e |
} auth_handle_t;
|
|
|
d1681e |
|
|
|
d1681e |
-auth_result_t gf_authenticate (dict_t *input_params,
|
|
|
d1681e |
- dict_t *config_params,
|
|
|
d1681e |
- dict_t *auth_modules);
|
|
|
d1681e |
int32_t gf_auth_init (xlator_t *xl, dict_t *auth_modules);
|
|
|
d1681e |
void gf_auth_fini (dict_t *auth_modules);
|
|
|
d1681e |
+auth_result_t gf_authenticate (dict_t *, dict_t *, dict_t *);
|
|
|
d1681e |
|
|
|
d1681e |
#endif /* _AUTHENTICATE_H */
|
|
|
d1681e |
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c
|
|
|
d1681e |
index cbc93a3..fc63f2c 100644
|
|
|
d1681e |
--- a/xlators/protocol/server/src/server-handshake.c
|
|
|
d1681e |
+++ b/xlators/protocol/server/src/server-handshake.c
|
|
|
d1681e |
@@ -747,7 +747,7 @@ server_setvolume (rpcsvc_request_t *req)
|
|
|
d1681e |
ret = dict_get_str (params, "volfile-key",
|
|
|
d1681e |
&volfile_key);
|
|
|
d1681e |
if (ret)
|
|
|
d1681e |
- gf_msg_debug (this->name, 0, "failed to set "
|
|
|
d1681e |
+ gf_msg_debug (this->name, 0, "failed to get "
|
|
|
d1681e |
"'volfile-key'");
|
|
|
d1681e |
|
|
|
d1681e |
ret = _validate_volfile_checksum (this, volfile_key,
|
|
|
d1681e |
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
|
|
|
d1681e |
index eed4295..6f20a06 100644
|
|
|
d1681e |
--- a/xlators/protocol/server/src/server.c
|
|
|
d1681e |
+++ b/xlators/protocol/server/src/server.c
|
|
|
d1681e |
@@ -943,6 +943,10 @@ do_rpc:
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
+ GF_OPTION_RECONF ("strict-auth-accept", conf->strict_auth_enabled,
|
|
|
d1681e |
+ options, bool, out);
|
|
|
d1681e |
+
|
|
|
d1681e |
+
|
|
|
d1681e |
GF_OPTION_RECONF ("dynamic-auth", conf->dync_auth, options,
|
|
|
d1681e |
bool, out);
|
|
|
d1681e |
|
|
|
d1681e |
@@ -1183,6 +1187,14 @@ init (xlator_t *this)
|
|
|
d1681e |
"Failed to initialize group cache.");
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
}
|
|
|
d1681e |
+
|
|
|
d1681e |
+ ret = dict_get_str_boolean (this->options, "strict-auth-accept",
|
|
|
d1681e |
+ _gf_false);
|
|
|
d1681e |
+ if (ret == -1)
|
|
|
d1681e |
+ conf->strict_auth_enabled = _gf_false;
|
|
|
d1681e |
+ else
|
|
|
d1681e |
+ conf->strict_auth_enabled = ret;
|
|
|
d1681e |
+
|
|
|
d1681e |
ret = dict_get_str_boolean (this->options, "dynamic-auth",
|
|
|
d1681e |
_gf_true);
|
|
|
d1681e |
if (ret == -1)
|
|
|
d1681e |
@@ -1840,5 +1852,11 @@ struct volume_options options[] = {
|
|
|
d1681e |
"transport connection immediately in response to "
|
|
|
d1681e |
"*.allow | *.reject volume set options."
|
|
|
d1681e |
},
|
|
|
d1681e |
+ { .key = {"strict-auth-accept"},
|
|
|
d1681e |
+ .type = GF_OPTION_TYPE_BOOL,
|
|
|
d1681e |
+ .default_value = "off",
|
|
|
d1681e |
+ .description = "strict-auth-accept reject connection with out"
|
|
|
d1681e |
+ "a valid username and password."
|
|
|
d1681e |
+ },
|
|
|
d1681e |
{ .key = {NULL} },
|
|
|
d1681e |
};
|
|
|
d1681e |
diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h
|
|
|
d1681e |
index af987aa..691c75b 100644
|
|
|
d1681e |
--- a/xlators/protocol/server/src/server.h
|
|
|
d1681e |
+++ b/xlators/protocol/server/src/server.h
|
|
|
d1681e |
@@ -24,6 +24,7 @@
|
|
|
d1681e |
#include "client_t.h"
|
|
|
d1681e |
#include "gidcache.h"
|
|
|
d1681e |
#include "defaults.h"
|
|
|
d1681e |
+#include "authenticate.h"
|
|
|
d1681e |
|
|
|
d1681e |
#define DEFAULT_BLOCK_SIZE 4194304 /* 4MB */
|
|
|
d1681e |
#define DEFAULT_VOLUME_FILE_PATH CONFDIR "/glusterfs.vol"
|
|
|
d1681e |
@@ -109,6 +110,7 @@ struct server_conf {
|
|
|
d1681e |
* tweeked */
|
|
|
d1681e |
struct _child_status *child_status;
|
|
|
d1681e |
gf_lock_t itable_lock;
|
|
|
d1681e |
+ gf_boolean_t strict_auth_enabled;
|
|
|
d1681e |
};
|
|
|
d1681e |
typedef struct server_conf server_conf_t;
|
|
|
d1681e |
|
|
|
d1681e |
--
|
|
|
d1681e |
1.8.3.1
|
|
|
d1681e |
|