auth: Turn password_authenticator_name into a std::string_view variable

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
This commit is contained in:
Rafael Ávila de Espíndola
2020-02-26 13:50:45 -08:00
parent e526ed369b
commit 27c2b3de30
4 changed files with 8 additions and 11 deletions

View File

@@ -62,10 +62,7 @@
namespace auth {
const sstring& password_authenticator_name() {
static const sstring name = make_sstring(meta::AUTH_PACKAGE_NAME, "PasswordAuthenticator");
return name;
}
constexpr std::string_view password_authenticator_name("org.apache.cassandra.auth.PasswordAuthenticator");
// name of the hash column.
static const sstring SALTED_HASH = "salted_hash";
@@ -198,7 +195,7 @@ db::consistency_level password_authenticator::consistency_for_user(std::string_v
}
std::string_view password_authenticator::qualified_java_name() const {
return password_authenticator_name();
return password_authenticator_name;
}
bool password_authenticator::require_authentication() const {

View File

@@ -52,7 +52,7 @@ class migration_manager;
namespace auth {
const sstring& password_authenticator_name();
extern const std::string_view password_authenticator_name;
class password_authenticator : public authenticator {
cql3::query_processor& _qp;

View File

@@ -129,11 +129,11 @@ service::service(
// The password authenticator requires that the `standard_role_manager` is running so that the roles metadata table
// it manages is created and updated. This cross-module dependency is rather gross, but we have to maintain it for
// the sake of compatibility with Apache Cassandra and its choice of auth. schema.
if ((_authenticator->qualified_java_name() == password_authenticator_name())
if ((_authenticator->qualified_java_name() == password_authenticator_name)
&& (_role_manager->qualified_java_name() != standard_role_manager_name())) {
throw incompatible_module_combination(
format("The {} authenticator must be loaded alongside the {} role-manager.",
password_authenticator_name(),
password_authenticator_name,
standard_role_manager_name()));
}
}

View File

@@ -55,12 +55,12 @@ SEASTAR_TEST_CASE(test_default_authenticator) {
SEASTAR_TEST_CASE(test_password_authenticator_attributes) {
auto cfg = make_shared<db::config>();
cfg->authenticator(auth::password_authenticator_name());
cfg->authenticator(sstring(auth::password_authenticator_name));
return do_with_cql_env([](cql_test_env& env) {
auto& a = env.local_auth_service().underlying_authenticator();
BOOST_REQUIRE(a.require_authentication());
BOOST_REQUIRE_EQUAL(a.qualified_java_name(), auth::password_authenticator_name());
BOOST_REQUIRE_EQUAL(a.qualified_java_name(), auth::password_authenticator_name);
return make_ready_future();
}, cfg);
}
@@ -96,7 +96,7 @@ future<> require_throws(seastar::future<Args...> fut) {
SEASTAR_TEST_CASE(test_password_authenticator_operations) {
auto cfg = make_shared<db::config>();
cfg->authenticator(auth::password_authenticator_name());
cfg->authenticator(sstring(auth::password_authenticator_name));
/**
* Not using seastar::async due to apparent ASan bug.