Skip to content

Commit 9e46e08

Browse files
authored
Add sign-in request for authentication token retrieval (#216)
## Release notes: usage and product changes A new mechanism of authentication tokens has been introduced to replace the old way of sending usernames and passwords through the network with every request. Instead, all user credentials (currently, it's usernames and passwords) are sent only: * as a part of `connection_open` request for authentication and authorization, with a temporary token returned; * as a part of `sign_in` request for sign ins within an established connection (to change the user or to get a new authentication token). Then, all further requests are expected to be authenticated only by temporary, less sensitive tokens. The approach is extensible to other credential types that can be introduced in the future. ## Implementation
1 parent 91fa29c commit 9e46e08

File tree

10 files changed

+54
-8
lines changed

10 files changed

+54
-8
lines changed

grpc/java/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ java_grpc_library(
1616
"//proto:answer-proto",
1717
"//proto:concept-proto",
1818
"//proto:connection-proto",
19+
"//proto:authentication-proto",
1920
"//proto:logic-proto",
2021
"//proto:options-proto",
2122
"//proto:query-proto",

grpc/nodejs/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ts_grpc_compile(
3232
"//proto:answer-proto",
3333
"//proto:concept-proto",
3434
"//proto:connection-proto",
35+
"//proto:authentication-proto",
3536
"//proto:logic-proto",
3637
"//proto:options-proto",
3738
"//proto:query-proto",

grpc/rust/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ rust_tonic_compile(
1919
"//proto:answer-proto",
2020
"//proto:concept-proto",
2121
"//proto:connection-proto",
22+
"//proto:authentication-proto",
2223
"//proto:logic-proto",
2324
"//proto:options-proto",
2425
"//proto:query-proto",

grpc/rust/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
fn main() -> std::io::Result<()> {
66
let protos = vec![
77
"../../proto/answer.proto",
8+
"../../proto/authentication.proto",
89
"../../proto/concept.proto",
910
"../../proto/connection.proto",
1011
"../../proto/database.proto",

proto/BUILD

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ proto_library(
1111
srcs = [":typedb-service.proto"],
1212
deps = [
1313
":connection-proto",
14+
":authentication-proto",
1415
":server-proto",
1516
":user-proto",
1617
":database-proto",
@@ -39,6 +40,11 @@ proto_library(
3940
deps = [":concept-proto"],
4041
)
4142

43+
proto_library(
44+
name = "authentication-proto",
45+
srcs = ["authentication.proto"],
46+
)
47+
4248
proto_library(
4349
name = "concept-proto",
4450
srcs = ["concept.proto"],
@@ -48,8 +54,9 @@ proto_library(
4854
name = "connection-proto",
4955
srcs = ["connection.proto"],
5056
deps = [
51-
":version-proto",
52-
":database-proto"
57+
":authentication-proto",
58+
":database-proto",
59+
":version-proto"
5360
],
5461
)
5562

proto/authentication.proto

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
syntax = "proto3";
6+
7+
package typedb.protocol;
8+
9+
message Authentication {
10+
message Token {
11+
message Create {
12+
message Req {
13+
message Password {
14+
string username = 1;
15+
string password = 2;
16+
}
17+
18+
oneof credentials {
19+
Password password = 1;
20+
// extend by other credential kinds
21+
}
22+
}
23+
24+
message Res {
25+
string token = 1;
26+
}
27+
}
28+
}
29+
}

proto/connection.proto

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
syntax = "proto3";
66

7-
import "proto/version.proto";
7+
import "proto/authentication.proto";
88
import "proto/database.proto";
9+
import "proto/version.proto";
910

1011
package typedb.protocol;
1112

@@ -16,16 +17,18 @@ message Connection {
1617
Version version = 1;
1718
string driver_lang = 2;
1819
string driver_version = 3;
20+
21+
Authentication.Token.Create.Req authentication = 4;
1922
}
2023

2124
message Res {
2225
uint64 server_duration_millis = 1;
2326
ConnectionID connection_id = 2;
2427

25-
// TODO: initial Token
26-
2728
// pre-send all databases and replica info
2829
DatabaseManager.All.Res databases_all = 3;
30+
31+
Authentication.Token.Create.Res authentication = 4;
2932
}
3033
}
3134
}

proto/query.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ syntax = "proto3";
66

77
import "proto/answer.proto";
88
import "proto/options.proto";
9-
import "proto/concept.proto";
109

1110
package typedb.protocol;
1211

proto/typedb-service.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
syntax = "proto3";
66

7+
import "proto/authentication.proto";
78
import "proto/connection.proto";
89
import "proto/database.proto";
910
import "proto/server.proto";
@@ -17,6 +18,9 @@ service TypeDB {
1718
// Connection API
1819
rpc connection_open (Connection.Open.Req) returns (Connection.Open.Res);
1920

21+
// Authentication API
22+
rpc authentication_token_create (Authentication.Token.Create.Req) returns (Authentication.Token.Create.Res);
23+
2024
// Server Manager API
2125
rpc servers_all (ServerManager.All.Req) returns (ServerManager.All.Res);
2226

proto/version.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ syntax = "proto3";
77
package typedb.protocol;
88

99
enum Version {
10-
reserved 1, 2, 3; // add past version numbers into the reserved range
10+
reserved 1, 2, 3, 4; // add past version numbers into the reserved range
1111
UNSPECIFIED = 0;
12-
VERSION = 4;
12+
VERSION = 5;
1313
}

0 commit comments

Comments
 (0)