diff --git a/auth/allow_all_authenticator.cc b/auth/allow_all_authenticator.cc
new file mode 100644
index 0000000000..c3eae17db3
--- /dev/null
+++ b/auth/allow_all_authenticator.cc
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2017 ScyllaDB
+ */
+
+/*
+ * This file is part of Scylla.
+ *
+ * Scylla is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Scylla is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Scylla. If not, see .
+ */
+
+#include "auth/allow_all_authenticator.hh"
+
+#include "service/migration_manager.hh"
+#include "utils/class_registrator.hh"
+
+namespace auth {
+
+const sstring& allow_all_authenticator_name() {
+ static const sstring name = meta::AUTH_PACKAGE_NAME + "AllowAllAuthenticator";
+ return name;
+}
+
+// To ensure correct initialization order, we unfortunately need to use a string literal.
+static const class_registrator<
+ authenticator,
+ allow_all_authenticator,
+ cql3::query_processor&,
+ ::service::migration_manager&> registration("org.apache.cassandra.auth.AllowAllAuthenticator");
+
+}
diff --git a/auth/allow_all_authenticator.hh b/auth/allow_all_authenticator.hh
new file mode 100644
index 0000000000..e5da1953a0
--- /dev/null
+++ b/auth/allow_all_authenticator.hh
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2017 ScyllaDB
+ */
+
+/*
+ * This file is part of Scylla.
+ *
+ * Scylla is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Scylla is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Scylla. If not, see .
+ */
+
+#pragma once
+
+#include
+
+#include "auth/authenticator.hh"
+#include "auth/authenticated_user.hh"
+#include "auth/common.hh"
+
+namespace cql3 {
+class query_processor;
+}
+
+namespace service {
+class migration_manager;
+}
+
+namespace auth {
+
+const sstring& allow_all_authenticator_name();
+
+class allow_all_authenticator final : public authenticator {
+public:
+ allow_all_authenticator(cql3::query_processor&, ::service::migration_manager&) {
+ }
+
+ future<> start() override {
+ return make_ready_future<>();
+ }
+
+ future<> stop() override {
+ return make_ready_future<>();
+ }
+
+ const sstring& qualified_java_name() const override {
+ return allow_all_authenticator_name();
+ }
+
+ bool require_authentication() const override {
+ return false;
+ }
+
+ option_set supported_options() const override {
+ return option_set();
+ }
+
+ option_set alterable_options() const override {
+ return option_set();
+ }
+
+ future<::shared_ptr> authenticate(const credentials_map& credentials) const override {
+ return make_ready_future<::shared_ptr>(::make_shared());
+ }
+
+ future<> create(sstring username, const option_map& options) override {
+ return make_ready_future();
+ }
+
+ future<> alter(sstring username, const option_map& options) override {
+ return make_ready_future();
+ }
+
+ future<> drop(sstring username) override {
+ return make_ready_future();
+ }
+
+ const resource_ids& protected_resources() const override {
+ static const resource_ids ids;
+ return ids;
+ }
+
+ ::shared_ptr new_sasl_challenge() const override {
+ throw std::runtime_error("Should not reach");
+ }
+};
+
+}
diff --git a/auth/allow_all_authorizer.cc b/auth/allow_all_authorizer.cc
new file mode 100644
index 0000000000..6cd2ef2aa6
--- /dev/null
+++ b/auth/allow_all_authorizer.cc
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2017 ScyllaDB
+ */
+
+/*
+ * This file is part of Scylla.
+ *
+ * Scylla is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Scylla is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Scylla. If not, see .
+ */
+
+#include "auth/allow_all_authorizer.hh"
+
+#include "auth/common.hh"
+#include "utils/class_registrator.hh"
+
+namespace auth {
+
+const sstring& allow_all_authorizer_name() {
+ static const sstring name = meta::AUTH_PACKAGE_NAME + "AllowAllAuthorizer";
+ return name;
+}
+
+// To ensure correct initialization order, we unfortunately need to use a string literal.
+static const class_registrator<
+ authorizer,
+ allow_all_authorizer,
+ cql3::query_processor&,
+ ::service::migration_manager&> registration("org.apache.cassandra.auth.AllowAllAuthorizer");
+
+}
diff --git a/auth/allow_all_authorizer.hh b/auth/allow_all_authorizer.hh
new file mode 100644
index 0000000000..a03535ec43
--- /dev/null
+++ b/auth/allow_all_authorizer.hh
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2017 ScyllaDB
+ */
+
+/*
+ * This file is part of Scylla.
+ *
+ * Scylla is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Scylla is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Scylla. If not, see .
+ */
+
+#pragma once
+
+#include "authorizer.hh"
+#include "exceptions/exceptions.hh"
+#include "stdx.hh"
+
+namespace cql3 {
+class query_processor;
+}
+
+namespace service {
+class migration_manager;
+}
+
+namespace auth {
+
+class service;
+
+const sstring& allow_all_authorizer_name();
+
+class allow_all_authorizer final : public authorizer {
+public:
+ allow_all_authorizer(cql3::query_processor&, ::service::migration_manager&) {
+ }
+
+ future<> start() override {
+ return make_ready_future<>();
+ }
+
+ future<> stop() override {
+ return make_ready_future<>();
+ }
+
+ const sstring& qualified_java_name() const override {
+ return allow_all_authorizer_name();
+ }
+
+ future authorize(service&, ::shared_ptr, data_resource) const override {
+ return make_ready_future(permissions::ALL);
+ }
+
+ future<> grant(::shared_ptr, permission_set, data_resource, sstring) override {
+ throw exceptions::invalid_request_exception("GRANT operation is not supported by AllowAllAuthorizer");
+ }
+
+ future<> revoke(::shared_ptr, permission_set, data_resource, sstring) override {
+ throw exceptions::invalid_request_exception("REVOKE operation is not supported by AllowAllAuthorizer");
+ }
+
+ future> list(
+ service&,
+ ::shared_ptr performer,
+ permission_set,
+ stdx::optional,
+ stdx::optional) const override {
+ throw exceptions::invalid_request_exception("LIST PERMISSIONS operation is not supported by AllowAllAuthorizer");
+ }
+
+ future<> revoke_all(sstring dropped_user) override {
+ return make_ready_future();
+ }
+
+ future<> revoke_all(data_resource) override {
+ return make_ready_future();
+ }
+
+ const resource_ids& protected_resources() override {
+ static const resource_ids ids;
+ return ids;
+ }
+
+ future<> validate_configuration() const override {
+ return make_ready_future();
+ }
+};
+
+}
diff --git a/auth/auth.cc b/auth/auth.cc
deleted file mode 100644
index 75e1563523..0000000000
--- a/auth/auth.cc
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Copyright (C) 2016 ScyllaDB
- *
- * Modified by ScyllaDB
- */
-
-/*
- * This file is part of Scylla.
- *
- * Scylla is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Scylla is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Scylla. If not, see .
- */
-
-#include
-
-#include
-
-#include
-
-#include "auth.hh"
-#include "authenticator.hh"
-#include "authorizer.hh"
-#include "common.hh"
-#include "database.hh"
-#include "cql3/query_processor.hh"
-#include "cql3/untyped_result_set.hh"
-#include "cql3/statements/raw/cf_statement.hh"
-#include "cql3/statements/create_table_statement.hh"
-#include "db/config.hh"
-#include "delayed_tasks.hh"
-#include "permissions_cache.hh"
-#include "service/migration_manager.hh"
-#include "utils/loading_cache.hh"
-#include "utils/hash.hh"
-
-static const sstring USER_NAME("name");
-static const sstring SUPER("super");
-
-static logging::logger alogger("auth");
-
-// TODO: configurable
-using namespace std::chrono_literals;
-static const std::chrono::milliseconds SUPERUSER_SETUP_DELAY = 10000ms;
-
-class auth_migration_listener : public service::migration_listener {
- void on_create_keyspace(const sstring& ks_name) override {}
- void on_create_column_family(const sstring& ks_name, const sstring& cf_name) override {}
- void on_create_user_type(const sstring& ks_name, const sstring& type_name) override {}
- void on_create_function(const sstring& ks_name, const sstring& function_name) override {}
- void on_create_aggregate(const sstring& ks_name, const sstring& aggregate_name) override {}
- void on_create_view(const sstring& ks_name, const sstring& view_name) override {}
-
- void on_update_keyspace(const sstring& ks_name) override {}
- void on_update_column_family(const sstring& ks_name, const sstring& cf_name, bool) override {}
- void on_update_user_type(const sstring& ks_name, const sstring& type_name) override {}
- void on_update_function(const sstring& ks_name, const sstring& function_name) override {}
- void on_update_aggregate(const sstring& ks_name, const sstring& aggregate_name) override {}
- void on_update_view(const sstring& ks_name, const sstring& view_name, bool columns_changed) override {}
-
- void on_drop_keyspace(const sstring& ks_name) override {
- auth::authorizer::get().revoke_all(auth::data_resource(ks_name));
- }
- void on_drop_column_family(const sstring& ks_name, const sstring& cf_name) override {
- auth::authorizer::get().revoke_all(auth::data_resource(ks_name, cf_name));
- }
- void on_drop_user_type(const sstring& ks_name, const sstring& type_name) override {}
- void on_drop_function(const sstring& ks_name, const sstring& function_name) override {}
- void on_drop_aggregate(const sstring& ks_name, const sstring& aggregate_name) override {}
- void on_drop_view(const sstring& ks_name, const sstring& view_name) override {}
-};
-
-static auth_migration_listener auth_migration;
-
-static sharded perm_cache;
-
-static future<> start_permission_cache() {
- auto& db_config = cql3::get_local_query_processor().db().local().get_config();
-
- auth::permissions_cache_config c;
- c.max_entries = db_config.permissions_cache_max_entries();
- c.validity_period = std::chrono::milliseconds(db_config.permissions_validity_in_ms());
- c.update_period = std::chrono::milliseconds(db_config.permissions_update_interval_in_ms());
-
- return perm_cache.start(c, std::ref(auth::authorizer::get()), std::ref(alogger));
-}
-
-static delayed_tasks<>& get_local_delayed_tasks() {
- static thread_local delayed_tasks<> instance;
- return instance;
-}
-
-void auth::auth::schedule_when_up(scheduled_func f) {
- get_local_delayed_tasks().schedule_after(SUPERUSER_SETUP_DELAY, std::move(f));
-}
-
-future<> auth::auth::setup() {
- auto& db = cql3::get_local_query_processor().db().local();
- auto& cfg = db.get_config();
-
- qualified_name authenticator_name(meta::AUTH_PACKAGE_NAME, cfg.authenticator()),
- authorizer_name(meta::AUTH_PACKAGE_NAME, cfg.authorizer());
-
- if (allow_all_authenticator_name() == authenticator_name && allow_all_authorizer_name() == authorizer_name) {
- return authenticator::setup(authenticator_name).then([authorizer_name = std::move(authorizer_name)] {
- return authorizer::setup(authorizer_name);
- }).then([] {
- return start_permission_cache();
- });
- }
-
- future<> f = make_ready_future<>();
-
- if (!db.has_keyspace(meta::AUTH_KS)) {
- std::map opts;
- opts["replication_factor"] = "1";
- auto ksm = keyspace_metadata::new_keyspace(meta::AUTH_KS, "org.apache.cassandra.locator.SimpleStrategy", opts, true);
- // We use min_timestamp so that default keyspace metadata will loose with any manual adjustments. See issue #2129.
- f = service::get_local_migration_manager().announce_new_keyspace(ksm, api::min_timestamp, false);
- }
-
- return f.then([] {
- return setup_table(meta::USERS_CF, sprint("CREATE TABLE %s.%s (%s text, %s boolean, PRIMARY KEY(%s)) WITH gc_grace_seconds=%d",
- meta::AUTH_KS, meta::USERS_CF, USER_NAME, SUPER, USER_NAME,
- 90 * 24 * 60 * 60)); // 3 months.
- }).then([authenticator_name = std::move(authenticator_name)] {
- return authenticator::setup(authenticator_name);
- }).then([authorizer_name = std::move(authorizer_name)] {
- return authorizer::setup(authorizer_name);
- }).then([] {
- return start_permission_cache();
- }).then([] {
- service::get_local_migration_manager().register_listener(&auth_migration); // again, only one shard...
- // instead of once-timer, just schedule this later
- schedule_when_up([] {
- // setup default super user
- return has_existing_users(meta::USERS_CF, meta::DEFAULT_SUPERUSER_NAME, USER_NAME).then([](bool exists) {
- if (!exists) {
- auto query = sprint("INSERT INTO %s.%s (%s, %s) VALUES (?, ?) USING TIMESTAMP 0",
- meta::AUTH_KS, meta::USERS_CF, USER_NAME, SUPER);
- cql3::get_local_query_processor().process(query, db::consistency_level::ONE, {meta::DEFAULT_SUPERUSER_NAME, true}).then([](auto) {
- alogger.info("Created default superuser '{}'", meta::DEFAULT_SUPERUSER_NAME);
- }).handle_exception([](auto ep) {
- try {
- std::rethrow_exception(ep);
- } catch (exceptions::request_execution_exception&) {
- alogger.warn("Skipped default superuser setup: some nodes were not ready");
- }
- });
- }
- });
- });
- });
-}
-
-future<> auth::auth::shutdown() {
- // just make sure we don't have pending tasks.
- // this is mostly relevant for test cases where
- // db-env-shutdown != process shutdown
- return smp::invoke_on_all([] {
- get_local_delayed_tasks().cancel_all();
- }).then([] {
- return perm_cache.stop();
- }).then([] {
- return when_all_succeed(authorizer::get().stop(), authenticator::get().stop());
- });
-}
-
-future auth::auth::get_permissions(::shared_ptr user, data_resource resource) {
- return perm_cache.local().get(std::move(user), std::move(resource));
-}
-
-static db::consistency_level consistency_for_user(const sstring& username) {
- if (username == auth::meta::DEFAULT_SUPERUSER_NAME) {
- return db::consistency_level::QUORUM;
- }
- return db::consistency_level::LOCAL_ONE;
-}
-
-static future<::shared_ptr> select_user(const sstring& username) {
- // Here was a thread local, explicit cache of prepared statement. In normal execution this is
- // fine, but since we in testing set up and tear down system over and over, we'd start using
- // obsolete prepared statements pretty quickly.
- // Rely on query processing caching statements instead, and lets assume
- // that a map lookup string->statement is not gonna kill us much.
- return cql3::get_local_query_processor().process(
- sprint("SELECT * FROM %s.%s WHERE %s = ?",
- auth::meta::AUTH_KS, auth::meta::USERS_CF,
- USER_NAME), consistency_for_user(username),
- { username }, true);
-}
-
-future auth::auth::is_existing_user(const sstring& username) {
- return select_user(username).then(
- [](::shared_ptr res) {
- return make_ready_future(!res->empty());
- });
-}
-
-future auth::auth::is_super_user(const sstring& username) {
- return select_user(username).then(
- [](::shared_ptr res) {
- return make_ready_future(!res->empty() && res->one().get_as(SUPER));
- });
-}
-
-future<> auth::auth::insert_user(const sstring& username, bool is_super) {
- return cql3::get_local_query_processor().process(sprint("INSERT INTO %s.%s (%s, %s) VALUES (?, ?)",
- meta::AUTH_KS, meta::USERS_CF, USER_NAME, SUPER),
- consistency_for_user(username), { username, is_super }).discard_result();
-}
-
-future<> auth::auth::delete_user(const sstring& username) {
- return cql3::get_local_query_processor().process(sprint("DELETE FROM %s.%s WHERE %s = ?",
- meta::AUTH_KS, meta::USERS_CF, USER_NAME),
- consistency_for_user(username), { username }).discard_result();
-}
-
-future<> auth::auth::setup_table(const sstring& name, const sstring& cql) {
- auto& qp = cql3::get_local_query_processor();
- auto& db = qp.db().local();
-
- if (db.has_schema(meta::AUTH_KS, name)) {
- return make_ready_future();
- }
-
- ::shared_ptr parsed = static_pointer_cast<
- cql3::statements::raw::cf_statement>(cql3::query_processor::parse_statement(cql));
- parsed->prepare_keyspace(meta::AUTH_KS);
- ::shared_ptr statement =
- static_pointer_cast(
- parsed->prepare(db, qp.get_cql_stats())->statement);
- auto schema = statement->get_cf_meta_data();
- auto uuid = generate_legacy_id(schema->ks_name(), schema->cf_name());
-
- schema_builder b(schema);
- b.set_uuid(uuid);
- return service::get_local_migration_manager().announce_new_column_family(b.build(), false);
-}
-
-future auth::auth::has_existing_users(const sstring& cfname, const sstring& def_user_name, const sstring& name_column) {
- auto default_user_query = sprint("SELECT * FROM %s.%s WHERE %s = ?", meta::AUTH_KS, cfname, name_column);
- auto all_users_query = sprint("SELECT * FROM %s.%s LIMIT 1", meta::AUTH_KS, cfname);
-
- return cql3::get_local_query_processor().process(default_user_query, db::consistency_level::ONE, { def_user_name }).then([=](::shared_ptr res) {
- if (!res->empty()) {
- return make_ready_future(true);
- }
- return cql3::get_local_query_processor().process(default_user_query, db::consistency_level::QUORUM, { def_user_name }).then([all_users_query](::shared_ptr res) {
- if (!res->empty()) {
- return make_ready_future(true);
- }
- return cql3::get_local_query_processor().process(all_users_query, db::consistency_level::QUORUM).then([](::shared_ptr res) {
- return make_ready_future(!res->empty());
- });
- });
- });
-}
-
diff --git a/auth/auth.hh b/auth/auth.hh
deleted file mode 100644
index 53eb775031..0000000000
--- a/auth/auth.hh
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * Copyright (C) 2016 ScyllaDB
- *
- * Modified by ScyllaDB
- */
-
-/*
- * This file is part of Scylla.
- *
- * Scylla is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Scylla is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Scylla. If not, see .
- */
-
-#pragma once
-
-#include
-#include
-#include
-
-
-#include "exceptions/exceptions.hh"
-#include "permission.hh"
-#include "data_resource.hh"
-#include "authenticated_user.hh"
-
-namespace auth {
-
-class auth {
-public:
- class permissions_cache;
-
- static future get_permissions(::shared_ptr, data_resource);
-
- /**
- * Checks if the username is stored in AUTH_KS.USERS_CF.
- *
- * @param username Username to query.
- * @return whether or not Cassandra knows about the user.
- */
- static future is_existing_user(const sstring& username);
-
- /**
- * Checks if the user is a known superuser.
- *
- * @param username Username to query.
- * @return true is the user is a superuser, false if they aren't or don't exist at all.
- */
- static future is_super_user(const sstring& username);
-
- /**
- * Inserts the user into AUTH_KS.USERS_CF (or overwrites their superuser status as a result of an ALTER USER query).
- *
- * @param username Username to insert.
- * @param isSuper User's new status.
- * @throws RequestExecutionException
- */
- static future<> insert_user(const sstring& username, bool is_super);
-
- /**
- * Deletes the user from AUTH_KS.USERS_CF.
- *
- * @param username Username to delete.
- * @throws RequestExecutionException
- */
- static future<> delete_user(const sstring& username);
-
- /**
- * Sets up Authenticator and Authorizer.
- */
- static future<> setup();
- static future<> shutdown();
-
- /**
- * Set up table from given CREATE TABLE statement under system_auth keyspace, if not already done so.
- *
- * @param name name of the table
- * @param cql CREATE TABLE statement
- */
- static future<> setup_table(const sstring& name, const sstring& cql);
-
- static future has_existing_users(const sstring& cfname, const sstring& def_user_name, const sstring& name_column_name);
-
- // For internal use. Run function "when system is up".
- typedef std::function()> scheduled_func;
- static void schedule_when_up(scheduled_func);
-};
-}
-
-std::ostream& operator<<(std::ostream& os, const std::pair& p);
diff --git a/auth/authenticated_user.cc b/auth/authenticated_user.cc
index d956559b85..ab876b6d00 100644
--- a/auth/authenticated_user.cc
+++ b/auth/authenticated_user.cc
@@ -41,7 +41,6 @@
#include "authenticated_user.hh"
-#include "auth.hh"
const sstring auth::authenticated_user::ANONYMOUS_USERNAME("anonymous");
@@ -60,13 +59,6 @@ const sstring& auth::authenticated_user::name() const {
return _anon ? ANONYMOUS_USERNAME : _name;
}
-future auth::authenticated_user::is_super() const {
- if (is_anonymous()) {
- return make_ready_future(false);
- }
- return auth::auth::is_super_user(_name);
-}
-
bool auth::authenticated_user::operator==(const authenticated_user& v) const {
return _anon ? v._anon : _name == v._name;
}
diff --git a/auth/authenticated_user.hh b/auth/authenticated_user.hh
index b265537532..b9f1770826 100644
--- a/auth/authenticated_user.hh
+++ b/auth/authenticated_user.hh
@@ -58,14 +58,6 @@ public:
const sstring& name() const;
- /**
- * Checks the user's superuser status.
- * Only a superuser is allowed to perform CREATE USER and DROP USER queries.
- * Im most cased, though not necessarily, a superuser will have Permission.ALL on every resource
- * (depends on IAuthorizer implementation).
- */
- future is_super() const;
-
/**
* If IAuthenticator doesn't require authentication, this method may return true.
*/
diff --git a/auth/authenticator.cc b/auth/authenticator.cc
index eec1212d4b..f89bbedd90 100644
--- a/auth/authenticator.cc
+++ b/auth/authenticator.cc
@@ -43,7 +43,6 @@
#include "authenticated_user.hh"
#include "common.hh"
#include "password_authenticator.hh"
-#include "auth.hh"
#include "cql3/query_processor.hh"
#include "db/config.hh"
#include "utils/class_registrator.hh"
@@ -51,11 +50,6 @@
const sstring auth::authenticator::USERNAME_KEY("username");
const sstring auth::authenticator::PASSWORD_KEY("password");
-const sstring& auth::allow_all_authenticator_name() {
- static const sstring name = meta::AUTH_PACKAGE_NAME + "AllowAllAuthenticator";
- return name;
-}
-
auth::authenticator::option auth::authenticator::string_to_option(const sstring& name) {
if (strcasecmp(name.c_str(), "password") == 0) {
return option::PASSWORD;
@@ -71,70 +65,3 @@ sstring auth::authenticator::option_to_string(option opt) {
throw std::invalid_argument(sprint("Unknown option {}", opt));
}
}
-
-/**
- * Authenticator is assumed to be a fully state-less immutable object (note all the const).
- * We thus store a single instance globally, since it should be safe/ok.
- */
-static std::unique_ptr global_authenticator;
-
-using authenticator_registry = class_registry;
-
-future<>
-auth::authenticator::setup(const sstring& type) {
- if (type == allow_all_authenticator_name()) {
- class allow_all_authenticator : public authenticator {
- public:
- future<> start() override {
- return make_ready_future<>();
- }
- future<> stop() override {
- return make_ready_future<>();
- }
- const sstring& qualified_java_name() const override {
- return allow_all_authenticator_name();
- }
- bool require_authentication() const override {
- return false;
- }
- option_set supported_options() const override {
- return option_set();
- }
- option_set alterable_options() const override {
- return option_set();
- }
- future<::shared_ptr> authenticate(const credentials_map& credentials) const override {
- return make_ready_future<::shared_ptr>(::make_shared());
- }
- future<> create(sstring username, const option_map& options) override {
- return make_ready_future();
- }
- future<> alter(sstring username, const option_map& options) override {
- return make_ready_future();
- }
- future<> drop(sstring username) override {
- return make_ready_future();
- }
- const resource_ids& protected_resources() const override {
- static const resource_ids ids;
- return ids;
- }
- ::shared_ptr new_sasl_challenge() const override {
- throw std::runtime_error("Should not reach");
- }
- };
- global_authenticator = std::make_unique();
- return make_ready_future();
- } else {
- auto a = authenticator_registry::create(type, cql3::get_local_query_processor());
- auto f = a->start();
- return f.then([a = std::move(a)]() mutable {
- global_authenticator = std::move(a);
- });
- }
-}
-
-auth::authenticator& auth::authenticator::get() {
- assert(global_authenticator);
- return *global_authenticator;
-}
diff --git a/auth/authenticator.hh b/auth/authenticator.hh
index db2fbe6e9c..55c2c42737 100644
--- a/auth/authenticator.hh
+++ b/auth/authenticator.hh
@@ -65,8 +65,6 @@ namespace auth {
class authenticated_user;
-const sstring& allow_all_authenticator_name();
-
class authenticator {
public:
static const sstring USERNAME_KEY;
@@ -87,19 +85,6 @@ public:
using option_map = std::unordered_map