From 66a6d471d222a484e39a8dda3fce360acd71bdbc Mon Sep 17 00:00:00 2001 From: St4NNi Date: Mon, 17 Jul 2023 11:38:12 +0200 Subject: [PATCH 1/2] feat: Update notifications to reduce complexity requires db call afterwards --- .../services/v2/notification_service.proto | 95 ++++--------------- aruna/api/storage/models/v2/models.proto | 12 ++- .../storage/services/v2/info_service.proto | 19 ++++ .../storage/services/v2/user_service.proto | 22 +++++ 4 files changed, 70 insertions(+), 78 deletions(-) diff --git a/aruna/api/notification/services/v2/notification_service.proto b/aruna/api/notification/services/v2/notification_service.proto index 8182ff82..b0f64e9d 100644 --- a/aruna/api/notification/services/v2/notification_service.proto +++ b/aruna/api/notification/services/v2/notification_service.proto @@ -55,8 +55,8 @@ service EventNotificationService { message Resource { string resource_id = 1; - string resource_name = 2; - string associated_id = 3; + string associated_id = 2; + bool persistent_resource_id = 3; storage.models.v2.ResourceVariant resource_variant = 4; } @@ -118,49 +118,12 @@ message StreamFromDate { google.protobuf.Timestamp timestamp = 1; } message StreamAll {} -enum ResourceEventType { - RESOURCE_EVENT_TYPE_UNSPECIFIED = 0; - RESOURCE_EVENT_TYPE_CREATED = 1; - RESOURCE_EVENT_TYPE_AVAILABLE = 2; - RESOURCE_EVENT_TYPE_UPDATED = 3; - RESOURCE_EVENT_TYPE_DELETED = 4; -} - -message RelationUpdate { - repeated storage.models.v2.Relation add_relations = 2; - repeated storage.models.v2.Relation remove_relations = 3; -} - -message Fields { - repeated string updated_fields = 1; -} - -message ResourceEventContext { - oneof event { - Fields updated_fields = 1; - RelationUpdate relation_updates = 2; - string custom_context = 3; - } -} -enum UserEventType { - USER_EVENT_TYPE_UNSPECIFIED = 0; - USER_EVENT_TYPE_CREATED = 1; - USER_EVENT_TYPE_UPDATED = 2; - USER_EVENT_TYPE_DELETED = 3; -} - -message Token { - string id = 1; - aruna.api.storage.models.v2.Permission permission = 2; -} - -message UserEventContext { - oneof event { - string updated_field = 1; - bool admin = 2; - Token token = 3; - aruna.api.storage.models.v2.Permission permission = 4; - } +enum EventVariant { + EVENT_VARIANT_UNSPECIFIED = 0; + EVENT_VARIANT_CREATED = 1; + EVENT_VARIANT_AVAILABLE = 2; + EVENT_VARIANT_UPDATED = 3; + EVENT_VARIANT_DELETED = 4; } message EventMessage { @@ -173,17 +136,14 @@ message EventMessage { message ResourceEvent { Resource resource = 1; - ResourceEventType event_type = 2; - ResourceEventContext context = 3; - Reply reply = 4; + EventVariant event_variant = 2; + Reply reply = 3; } message UserEvent { string user_id = 1; - string user_name = 2; - UserEventType event_type = 3; - UserEventContext context = 4; - Reply reply = 5; + EventVariant event_variant = 2; + Reply reply = 3; } message Reply { @@ -192,22 +152,6 @@ message Reply { string hmac = 3; } - - -message DataproxyInfo { - string endpoint_id = 1; - // Endpoint name - string name = 2; - // Endpoint type - storage.models.v2.EndpointVariant ep_variant = 3; - // Is this endpoint public - bool is_public = 4; - // required public_key - string pubkey = 5; - // url - string url = 6; -} - message ScheduledDowntime { string location = 1; string component = 2; @@ -227,12 +171,13 @@ message NewPubkey { message AnouncementEvent { oneof event_variant { - DataproxyInfo new_data_proxy = 1; - DataproxyInfo remove_data_proxy = 2; - DataproxyInfo update_data_proxy = 3; - ScheduledDowntime downtime = 4; - NewVersion version = 5; - NewPubkey pubkey = 6; + string new_data_proxy_id = 1; + string remove_data_proxy_id = 2; + string update_data_proxy_id = 3; + bool new_pubkey = 4; + bool remove_pubkey = 5; + ScheduledDowntime downtime = 6; + NewVersion version = 7; } - Reply reply = 7; + Reply reply = 8; } \ No newline at end of file diff --git a/aruna/api/storage/models/v2/models.proto b/aruna/api/storage/models/v2/models.proto index a2b289e9..1c4d345b 100644 --- a/aruna/api/storage/models/v2/models.proto +++ b/aruna/api/storage/models/v2/models.proto @@ -119,11 +119,16 @@ enum ResourceVariant { // ------------- USERS & PERMISSIONS ----------------------- +message ExternalId { + string external_id = 1; + string idp = 2; +} + message User { // Internal Aruna UserID string id = 1; // Oidc subject ID - repeated string external_id = 2; + repeated ExternalId external_ids = 2; // (optional) User display_name string display_name = 3; // Is the user activated @@ -164,8 +169,9 @@ message CustomAttributes { message UserAttributes { bool global_admin = 1; bool service_account = 2; - repeated CustomAttributes custom_attributes = 3; - repeated Permission personal_permissions = 4; + repeated Token tokens = 3; + repeated CustomAttributes custom_attributes = 4; + repeated Permission personal_permissions = 5; } // --------------- RELATION / KEYVALUES ------------------- diff --git a/aruna/api/storage/services/v2/info_service.proto b/aruna/api/storage/services/v2/info_service.proto index dd1ec00d..0b8826ef 100644 --- a/aruna/api/storage/services/v2/info_service.proto +++ b/aruna/api/storage/services/v2/info_service.proto @@ -38,6 +38,13 @@ service StorageStatusService { get : "/v2/info/status" }; } + + + rpc GetPubkeys(GetPubkeysRequest) returns (GetPubkeysResponse) { + option (google.api.http) = { + get : "/v2/info/pubkeys" + }; + } } @@ -89,4 +96,16 @@ message ComponentStatus { message GetStorageStatusResponse { // List of all locations and their component / status repeated LocationStatus location_status = 1; +} + +message GetPubkeysRequest {} + +message Pubkey { + int32 id = 1; + string key = 2; + string location = 3; +} + +message GetPubkeysResponse { + repeated Pubkey pubkeys = 1; } \ No newline at end of file diff --git a/aruna/api/storage/services/v2/user_service.proto b/aruna/api/storage/services/v2/user_service.proto index b59d968c..1be20248 100644 --- a/aruna/api/storage/services/v2/user_service.proto +++ b/aruna/api/storage/services/v2/user_service.proto @@ -123,6 +123,18 @@ service UserService { }; } + // GetUserRequest + // + // Status: STABLE + // + // This is a request that returns the user information of the + // current user or if invoked by an admin from another user + rpc GetUser(GetUserRedactedRequest) returns (GetUserRedactedResponse) { + option (google.api.http) = { + get : "/v2/user/redacted" + }; + } + // UpdateUserDisplayName // // Status: STABLE @@ -264,6 +276,16 @@ message GetUserResponse { storage.models.v2.User user = 1; } +message GetUserRedactedRequest { + // Optional user_id + string user_id = 1; +} + +message GetUserRedactedResponse { + // User info + storage.models.v2.User user = 1; +} + message UpdateUserDisplayNameRequest { // New display name string new_display_name = 1; From 9a7c36eca2ba6c0d0522977edc8660482041587d Mon Sep 17 00:00:00 2001 From: St4NNi Date: Mon, 17 Jul 2023 12:10:40 +0200 Subject: [PATCH 2/2] fix: Fixed missing name in GetUserRedacted --- aruna/api/storage/services/v2/user_service.proto | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aruna/api/storage/services/v2/user_service.proto b/aruna/api/storage/services/v2/user_service.proto index 1be20248..96ca5390 100644 --- a/aruna/api/storage/services/v2/user_service.proto +++ b/aruna/api/storage/services/v2/user_service.proto @@ -123,13 +123,14 @@ service UserService { }; } - // GetUserRequest + // GetUserRequestRedacted // // Status: STABLE // // This is a request that returns the user information of the // current user or if invoked by an admin from another user - rpc GetUser(GetUserRedactedRequest) returns (GetUserRedactedResponse) { + // Redacts personal information like name or email + rpc GetUserRedacted(GetUserRedactedRequest) returns (GetUserRedactedResponse) { option (google.api.http) = { get : "/v2/user/redacted" };