diff options
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/auth/login/src/login.c | 51 | ||||
-rw-r--r-- | xlators/protocol/server/src/authenticate.h | 4 | ||||
-rw-r--r-- | xlators/protocol/server/src/server-handshake.c | 2 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.c | 18 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.h | 2 |
5 files changed, 66 insertions, 11 deletions
diff --git a/xlators/protocol/auth/login/src/login.c b/xlators/protocol/auth/login/src/login.c index 9ee8a0c7a7b..0403858d98f 100644 --- a/xlators/protocol/auth/login/src/login.c +++ b/xlators/protocol/auth/login/src/login.c @@ -11,6 +11,16 @@ #include <fnmatch.h> #include "authenticate.h" +/* Note on strict_auth + * - Strict auth kicks in when authentication is using the username, password + * in the volfile to login + * - If enabled, auth is rejected if the username and password is not matched + * or is not present + * - When using SSL names, this is automatically strict, and allows only those + * names that are present in the allow list, IOW strict auth checking has no + * implication when using SSL names +*/ + auth_result_t gf_auth (dict_t *input_params, dict_t *config_params) { auth_result_t result = AUTH_DONT_CARE; @@ -27,6 +37,7 @@ auth_result_t gf_auth (dict_t *input_params, dict_t *config_params) char *tmp = NULL; char *username_cpy = NULL; gf_boolean_t using_ssl = _gf_false; + gf_boolean_t strict_auth = _gf_false; username_data = dict_get (input_params, "ssl-name"); if (username_data) { @@ -35,16 +46,39 @@ auth_result_t gf_auth (dict_t *input_params, dict_t *config_params) using_ssl = _gf_true; } else { + ret = dict_get_str_boolean (config_params, "strict-auth-accept", + _gf_false); + if (ret == -1) + strict_auth = _gf_false; + else + strict_auth = ret; + username_data = dict_get (input_params, "username"); if (!username_data) { - gf_log ("auth/login", GF_LOG_DEBUG, - "username not found, returning DONT-CARE"); + if (strict_auth) { + gf_log ("auth/login", GF_LOG_DEBUG, + "username not found, strict auth" + " configured returning REJECT"); + result = AUTH_REJECT; + } else { + gf_log ("auth/login", GF_LOG_DEBUG, + "username not found, returning" + " DONT-CARE"); + } goto out; } password_data = dict_get (input_params, "password"); if (!password_data) { - gf_log ("auth/login", GF_LOG_WARNING, - "password not found, returning DONT-CARE"); + if (strict_auth) { + gf_log ("auth/login", GF_LOG_DEBUG, + "password not found, strict auth" + " configured returning REJECT"); + result = AUTH_REJECT; + } else { + gf_log ("auth/login", GF_LOG_WARNING, + "password not found, returning" + " DONT-CARE"); + } goto out; } password = data_to_str (password_data); @@ -62,9 +96,10 @@ auth_result_t gf_auth (dict_t *input_params, dict_t *config_params) ret = gf_asprintf (&searchstr, "auth.login.%s.%s", brick_name, using_ssl ? "ssl-allow" : "allow"); if (-1 == ret) { - gf_log ("auth/login", GF_LOG_WARNING, + gf_log ("auth/login", GF_LOG_ERROR, "asprintf failed while setting search string, " - "returning DONT-CARE"); + "returning REJECT"); + result = AUTH_REJECT; goto out; } @@ -92,8 +127,10 @@ auth_result_t gf_auth (dict_t *input_params, dict_t *config_params) * ssl-allow=* case as well) authorization is effectively * disabled, though authentication and encryption are still * active. + * + * Read NOTE on strict_auth above. */ - if (using_ssl) { + if (using_ssl || strict_auth) { result = AUTH_REJECT; } username_cpy = gf_strdup (allow_user->data); diff --git a/xlators/protocol/server/src/authenticate.h b/xlators/protocol/server/src/authenticate.h index 3f80231ee0a..5f92183fb12 100644 --- a/xlators/protocol/server/src/authenticate.h +++ b/xlators/protocol/server/src/authenticate.h @@ -37,10 +37,8 @@ typedef struct { volume_opt_list_t *vol_opt; } auth_handle_t; -auth_result_t gf_authenticate (dict_t *input_params, - dict_t *config_params, - dict_t *auth_modules); int32_t gf_auth_init (xlator_t *xl, dict_t *auth_modules); void gf_auth_fini (dict_t *auth_modules); +auth_result_t gf_authenticate (dict_t *, dict_t *, dict_t *); #endif /* _AUTHENTICATE_H */ diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index 08f76de9748..af63a0f15d9 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -716,7 +716,7 @@ server_setvolume (rpcsvc_request_t *req) ret = dict_get_str (params, "volfile-key", &volfile_key); if (ret) - gf_msg_debug (this->name, 0, "failed to set " + gf_msg_debug (this->name, 0, "failed to get " "'volfile-key'"); ret = _validate_volfile_checksum (this, volfile_key, diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 87a03d23c3f..254a5ca6c62 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -798,6 +798,10 @@ do_rpc: goto out; } + GF_OPTION_RECONF ("strict-auth-accept", conf->strict_auth_enabled, + options, bool, out); + + GF_OPTION_RECONF ("dynamic-auth", conf->dync_auth, options, bool, out); @@ -1062,6 +1066,14 @@ server_init (xlator_t *this) "Failed to initialize group cache."); goto out; } + + ret = dict_get_str_boolean (this->options, "strict-auth-accept", + _gf_false); + if (ret == -1) + conf->strict_auth_enabled = _gf_false; + else + conf->strict_auth_enabled = ret; + ret = dict_get_str_boolean (this->options, "dynamic-auth", _gf_true); if (ret == -1) @@ -1793,6 +1805,12 @@ struct volume_options server_options[] = { .op_version = {GD_OP_VERSION_3_7_5}, .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC }, + { .key = {"strict-auth-accept"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .description = "strict-auth-accept reject connection with out" + "a valid username and password." + }, { .key = {NULL} }, }; diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h index ea1fbf92919..88aaa263018 100644 --- a/xlators/protocol/server/src/server.h +++ b/xlators/protocol/server/src/server.h @@ -24,6 +24,7 @@ #include "client_t.h" #include "gidcache.h" #include "defaults.h" +#include "authenticate.h" #define DEFAULT_BLOCK_SIZE 4194304 /* 4MB */ #define DEFAULT_VOLUME_FILE_PATH CONFDIR "/glusterfs.vol" @@ -128,6 +129,7 @@ struct server_conf { * tweeked */ struct _child_status *child_status; gf_lock_t itable_lock; + gf_boolean_t strict_auth_enabled; }; typedef struct server_conf server_conf_t; |