diff --git a/auth/password_authenticator.cc b/auth/password_authenticator.cc index 48b93a9bae..ba939c838a 100644 --- a/auth/password_authenticator.cc +++ b/auth/password_authenticator.cc @@ -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 { diff --git a/auth/password_authenticator.hh b/auth/password_authenticator.hh index 4bd6c2e279..4a605116c4 100644 --- a/auth/password_authenticator.hh +++ b/auth/password_authenticator.hh @@ -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; diff --git a/auth/service.cc b/auth/service.cc index 9ca1c7b49c..5392983795 100644 --- a/auth/service.cc +++ b/auth/service.cc @@ -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())); } } diff --git a/test/boost/auth_test.cc b/test/boost/auth_test.cc index 7014b3156e..3b196d88d3 100644 --- a/test/boost/auth_test.cc +++ b/test/boost/auth_test.cc @@ -55,12 +55,12 @@ SEASTAR_TEST_CASE(test_default_authenticator) { SEASTAR_TEST_CASE(test_password_authenticator_attributes) { auto cfg = make_shared(); - 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 fut) { SEASTAR_TEST_CASE(test_password_authenticator_operations) { auto cfg = make_shared(); - cfg->authenticator(auth::password_authenticator_name()); + cfg->authenticator(sstring(auth::password_authenticator_name)); /** * Not using seastar::async due to apparent ASan bug.