From e06573b7037f3432c89efb453960f92430c9062c Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Wed, 12 Mar 2025 15:47:45 +0000 Subject: [PATCH 1/8] Add sign_in auth request --- proto/authentication.proto | 22 ++++++++++++++++++++++ proto/connection.proto | 2 -- proto/typedb-service.proto | 4 ++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 proto/authentication.proto diff --git a/proto/authentication.proto b/proto/authentication.proto new file mode 100644 index 0000000..99661f2 --- /dev/null +++ b/proto/authentication.proto @@ -0,0 +1,22 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +syntax = "proto3"; + +package typedb.protocol; + +message Authentication { + + // TODO: How to extend it if other credentials appear? Make SignInPassword + SignInXXX, or make username + password optional? + message SignIn { + message Req { + string username = 1; + string password = 2; + } + + message Res { + string token = 1; + } + } +} diff --git a/proto/connection.proto b/proto/connection.proto index b7f5105..27a5c21 100644 --- a/proto/connection.proto +++ b/proto/connection.proto @@ -22,8 +22,6 @@ message Connection { uint64 server_duration_millis = 1; ConnectionID connection_id = 2; - // TODO: initial Token - // pre-send all databases and replica info DatabaseManager.All.Res databases_all = 3; } diff --git a/proto/typedb-service.proto b/proto/typedb-service.proto index 4f693cd..4e9e62d 100644 --- a/proto/typedb-service.proto +++ b/proto/typedb-service.proto @@ -4,6 +4,7 @@ syntax = "proto3"; +import "proto/authentication.proto"; import "proto/connection.proto"; import "proto/database.proto"; import "proto/server.proto"; @@ -17,6 +18,9 @@ service TypeDB { // Connection API rpc connection_open (Connection.Open.Req) returns (Connection.Open.Res); + // Authentication API + rpc sign_in (Authentication.SignIn.Req) returns (Authentication.SignIn.Res); + // Server Manager API rpc servers_all (ServerManager.All.Req) returns (ServerManager.All.Res); From 474f3efaa0ed4b9ff07df8e30e4968ad21e54eab Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Wed, 12 Mar 2025 17:20:32 +0000 Subject: [PATCH 2/8] Refactor for extensibility --- proto/authentication.proto | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/proto/authentication.proto b/proto/authentication.proto index 99661f2..3aa8a02 100644 --- a/proto/authentication.proto +++ b/proto/authentication.proto @@ -8,11 +8,14 @@ package typedb.protocol; message Authentication { - // TODO: How to extend it if other credentials appear? Make SignInPassword + SignInXXX, or make username + password optional? message SignIn { message Req { - string username = 1; - string password = 2; + message Password { + string username = 1; + string password = 2; + } + + optional Password password = 1; } message Res { From 5086f963c55316432190eba747a8b3e0a7b14c2b Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Wed, 12 Mar 2025 17:44:46 +0000 Subject: [PATCH 3/8] Refactor + add the new proto file to the needed build files --- grpc/java/BUILD | 1 + grpc/nodejs/BUILD | 1 + grpc/rust/BUILD | 1 + proto/BUILD | 6 ++++++ proto/authentication.proto | 5 ++++- proto/query.proto | 1 - 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/grpc/java/BUILD b/grpc/java/BUILD index 33a8dc9..0ca5360 100644 --- a/grpc/java/BUILD +++ b/grpc/java/BUILD @@ -16,6 +16,7 @@ java_grpc_library( "//proto:answer-proto", "//proto:concept-proto", "//proto:connection-proto", + "//proto:authentication-proto", "//proto:logic-proto", "//proto:options-proto", "//proto:query-proto", diff --git a/grpc/nodejs/BUILD b/grpc/nodejs/BUILD index 6233662..74860c2 100644 --- a/grpc/nodejs/BUILD +++ b/grpc/nodejs/BUILD @@ -32,6 +32,7 @@ ts_grpc_compile( "//proto:answer-proto", "//proto:concept-proto", "//proto:connection-proto", + "//proto:authentication-proto", "//proto:logic-proto", "//proto:options-proto", "//proto:query-proto", diff --git a/grpc/rust/BUILD b/grpc/rust/BUILD index 5d608c9..2c98ea8 100644 --- a/grpc/rust/BUILD +++ b/grpc/rust/BUILD @@ -19,6 +19,7 @@ rust_tonic_compile( "//proto:answer-proto", "//proto:concept-proto", "//proto:connection-proto", + "//proto:authentication-proto", "//proto:logic-proto", "//proto:options-proto", "//proto:query-proto", diff --git a/proto/BUILD b/proto/BUILD index 9c9ec50..710d586 100644 --- a/proto/BUILD +++ b/proto/BUILD @@ -11,6 +11,7 @@ proto_library( srcs = [":typedb-service.proto"], deps = [ ":connection-proto", + ":authentication-proto", ":server-proto", ":user-proto", ":database-proto", @@ -39,6 +40,11 @@ proto_library( deps = [":concept-proto"], ) +proto_library( + name = "authentication-proto", + srcs = ["authentication.proto"], +) + proto_library( name = "concept-proto", srcs = ["concept.proto"], diff --git a/proto/authentication.proto b/proto/authentication.proto index 3aa8a02..cdb6ac5 100644 --- a/proto/authentication.proto +++ b/proto/authentication.proto @@ -15,7 +15,10 @@ message Authentication { string password = 2; } - optional Password password = 1; + oneof credentials { + Password password = 1; + // extend by other credential kinds + } } message Res { diff --git a/proto/query.proto b/proto/query.proto index bfae4c9..0ffc7a4 100644 --- a/proto/query.proto +++ b/proto/query.proto @@ -6,7 +6,6 @@ syntax = "proto3"; import "proto/answer.proto"; import "proto/options.proto"; -import "proto/concept.proto"; package typedb.protocol; From f0711d197c1e266891a5dbb434175dab1332fe41 Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Thu, 13 Mar 2025 11:15:12 +0000 Subject: [PATCH 4/8] Add authentication into connection --- proto/BUILD | 5 +++-- proto/connection.proto | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/proto/BUILD b/proto/BUILD index 710d586..756f318 100644 --- a/proto/BUILD +++ b/proto/BUILD @@ -54,8 +54,9 @@ proto_library( name = "connection-proto", srcs = ["connection.proto"], deps = [ - ":version-proto", - ":database-proto" + ":authentication-proto", + ":database-proto", + ":version-proto" ], ) diff --git a/proto/connection.proto b/proto/connection.proto index 27a5c21..d19c8fa 100644 --- a/proto/connection.proto +++ b/proto/connection.proto @@ -4,8 +4,9 @@ syntax = "proto3"; -import "proto/version.proto"; +import "proto/authentication.proto"; import "proto/database.proto"; +import "proto/version.proto"; package typedb.protocol; @@ -16,6 +17,8 @@ message Connection { Version version = 1; string driver_lang = 2; string driver_version = 3; + + Authentication.SignIn.Req authentication = 4; } message Res { @@ -24,6 +27,8 @@ message Connection { // pre-send all databases and replica info DatabaseManager.All.Res databases_all = 3; + + Authentication.SignIn.Res authentication = 4; } } } From f39182fdab483cf9dfd86ca089fbd1cf49e51762 Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Mon, 24 Mar 2025 10:05:37 +0000 Subject: [PATCH 5/8] Refactor SignIn to Token.Create --- proto/authentication.proto | 25 +++++++++++++------------ proto/connection.proto | 4 ++-- proto/typedb-service.proto | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/proto/authentication.proto b/proto/authentication.proto index cdb6ac5..5a93162 100644 --- a/proto/authentication.proto +++ b/proto/authentication.proto @@ -7,22 +7,23 @@ syntax = "proto3"; package typedb.protocol; message Authentication { + message Token { + message Create { + message Req { + message Password { + string username = 1; + string password = 2; + } - message SignIn { - message Req { - message Password { - string username = 1; - string password = 2; + oneof credentials { + Password password = 1; + // extend by other credential kinds + } } - oneof credentials { - Password password = 1; - // extend by other credential kinds + message Res { + string token = 1; } } - - message Res { - string token = 1; - } } } diff --git a/proto/connection.proto b/proto/connection.proto index d19c8fa..6123524 100644 --- a/proto/connection.proto +++ b/proto/connection.proto @@ -18,7 +18,7 @@ message Connection { string driver_lang = 2; string driver_version = 3; - Authentication.SignIn.Req authentication = 4; + Authentication.Token.Create.Req authentication = 4; } message Res { @@ -28,7 +28,7 @@ message Connection { // pre-send all databases and replica info DatabaseManager.All.Res databases_all = 3; - Authentication.SignIn.Res authentication = 4; + Authentication.Token.Create.Res authentication = 4; } } } diff --git a/proto/typedb-service.proto b/proto/typedb-service.proto index 4e9e62d..4b455bf 100644 --- a/proto/typedb-service.proto +++ b/proto/typedb-service.proto @@ -19,7 +19,7 @@ service TypeDB { rpc connection_open (Connection.Open.Req) returns (Connection.Open.Res); // Authentication API - rpc sign_in (Authentication.SignIn.Req) returns (Authentication.SignIn.Res); + rpc sign_in (Authentication.Token.Create.Req) returns (Authentication.Token.Create.Res); // Server Manager API rpc servers_all (ServerManager.All.Req) returns (ServerManager.All.Res); From 6cf67b5e93fc76d1b5c24d064b16c063a53b5e9c Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Mon, 24 Mar 2025 10:12:51 +0000 Subject: [PATCH 6/8] Rename sign_in to authentication_token_create --- proto/typedb-service.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/typedb-service.proto b/proto/typedb-service.proto index 4b455bf..beffa1b 100644 --- a/proto/typedb-service.proto +++ b/proto/typedb-service.proto @@ -19,7 +19,7 @@ service TypeDB { rpc connection_open (Connection.Open.Req) returns (Connection.Open.Res); // Authentication API - rpc sign_in (Authentication.Token.Create.Req) returns (Authentication.Token.Create.Res); + rpc authentication_token_create (Authentication.Token.Create.Req) returns (Authentication.Token.Create.Res); // Server Manager API rpc servers_all (ServerManager.All.Req) returns (ServerManager.All.Res); From c43acc88e676fad831d09491577e11fef12501be Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Tue, 8 Apr 2025 14:29:07 +0100 Subject: [PATCH 7/8] Update protocol version --- proto/version.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/version.proto b/proto/version.proto index 683ce5d..f414540 100644 --- a/proto/version.proto +++ b/proto/version.proto @@ -7,7 +7,7 @@ syntax = "proto3"; package typedb.protocol; enum Version { - reserved 1, 2, 3; // add past version numbers into the reserved range + reserved 1, 2, 3, 4; // add past version numbers into the reserved range UNSPECIFIED = 0; - VERSION = 4; + VERSION = 5; } From 154c0dd891192d4b3649abcd09ef019249a204f5 Mon Sep 17 00:00:00 2001 From: Georgii Novoselov Date: Wed, 9 Apr 2025 17:21:11 +0100 Subject: [PATCH 8/8] Fix rust build --- grpc/rust/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/grpc/rust/build.rs b/grpc/rust/build.rs index e5008cc..6e91838 100644 --- a/grpc/rust/build.rs +++ b/grpc/rust/build.rs @@ -5,6 +5,7 @@ fn main() -> std::io::Result<()> { let protos = vec![ "../../proto/answer.proto", + "../../proto/authentication.proto", "../../proto/concept.proto", "../../proto/connection.proto", "../../proto/database.proto",