From 1a11e64f52257eb20407e5c19b9466096583a4ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Wed, 26 Feb 2020 13:45:57 -0800 Subject: [PATCH] auth: Turn allow_all_authorizer_name into a std::string_view variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafael Ávila de Espíndola --- auth/allow_all_authorizer.cc | 5 +---- auth/allow_all_authorizer.hh | 4 ++-- auth/service.cc | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/auth/allow_all_authorizer.cc b/auth/allow_all_authorizer.cc index df1a4b95a1..3fcb1abd1d 100644 --- a/auth/allow_all_authorizer.cc +++ b/auth/allow_all_authorizer.cc @@ -26,10 +26,7 @@ namespace auth { -const sstring& allow_all_authorizer_name() { - static const sstring name = make_sstring(meta::AUTH_PACKAGE_NAME, "AllowAllAuthorizer"); - return name; -} +constexpr std::string_view allow_all_authorizer_name("org.apache.cassandra.auth.AllowAllAuthorizer"); // To ensure correct initialization order, we unfortunately need to use a string literal. static const class_registrator< diff --git a/auth/allow_all_authorizer.hh b/auth/allow_all_authorizer.hh index 67de9d287f..718fe4faf5 100644 --- a/auth/allow_all_authorizer.hh +++ b/auth/allow_all_authorizer.hh @@ -34,7 +34,7 @@ class migration_manager; namespace auth { -const sstring& allow_all_authorizer_name(); +extern const std::string_view allow_all_authorizer_name; class allow_all_authorizer final : public authorizer { public: @@ -50,7 +50,7 @@ public: } virtual std::string_view qualified_java_name() const override { - return allow_all_authorizer_name(); + return allow_all_authorizer_name; } virtual future authorize(const role_or_anonymous&, const resource&) const override { diff --git a/auth/service.cc b/auth/service.cc index 66e617844d..9ca1c7b49c 100644 --- a/auth/service.cc +++ b/auth/service.cc @@ -376,7 +376,7 @@ future get_permissions(const service& ser, const authenticated_u } bool is_enforcing(const service& ser) { - const bool enforcing_authorizer = ser.underlying_authorizer().qualified_java_name() != allow_all_authorizer_name(); + const bool enforcing_authorizer = ser.underlying_authorizer().qualified_java_name() != allow_all_authorizer_name; const bool enforcing_authenticator = ser.underlying_authenticator().qualified_java_name() != allow_all_authenticator_name;