Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add nameserver auth #3835

Merged
merged 62 commits into from
Apr 19, 2024
Merged

Conversation

oh2024
Copy link
Collaborator

@oh2024 oh2024 commented Mar 26, 2024

What kind of change does this PR introduce?
This PR introduces a significant security enhancement by implementing RPC authenticator functionality to ensure all connections are authenticated server-side. This is a feature change aimed at improving the security of server-client communications.

What is the current behavior?
Currently, there is no authentication performed on the server side for incoming connections. Authentication is solely handled within the SDK, leaving a potential security gap for server-client communications.

What is the new behavior (if this is a feature change)?
With this change, all connections to the server will undergo authentication at the beginning of the rpc connection. This server-side authentication is facilitated by the newly introduced Authenticator class, which supports two types of authentication: service authentication and user authentication. For the sake of maintaining backward compatibility, the system will initially allow all services carrying the "default" token and users with the username "root". This PR lays down the foundational framework for our enhanced security measures, focusing on authentication at the server side. Future PRs will expand on this by incorporating user verification against tablet data and authenticating service tokens via a Zookeeper service token record. This implementation is a critical step toward tightening security and providing a robust authentication mechanism for our system.

@oh2024 oh2024 requested review from aceforeverd and vagetablechicken and removed request for aceforeverd March 26, 2024 04:35
@github-actions github-actions bot added build openmldb compiling and installing storage-engine openmldb storage engine. nameserver & tablet labels Mar 26, 2024
@oh2024 oh2024 requested review from dl239, aceforeverd and vagetablechicken and removed request for vagetablechicken March 26, 2024 04:35
Copy link
Contributor

github-actions bot commented Mar 26, 2024

Linux Test Report

    59 files  +    59     249 suites  +249   1h 47m 47s ⏱️ + 1h 47m 47s
13 256 tests +13 256  13 249 ✅ +13 249  7 💤 +7  0 ❌ ±0 
18 813 runs  +18 813  18 806 ✅ +18 806  7 💤 +7  0 ❌ ±0 

Results for commit 5debf64. ± Comparison against base commit 6b52ee5.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Mar 26, 2024

SDK Test Report

102 files  ±0  102 suites  ±0   2m 15s ⏱️ -2s
357 tests ±0  343 ✅ ±0  14 💤 ±0  0 ❌ ±0 
483 runs  ±0  469 ✅ ±0  14 💤 ±0  0 ❌ ±0 

Results for commit 5debf64. ± Comparison against base commit 6b52ee5.

