Rename use_auth to use_perms

This commit is contained in:
Vitaliy Filippov
2026-07-05 14:58:24 +03:00
parent 5382f1c7bb
commit aa71a1968f
10 changed files with 22 additions and 22 deletions
+2 -2
View File
@@ -78,8 +78,8 @@ class AntiEtcdAdapter
delete antietcd_config.cluster;
delete antietcd_config.cluster_key;
}
const use_auth = config.use_auth || config.use_auth == null && config.client_ca;
if (use_auth)
const use_perms = config.use_perms || config.use_perms == null && config.client_ca;
if (use_perms)
{
antietcd_config.client_cert_auth = true;
antietcd_config.auth_filter = vitastor_auth_filter;
+1 -1
View File
@@ -265,7 +265,7 @@ static const char* help_text =
" --bind_address ADDR Specify server IP address or addresses, separated by space. Default is 127.0.0.1.\n"
" --port 8080 Specify server port.\n"
" --server_cert FILE Path to server TLS certificate file (PEM format).\n"
" --server_key FILE Path to server TLS private key file.\n"
" --server_pkey FILE Path to server TLS private key file.\n"
" --client_ca FILE Path to file with TLS CA certificates used to validate client connections.\n"
"\n"
"Use vitastor-cli --help <command> for command details or vitastor-cli --help --all for all details.\n"
+10 -10
View File
@@ -76,7 +76,7 @@ struct cli_serve_t
int port = 0;
int listen_backlog = 0;
bool ssl = false;
bool use_auth = false;
bool use_perms = false;
std::vector<int> listen_fds;
http_context_t *http_ctx = NULL;
std::set<cli_serve_conn_t*> connections;
@@ -115,8 +115,8 @@ struct cli_serve_t
{
std::string tls_cert = (parent->cli->config.find("server_cert") != parent->cli->config.end()
? parent->cli->config["server_cert"].string_value() : "");
std::string tls_key = (parent->cli->config.find("server_key") != parent->cli->config.end()
? parent->cli->config["server_key"].string_value() : "");
std::string tls_key = (parent->cli->config.find("server_pkey") != parent->cli->config.end()
? parent->cli->config["server_pkey"].string_value() : "");
std::string tls_ca = (parent->cli->config.find("client_ca") != parent->cli->config.end()
? parent->cli->config["client_ca"].string_value() : "");
if (tls_cert != "" || tls_key != "" || tls_ca != "")
@@ -124,14 +124,14 @@ struct cli_serve_t
ssl = true;
if (tls_cert == "" || tls_key == "")
{
result = (cli_result_t){ .err = EINVAL, .text = "server_cert and server_key are required to serve HTTPS" };
result = (cli_result_t){ .err = EINVAL, .text = "server_cert and server_pkey are required to serve HTTPS" };
state = 100;
return;
}
// use_auth is enabled by default when client_ca is set
use_auth = (parent->cli->config["use_auth"].is_null()
// use_perms is enabled by default when client_ca is set
use_perms = (parent->cli->config["use_perms"].is_null()
? (tls_ca != "")
: json_is_true(parent->cli->config["use_auth"]));
: json_is_true(parent->cli->config["use_perms"]));
std::string error;
http_ctx = http_context_init(parent->epmgr->tfd, tls_cert, tls_key, tls_ca, tls_ca != "", error);
if (error != "")
@@ -360,7 +360,7 @@ struct cli_serve_t
conn->request_path = std::move(req_line[1]);
conn->request_body = std::move(msg->body);
conn->response_type = "";
if (use_auth)
if (use_perms)
{
conn->p->user = parent->cli->st_cli->get_user(msg->headers["_tls_common_name"]);
}
@@ -391,7 +391,7 @@ struct cli_serve_t
{
conn->response_type = "application/json";
conn->result = { .text = openapi_description };
if (use_auth)
if (use_perms)
{
// Filter available paths by privileges
if (conn->p->user->type == user_type_t::CLIENT)
@@ -426,7 +426,7 @@ struct cli_serve_t
{
conn->result = { .err = ENOSYS, .text = "method /"+uri[0]+" only allows POST requests" };
}
else if (use_auth && conn->p->user->type == user_type_t::CLIENT && !cmd_it->second.allow_client)
else if (use_perms && conn->p->user->type == user_type_t::CLIENT && !cmd_it->second.allow_client)
{
conn->result = { .err = EACCES, .text = "Access denied" };
}
+3 -3
View File
@@ -191,10 +191,10 @@ void osd_t::parse_config(bool init)
msgr.parse_config(config, init);
if (init)
{
// use_auth is enabled by default when encryption is enabled
use_auth = (config["use_auth"].is_null()
// use_perms is enabled by default when encryption is enabled
use_perms = (config["use_perms"].is_null()
? msgr.is_encryption_enabled()
: json_is_true(config["use_auth"]));
: json_is_true(config["use_perms"]));
// Vital Blockstore parameters
bs_block_size = config["block_size"].uint64_value();
if (!bs_block_size)
+1 -1
View File
@@ -161,7 +161,7 @@ class osd_t
std::unique_ptr<etcd_state_client_t> st_cli;
std::function<blockstore_i*(blockstore_config_t & config)> bs_factory;
osd_messenger_t msgr;
bool use_auth = false;
bool use_perms = false;
int etcd_failed_attempts = 0;
std::string etcd_lease_id;
json11::Json self_state;
+1 -1
View File
@@ -71,7 +71,7 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
finish_op(cur_op, -EINVAL);
return false;
}
if (use_auth && cur_op->client_id != SELF_CLIENT)
if (use_perms && cur_op->client_id != SELF_CLIENT)
{
osd_client_t *cl = msgr.clients.at(cur_op->client_id);
if (cl->hs_result.peer_is_osd)
+1 -1
View File
@@ -91,7 +91,7 @@ static void scan_lists(std::vector<unclean_list_t> & lists, uint64_t limit, desc
// Describe unclean objects
void osd_t::continue_primary_describe(osd_op_t *cur_op)
{
if (use_auth)
if (use_perms)
{
osd_client_t *cl = msgr.clients.at(cur_op->client_id);
if (cl->hs_result.peer_is_osd)
+1 -1
View File
@@ -8,7 +8,7 @@ void osd_t::continue_primary_sync(osd_op_t *cur_op)
{
if (!cur_op->op_data)
{
if (use_auth && cur_op->client_id != SELF_CLIENT)
if (use_perms && cur_op->client_id != SELF_CLIENT)
{
osd_client_t *cl = msgr.clients.at(cur_op->client_id);
if (cl->hs_result.peer_is_osd)
+1 -1
View File
@@ -115,7 +115,7 @@ bool osd_t::sec_check_pg_lock(osd_num_t primary_osd, const object_id &oid, uint3
void osd_t::exec_secondary_real(osd_op_t *cur_op)
{
osd_client_t *cl = msgr.clients.at(cur_op->client_id);
if (use_auth && !cl->hs_result.peer_is_osd)
if (use_perms && !cl->hs_result.peer_is_osd)
{
// Non-OSDs are not allowed to execute "secondary" operations except LIST
bool allowed = false;
+1 -1
View File
@@ -144,7 +144,7 @@ if [[ "$OSD_TLS" = "1" ]]; then
VITASTOR_CFG="$VITASTOR_CFG"',"client_ca":"'$(pwd)'/testdata/client_ca.crt"'
VITASTOR_CFG="$VITASTOR_CFG"',"cert":"'$(pwd)'/testdata/cli.crt"'
VITASTOR_CFG="$VITASTOR_CFG"',"pkey":"'$(pwd)'/testdata/cli.key"'
VITASTOR_CFG="$VITASTOR_CFG"',"use_auth":false'
VITASTOR_CFG="$VITASTOR_CFG"',"use_perms":false'
fi
echo "{$VITASTOR_CFG}" > ./testdata/vitastor.conf
VITASTOR_CFG=./testdata/vitastor.conf