auth: Convert sstring variables in common.hh to constexpr std::string_view

This converts the following variables:
DEFAULT_SUPERUSER_NAME AUTH_KS USERS_CF AUTH_PACKAGE_NAME

Since they are now constexpr they will not be part of any
initialization order problems.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
This commit is contained in:
Rafael Ávila de Espíndola
2020-02-26 09:14:11 -08:00
parent 53ed39e64a
commit 400212e81f
9 changed files with 18 additions and 18 deletions

View File

@@ -27,7 +27,7 @@
namespace auth {
const sstring& allow_all_authenticator_name() {
static const sstring name = meta::AUTH_PACKAGE_NAME + "AllowAllAuthenticator";
static const sstring name = make_sstring(meta::AUTH_PACKAGE_NAME, "AllowAllAuthenticator");
return name;
}

View File

@@ -27,7 +27,7 @@
namespace auth {
const sstring& allow_all_authorizer_name() {
static const sstring name = meta::AUTH_PACKAGE_NAME + "AllowAllAuthorizer";
static const sstring name = make_sstring(meta::AUTH_PACKAGE_NAME, "AllowAllAuthorizer");
return name;
}

View File

@@ -34,10 +34,10 @@ namespace auth {
namespace meta {
const sstring DEFAULT_SUPERUSER_NAME("cassandra");
const sstring AUTH_KS("system_auth");
const sstring USERS_CF("users");
const sstring AUTH_PACKAGE_NAME("org.apache.cassandra.auth.");
constexpr std::string_view DEFAULT_SUPERUSER_NAME("cassandra");
constexpr std::string_view AUTH_KS("system_auth");
constexpr std::string_view USERS_CF("users");
constexpr std::string_view AUTH_PACKAGE_NAME("org.apache.cassandra.auth.");
}

View File

@@ -53,10 +53,10 @@ namespace auth {
namespace meta {
extern const sstring DEFAULT_SUPERUSER_NAME;
extern const sstring AUTH_KS;
extern const sstring USERS_CF;
extern const sstring AUTH_PACKAGE_NAME;
extern const std::string_view DEFAULT_SUPERUSER_NAME;
extern const std::string_view AUTH_KS;
extern const std::string_view USERS_CF;
extern const std::string_view AUTH_PACKAGE_NAME;
}

View File

@@ -66,7 +66,7 @@ extern "C" {
namespace auth {
const sstring& default_authorizer_name() {
static const sstring name = meta::AUTH_PACKAGE_NAME + "CassandraAuthorizer";
static const sstring name = make_sstring(meta::AUTH_PACKAGE_NAME, "CassandraAuthorizer");
return name;
}

View File

@@ -63,14 +63,14 @@
namespace auth {
const sstring& password_authenticator_name() {
static const sstring name = meta::AUTH_PACKAGE_NAME + "PasswordAuthenticator";
static const sstring name = make_sstring(meta::AUTH_PACKAGE_NAME, "PasswordAuthenticator");
return name;
}
// name of the hash column.
static const sstring SALTED_HASH = "salted_hash";
static const sstring DEFAULT_USER_NAME = meta::DEFAULT_SUPERUSER_NAME;
static const sstring DEFAULT_USER_PASSWORD = meta::DEFAULT_SUPERUSER_NAME;
static const sstring DEFAULT_USER_NAME = sstring(meta::DEFAULT_SUPERUSER_NAME);
static const sstring DEFAULT_USER_PASSWORD = sstring(meta::DEFAULT_SUPERUSER_NAME);
static logging::logger plogger("password_authenticator");

View File

@@ -52,7 +52,7 @@ std::string_view creation_query() {
}
std::string_view qualified_name() noexcept {
static const sstring instance = AUTH_KS + "." + sstring(name);
static const sstring instance = make_sstring(meta::AUTH_KS, ".", name);
return instance;
}

View File

@@ -51,7 +51,7 @@ namespace role_members_table {
constexpr std::string_view name{"role_members" , 12};
static std::string_view qualified_name() noexcept {
static const sstring instance = AUTH_KS + "." + sstring(name);
static const sstring instance = make_sstring(meta::AUTH_KS, ".", name);
return instance;
}
@@ -125,7 +125,7 @@ static bool has_can_login(const cql3::untyped_result_set_row& row) {
}
std::string_view standard_role_manager_name() noexcept {
static const sstring instance = meta::AUTH_PACKAGE_NAME + "CassandraRoleManager";
static const sstring instance = make_sstring(meta::AUTH_PACKAGE_NAME, "CassandraRoleManager");
return instance;
}

View File

@@ -65,7 +65,7 @@ static const std::unordered_set<sstring> internal_keyspaces = {
db::system_distributed_keyspace::NAME,
db::system_keyspace::NAME,
db::schema_tables::NAME,
auth::meta::AUTH_KS,
sstring(auth::meta::AUTH_KS),
tracing::trace_keyspace_helper::KEYSPACE_NAME
};