This pull request removes 48 and adds 27 tests. Note that renamed tests count towards both.
  PARTITION BY db1.t1.col2 ORDER BY db1.t1.col1
  PARTITION BY t1.col2 ORDER BY t1.col1
  ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW
 ) limit 10;](1)
 ) limit 10;](2)
 ) limit 10;](3)
 FROM db1.t1
 FROM t1
 WINDOW w1 AS (
 last join db2.t2 order by db2.t2.col1
…
com._4paradigm.hybridse.sdk.SqlEngineTest ‑ sqlLastJoinWithMultipleDB[,  SELECT sum(db1.t1.col1) over w1 as sum_t1_col1, db2.t2.str1 as t2_str1
 FROM db1.t1
 last join db2.t2 order by db2.t2.col1
 on db1.t1.col1 = db2.t2.col1 and db1.t1.col2 = db2.t2.col0
 WINDOW w1 AS (
  PARTITION BY db1.t1.col2 ORDER BY db1.t1.col1
  ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW
 ) limit 10;](2)
com._4paradigm.hybridse.sdk.SqlEngineTest ‑ sqlLastJoinWithMultipleDB[db1,  SELECT sum(t1.col1) over w1 as sum_t1_col1, db2.t2.str1 as t2_str1
 FROM t1
 last join db2.t2 order by db2.t2.col1
 on t1.col1 = db2.t2.col1 and t1.col2 = db2.t2.col0
 WINDOW w1 AS (
  PARTITION BY t1.col2 ORDER BY t1.col1
  ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW
 ) limit 10;](1)
com._4paradigm.hybridse.sdk.SqlEngineTest ‑ sqlLastJoinWithMultipleDB[null,  SELECT sum(db1.t1.col1) over w1 as sum_t1_col1, db2.t2.str1 as t2_str1
 FROM db1.t1
 last join db2.t2 order by db2.t2.col1
 on db1.t1.col1 = db2.t2.col1 and db1.t1.col2 = db2.t2.col0
 WINDOW w1 AS (
  PARTITION BY db1.t1.col2 ORDER BY db1.t1.col1
  ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW
 ) limit 10;](3)
com._4paradigm.hybridse.sdk.SqlEngineTest ‑ sqlMultipleDBErrorTest[, SELECT db2.t2.str1 as t2_str1
 FROM t1
 last join db2.t2 order by db2.t2.col1
 on t1.col1 = db2.t2.col1 and t1.col2 = db2.t2.col0;
, SQL parse error: Fail to transform data provider op: table t1 not exists in database []](4)
com._4paradigm.hybridse.sdk.SqlEngineTest ‑ sqlMultipleDBErrorTest[db1, SELECT db1.t2.str1 as t2_str1
 FROM t1
 last join db2.t2 order by db2.t2.col1
 on t1.col1 = db2.t2.col1 and t1.col2 = db2.t2.col0;
, SQL parse error: Column Not found: db1.t2.str1](2)
com._4paradigm.hybridse.sdk.SqlEngineTest ‑ sqlMultipleDBErrorTest[db1, SELECT db2.t2.str1 as t2_str1
 FROM t1
 last join db2.t2 order by db2.t2.col1
 on t1.col1 = t2.col1 and t1.col2 = db2.t2.col0;
, SQL parse error: Column Not found: .t2.col1](3)
com._4paradigm.hybridse.sdk.SqlEngineTest ‑ sqlMultipleDBErrorTest[db1, SELECT t2.str1 as t2_str1
 FROM t1
 last join db2.t2 order by db2.t2.col1
 on t1.col1 = db2.t2.col1 and t1.col2 = db2.t2.col0;
, SQL parse error: Column Not found: .t2.str1](1)
com._4paradigm.hybridse.sdk.SqlEngineTest ‑ sqlMultipleDBErrorTest[null, SELECT db2.t2.str1 as t2_str1
 FROM t1
 last join db2.t2 order by db2.t2.col1
 on t1.col1 = db2.t2.col1 and t1.col2 = db2.t2.col0;
, SQL parse error: Fail to transform data provider op: table t1 not exists in database []](5)
com._4paradigm.hybridse.sdk.SqlEngineTest ‑ sqlWindowLastJoin[ SELECT sum(t1.col1) over w1 as sum_t1_col1, t2.str1 as t2_str1
 FROM t1
 last join t2 order by t2.col1
 on t1.col1 = t2.col1 and t1.col2 = t2.col0
 WINDOW w1 AS (
  PARTITION BY t1.col2 ORDER BY t1.col1
  ROWS_RANGE BETWEEN 3 PRECEDING AND CURRENT ROW
 ) limit 10;](1)
com._4paradigm.openmldb.jdbc.SQLRouterSmokeTest ‑ testInsertMeta[com._4paradigm.openmldb.sdk.impl.SqlClusterExecutor@1280bae3](1)
…

♻️ This comment has been updated with latest results.

@oh2024 oh2024 requested a review from tobegit3hub March 26, 2024 06:08
@oh2024 oh2024 changed the title feat: add server auth feat: add nameserver auth Apr 2, 2024
@github-actions github-actions bot removed the sdk openmldb java/python sdk label Apr 11, 2024
@github-actions github-actions bot added the sdk openmldb java/python sdk label Apr 16, 2024
@oh2024
Copy link
Collaborator Author

oh2024 commented Apr 16, 2024

integration test will fail because old sdk is used

@github-actions github-actions bot removed the sdk openmldb java/python sdk label Apr 17, 2024
bool ok = name_server_client.SendRequest(&::openmldb::nameserver::NameServer_Stub::ShowTable, &request, &response,
FLAGS_request_timeout_ms, 1);
ASSERT_TRUE(ok);
ASSERT_EQ(response.table_info_size(), size);
}

TEST_F(SqlClusterTest, RecoverProcedure) {
TEST_F(SqlClusterTest, DropProcedureBeforeDropTable) {
Copy link
Collaborator

@vagetablechicken vagetablechicken Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why rename this test file? drop_procedure_before_drop_table_test.cc is not a good name. You'd better make the file name be the same with the test class, not the test method name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to separate the RecoverProcedure and DropProcedureBeforeDropTable for the tests to pass. There's probably some bugs in the tests that we can fix later

Copy link
Collaborator

@vagetablechicken vagetablechicken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no docs about privileges, add in auth.md after #3879


void UserAccessManager::StartSyncTask() {
sync_task_running_ = true;
sync_task_thread_ = std::thread([this] {
Copy link
Collaborator

@aceforeverd aceforeverd Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query table every 0.1 seconds ? Not good practice if my understand is correct, instead, you should lazy fetch the table with help of zk.

Register an event listener to zk > on table values update, notify zk > zk will send data updated event to every subscriber .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is just temporary solution to get latest user credentials. In the future we will use a distributed transaction to update user table cache on all nodes.

@vagetablechicken
Copy link
Collaborator

merge after 0.9.0 released, cherry-pick is heavy

@vagetablechicken vagetablechicken merged commit 86c5e65 into 4paradigm:main Apr 19, 2024
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
batch-engine openmldb batch(offline) engine build openmldb compiling and installing storage-engine openmldb storage engine. nameserver & tablet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants