Skip to content

Commit d38cdd0

Browse files
committed
update
1 parent 703dc1e commit d38cdd0

13 files changed

+144
-100
lines changed

Cargo.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ edition = "2021"
88
default = ["server-api", "client-api", "all_api"]
99
client-api = []
1010
server-api = []
11-
all_api = ["metrics", "storage", "share", "webhook", "seach"]
11+
all_api = ["metrics", "storage", "share", "webhook", "search", "engine", "account", "region"]
1212
# API for getting the metrics using operntelemetry over ptotobuf.
1313
metrics = ["opentelemetry-proto"]
1414
storage = []
1515
share = []
1616
webhook = []
17-
seach = []
17+
search = []
18+
region = []
19+
engine = []
20+
account = []
1821
[dependencies]
1922
tonic-health = {version = "*", default-features = false, features = []}
2023
tonic-web = {version = "*", default-features = false, features = []}

proto/account/v1/access_token.proto

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
syntax = "proto3";
2+
package account;
3+
import "google/protobuf/timestamp.proto";
4+
5+
message SetApiSettingsRequest {
6+
bool api_is_enable =
7+
1; /// Disabled by default. Use this request with parameter set as true.
8+
}
9+
10+
/// To globally enable or disable API for user, In case the API is compromised
11+
/// this can be used. Will be disabled by default to reduce security footprint.
12+
message SetApiSettingsResponse { bool api_is_enable = 1; }
13+
14+
message CreateNewAccessTokenRequest {
15+
/// ISO 8601 format.
16+
optional google.protobuf.Timestamp expires_at = 1;
17+
// will be API, or USER. User can revoke API tokens, API can't.
18+
string role = 2;
19+
/// Empty to allow access to all available buckets under user.
20+
/// Set to limit the access to specific users buckets.
21+
repeated string opt_user_id_access = 4;
22+
/// If the API is only allowed to access a set
23+
/// of specific bucket, leave empty for all.
24+
repeated string opt_bucket_id_access = 3;
25+
26+
optional bytes metadata = 6; /// Metadata to be stored with the API key.
27+
}
28+
29+
message CreateNewAccessTokenResponse {
30+
string access_token = 1; /// Will be a jwt token with role of 'api'.
31+
}
32+
33+
message UpdateAccessTokenRequest {
34+
string access_token = 1;
35+
}
36+
37+
message UpdateAccessTokenResponse {
38+
39+
}

proto/account/v1/account.proto

-28
Original file line numberDiff line numberDiff line change
@@ -69,34 +69,6 @@ message AddCreditsToBucketRequest {
6969

7070
message AddCreditsToBucketResponse {}
7171

72-
message SetApiSettingsRequest {
73-
bool api_is_enable =
74-
1; /// Disabled by default. Use this request with parameter set as true.
75-
}
76-
77-
/// To globaly enable or disable API for user, In case the API is compromised
78-
/// this can be used. Will be disabled by default to reduce security footprint.
79-
message SetApiSettingsResponse { bool api_is_enable = 1; }
80-
81-
message CreateNewApiKeyRequest {
82-
/// ISO 8601 format.
83-
optional google.protobuf.Timestamp expires_at = 1;
84-
// will be API, or USER. User can revoke API tokens, API can't.
85-
string role = 2;
86-
/// Empty to allow access to all available buckets under user.
87-
/// Set to limit the access to specific users buckets.
88-
repeated string opt_user_id_access = 4;
89-
/// If the API is only allowed to access a set
90-
/// of specific bucket, leave empty for all.
91-
repeated string opt_bucket_id_access = 3;
92-
93-
optional bytes metadata = 6; /// Metadata to be stored with the API key.
94-
}
95-
96-
message CreateNewApiKeyResponse {
97-
string api_token = 1; /// Will be a jwt token with role of 'api'.
98-
}
99-
10072

10173
/// If both field are empty, it will assume the user is requesting for his own
10274
/// account details. Some information such as email are never returned when
+10-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
syntax = "proto3";
22
import "account/v1/account.proto";
33
import "account/v1/auth.proto";
4+
import "account/v1/mfa.proto";
5+
import "account/v1/login.proto";
6+
import "account/v1/registration.proto";
7+
import "account/v1/access_token.proto";
8+
49
package account;
510

611
service AccountService {
7-
// Auth
12+
// Signup
813
rpc CreateAccountStart(CreateAccountStartRequest)
914
returns (CreateAccountStartResponse) {};
1015
rpc CreateAccountFinish(CreateAccountFinishRequest)
1116
returns (CreateAccountFinishResponse) {};
12-
17+
// Password based login
1318
rpc AccountLoginStart(AccountLoginStartRequest)
1419
returns (AccountLoginStartResponse) {};
1520
rpc AccountLoginFinish(AccountLoginFinishRequest)
1621
returns (AccountLoginFinishResponse) {};
17-
1822
rpc AccountLogout(AccountLogoutRequest) returns (AccountLogoutResponse) {};
23+
1924
// Account
2025
rpc DeleteAccount(DeleteAccountRequest) returns (DeleteAccountResponse) {};
2126
rpc UpdateAccount(UpdateAccountRequest) returns (UpdateAccountResponse) {};
@@ -27,6 +32,6 @@ service AccountService {
2732
rpc CreateCheckout(CreateCheckoutRequest) returns (CreateCheckoutResponse) {};
2833
// api
2934
rpc SetApiSettings(SetApiSettingsRequest) returns (SetApiSettingsResponse) {};
30-
rpc CreateNewApiKey(CreateNewApiKeyRequest)
31-
returns (CreateNewApiKeyResponse) {}
35+
rpc CreateNewAccessToken(CreateNewAccessTokenRequest)
36+
returns (CreateNewAccessTokenResponse) {}
3237
}

proto/account/v1/auth.proto

+1-60
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,12 @@
11
syntax = "proto3";
22
package account;
3-
// https://docs.rs/opaque-ke/latest/opaque_ke/
4-
// Will use opaque-ke for registration and login.
5-
// From opaque-ke we will get a session token. This token can later be used to
6-
// create a JWT token for API usage.
7-
message CreateAccountStartRequest {
8-
bytes oprf = 1; // OPAQUE Registration message.
9-
string email = 2;
10-
string captcha = 3;
11-
}
123

13-
message CreateAccountStartResponse {
14-
bytes oprf = 1; // OPAQUE Registration message.
15-
string session_id = 2;
16-
}
174

18-
message CreateAccountFinishRequest {
19-
string username = 1;
20-
bytes oprf = 2; // OPAQUE Registration message.
21-
string session_id = 3;
22-
bytes public_signing_key = 4; // The signing key that is used by the server to
23-
// verify user signatures.
24-
}
25-
26-
message CreateAccountFinishResponse { string jwt_token = 1; }
27-
28-
message AccountLoginStartRequest {
29-
string email = 1;
30-
bytes oprf = 2; // OPAQUE login message.
31-
}
32-
33-
message AccountLoginStartResponse {
34-
bytes oprf = 1; // OPAQUE login message.
35-
string session_id = 2;
36-
bool is_totp_code_required = 3;
37-
}
38-
39-
message AccountLoginFinishRequest {
40-
bytes oprf = 1; // OPAQUE login message.
41-
string session_id = 2;
42-
optional string totp_code = 3;
43-
}
44-
45-
message AccountLoginFinishResponse { string jwt_token = 1; }
46-
47-
// 2FA Setup and Verification. Will use TOTP. Will require the user to verify
48-
// the 2FA code with verifie message. Until then it's just temporary. Client ->
49-
// SetupTwoFactorAuthenticationRequest -> Server Client <-
50-
// SetupTwoFactorAuthenticationResponse <- Server Client ->
51-
// SetupVerifyTwoFactorAuthenticationRequest -> Server Client <-
52-
// SetupVerifyTwoFactorAuthenticationResponse <- Server
53-
// First the user gets the secrete, the user stores the secrete, the user uses the secrete to compute the first totp code and send that in for verification.
54-
message SetupTwoFactorAuthenticationRequest {}
55-
56-
message SetupTwoFactorAuthenticationResponse { string totp_secrete = 1; }
57-
58-
message SetupTwoFactorAuthenticationVerifyRequest { string totp_code = 1; }
59-
/// Will return a status error message if totp_code is invalid.
60-
message SetupTwoFactorAuthenticationVerifyResponse {}
61-
/// Invalidates the users JWT-token.
62-
message AccountLogoutRequest { string token = 1; }
63-
64-
message AccountLogoutResponse {}
655

666
// OPAQUE Registration.
677
// OPAQUE Login.
688
// message OpaqueRegistration {
699
// string username = 1;
7010

7111
// }
12+

proto/account/v1/login.proto

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
syntax = "proto3";
2+
package account;
3+
4+
5+
message AccountLoginStartRequest {
6+
string email = 1;
7+
bytes oprf = 2; // OPAQUE login message.
8+
}
9+
10+
message AccountLoginStartResponse {
11+
bytes oprf = 1; // OPAQUE login message.
12+
string session_id = 2;
13+
bool is_totp_code_required = 3;
14+
}
15+
16+
message AccountLoginFinishRequest {
17+
bytes oprf = 1; // OPAQUE login message.
18+
string session_id = 2;
19+
optional string totp_code = 3;
20+
}
21+
22+
message AccountLoginFinishResponse { string jwt_token = 1; }
23+
24+
25+
/// Invalidates the users JWT-token.
26+
message AccountLogoutRequest { string token = 1; }
27+
28+
message AccountLogoutResponse {}

proto/account/v1/mfa.proto

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
package account;
3+
4+
// 2FA Setup and Verification. Will use TOTP. Will require the user to verify
5+
// the 2FA code with verifies message. Until then it's just temporary. Client ->
6+
// SetupTwoFactorAuthenticationRequest -> Server Client <-
7+
// SetupTwoFactorAuthenticationResponse <- Server Client ->
8+
// SetupVerifyTwoFactorAuthenticationRequest -> Server Client <-
9+
// SetupVerifyTwoFactorAuthenticationResponse <- Server
10+
// First the user gets the secrete, the user stores the secrete, the user uses the secrete to compute the first totp code and send that in for verification.
11+
message SetupTwoFactorAuthenticationRequest {}
12+
13+
message SetupTwoFactorAuthenticationResponse { string totp_secrete = 1; }
14+
15+
message SetupTwoFactorAuthenticationVerifyRequest { string totp_code = 1; }
16+
/// Will return a status error message if totp_code is invalid.
17+
message SetupTwoFactorAuthenticationVerifyResponse {}

proto/account/v1/registration.proto

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
syntax = "proto3";
2+
package account;
3+
// https://docs.rs/opaque-ke/latest/opaque_ke/
4+
// Will use opaque-ke for registration and login.
5+
// From opaque-ke we will get a session token. This token can later be used to
6+
// create a JWT token for API usage.
7+
message CreateAccountStartRequest {
8+
bytes oprf = 1; // OPAQUE Registration message.
9+
string email = 2;
10+
string captcha = 3;
11+
}
12+
13+
message CreateAccountStartResponse {
14+
bytes oprf = 1; // OPAQUE Registration message.
15+
string session_id = 2;
16+
}
17+
18+
message CreateAccountFinishRequest {
19+
string username = 1;
20+
bytes oprf = 2; // OPAQUE Registration message.
21+
string session_id = 3;
22+
bytes public_signing_key = 4; // The signing key that is used by the server to
23+
// verify user signatures.
24+
}
25+
26+
message CreateAccountFinishResponse { string jwt_token = 1; }

proto/common/v1/storage.proto

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ message StorageOperationBehaviour {
3030
message BucketGuid {
3131
string user_id = 1;
3232
string bucket_id = 2;
33-
}
33+
}
34+

proto/common/v1/types.proto

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
syntax = "proto3";
2+
3+
package common.types;
4+
5+
6+
message UUID {
7+
uint64 most_significant_bits = 1;
8+
uint64 least_significant_bits = 2;
9+
}

proto/engine/v1/engine.proto

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ message StorageEngineDetail {
1010
string average_latency = 3;
1111
string average_throuput = 4;
1212
string average_load = 5;
13+
uint64 capactiy_utilized = 7;
14+
uint64 capacity_available = 8;
1315
}
1416

1517
message GetStorageEnginePaginationResponse {

proto/transcoding/v1/compresion.proto

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
syntax = "proto3";
22
package transcoding.compression;
3+
import "common/v1/storage.proto";
34
message ArchiveCompressionRequest {
45
repeated string from_absolute_paths = 1;
56
string to_absolute_path = 2;
67
string algorithm = 3;
7-
8+
common.storage.StorageOperationBehaviour behaviour = 4;
89
}
910

1011
message ArchiveCompressionResponse {

src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
pub mod backend_api {
33
//include!(concat!(env!("OUT_DIR"), "/backend_api.rs"));
4-
tonic::include_proto!("backend_api");
4+
//tonic::include_proto!("backend_api");
55
}
66

77
pub mod webhook_event {
8-
tonic::include_proto!("webhook_event");
8+
//tonic::include_proto!("webhook_event");
99
}
1010

1111

@@ -14,7 +14,7 @@ pub mod webhook_event {
1414
pub mod tonic {
1515
#[cfg(feature = "metrics")]
1616
pub use opentelemetry_proto::tonic;
17-
#[cfg(feature = "bucket")]
17+
#[cfg(feature = "storage")]
1818
#[path = "storage/v1"]
1919
pub mod storage {
2020

0 commit comments

Comments
 (0)