Skip to content

Commit

Permalink
db: auth: move auth tables to system keyspace
Browse files Browse the repository at this point in the history
Separate keyspace which also behaves as system brings
little benefit while creating some compatibility problems
like schema digest mismatch during rollback. So we decided
to move auth tables into system keyspace.

Fixes scylladb#18098

Closes scylladb#18769
  • Loading branch information
nuivall authored and avikivity committed May 26, 2024
1 parent 56d523b commit 2ab143f
Show file tree
Hide file tree
Showing 28 changed files with 169 additions and 244 deletions.
5 changes: 2 additions & 3 deletions auth/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "service/raft/group0_state_machine.hh"
#include "timeout_config.hh"
#include "db/config.hh"
#include "db/system_auth_keyspace.hh"
#include "utils/error_injection.hh"

namespace auth {
Expand All @@ -41,14 +40,14 @@ constinit const std::string_view AUTH_PACKAGE_NAME("org.apache.cassandra.auth.")
static logging::logger auth_log("auth");

bool legacy_mode(cql3::query_processor& qp) {
return qp.auth_version < db::system_auth_keyspace::version_t::v2;
return qp.auth_version < db::system_keyspace::auth_version_t::v2;
}

std::string_view get_auth_ks_name(cql3::query_processor& qp) {
if (legacy_mode(qp)) {
return meta::legacy::AUTH_KS;
}
return db::system_auth_keyspace::NAME;
return db::system_keyspace::NAME;
}

// Func must support being invoked more than once.
Expand Down
2 changes: 1 addition & 1 deletion auth/default_authorizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

#include "auth/default_authorizer.hh"
#include "db/system_auth_keyspace.hh"
#include "db/system_keyspace.hh"

extern "C" {
#include <crypt.h>
Expand Down
5 changes: 2 additions & 3 deletions auth/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "db/config.hh"
#include "db/consistency_level_type.hh"
#include "db/functions/function_name.hh"
#include "db/system_auth_keyspace.hh"
#include "log.hh"
#include "schema/schema_fwd.hh"
#include <seastar/core/future.hh>
Expand Down Expand Up @@ -633,7 +632,7 @@ future<> migrate_to_auth_v2(db::system_keyspace& sys_ks, ::service::raft_group0_
}
auto muts = co_await qp.get_mutations_internal(
format("INSERT INTO {}.{} ({}) VALUES ({})",
db::system_auth_keyspace::NAME,
db::system_keyspace::NAME,
cf_name,
col_names_str,
val_binders_str),
Expand All @@ -648,7 +647,7 @@ future<> migrate_to_auth_v2(db::system_keyspace& sys_ks, ::service::raft_group0_
}
}
co_yield co_await sys_ks.make_auth_version_mutation(ts,
db::system_auth_keyspace::version_t::v2);
db::system_keyspace::auth_version_t::v2);
};
co_await announce_mutations_with_batching(g0,
start_operation_func,
Expand Down
1 change: 0 additions & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,6 @@ def find_ninja():
'cql3/result_set.cc',
'cql3/prepare_context.cc',
'db/consistency_level.cc',
'db/system_auth_keyspace.cc',
'db/system_keyspace.cc',
'db/virtual_table.cc',
'db/virtual_tables.cc',
Expand Down
3 changes: 1 addition & 2 deletions cql3/query_processor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "lang/wasm.hh"
#include "service/raft/raft_group0_client.hh"
#include "types/types.hh"
#include "db/system_auth_keyspace.hh"


namespace service {
Expand Down Expand Up @@ -176,7 +175,7 @@ public:

wasm::manager& wasm() { return _wasm; }

db::system_auth_keyspace::version_t auth_version;
db::system_keyspace::auth_version_t auth_version;

statements::prepared_statement::checked_weak_ptr get_prepared(const std::optional<auth::authenticated_user>& user, const prepared_cache_key_type& key) {
if (user) {
Expand Down
1 change: 0 additions & 1 deletion db/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ add_library(db STATIC)
target_sources(db
PRIVATE
consistency_level.cc
system_auth_keyspace.cc
system_keyspace.cc
virtual_table.cc
virtual_tables.cc
Expand Down
2 changes: 0 additions & 2 deletions db/schema_tables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "gms/feature_service.hh"
#include "partition_slice_builder.hh"
#include "dht/i_partitioner.hh"
#include "system_auth_keyspace.hh"
#include "system_keyspace.hh"
#include "query-result-set.hh"
#include "query-result-writer.hh"
Expand Down Expand Up @@ -235,7 +234,6 @@ future<> save_system_schema(cql3::query_processor& qp) {
co_await save_system_schema_to_keyspace(qp, schema_tables::NAME);
// #2514 - make sure "system" is written to system_schema.keyspaces.
co_await save_system_schema_to_keyspace(qp, system_keyspace::NAME);
co_await save_system_schema_to_keyspace(qp, system_auth_keyspace::NAME);
}

namespace v3 {
Expand Down
141 changes: 0 additions & 141 deletions db/system_auth_keyspace.cc

This file was deleted.

38 changes: 0 additions & 38 deletions db/system_auth_keyspace.hh

This file was deleted.

Loading

0 comments on commit 2ab143f

Please sign in to comment.