feat: extend session search service (#6746)

* feat: extend session search service (#6029)

add two more searching criteria - human user id and session creation date

optional sorting by the session creation date

* fix: use correct column identifier

* fix: implement Col()

* chore: fix unit tests

* chore: fix linter warnings

---------

Co-authored-by: Fabi <fabienne@zitadel.com>
This commit is contained in:
sp132
2023-11-08 12:32:13 +02:00
committed by GitHub
parent 0d3788b757
commit 9a708b1b78
7 changed files with 251 additions and 46 deletions

View File

@@ -92,7 +92,14 @@ enum TextQueryMethod {
TEXT_QUERY_METHOD_ENDS_WITH_IGNORE_CASE = 7;
}
enum ListQueryMethod {
LIST_QUERY_METHOD_IN = 0;
}
enum TimestampQueryMethod {
TIMESTAMP_QUERY_METHOD_EQUALS = 0;
TIMESTAMP_QUERY_METHOD_GREATER = 1;
TIMESTAMP_QUERY_METHOD_GREATER_OR_EQUALS = 2;
TIMESTAMP_QUERY_METHOD_LESS = 3;
TIMESTAMP_QUERY_METHOD_LESS_OR_EQUALS = 4;
}

View File

@@ -2,6 +2,7 @@ syntax = "proto3";
package zitadel.session.v2beta;
import "zitadel/object.proto";
import "google/protobuf/timestamp.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "validate/validate.proto";
@@ -137,6 +138,8 @@ message SearchQuery {
option (validate.required) = true;
IDsQuery ids_query = 1;
UserIDQuery user_id_query = 2;
CreationDateQuery creation_date_query = 3;
}
}
@@ -144,6 +147,20 @@ message IDsQuery {
repeated string ids = 1;
}
message UserIDQuery {
string id = 1;
}
message CreationDateQuery {
google.protobuf.Timestamp creation_date = 1;
zitadel.v1.TimestampQueryMethod method = 2 [
(validate.rules).enum.defined_only = true,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "defines which timestamp comparison method is used";
}
];
}
message UserAgent {
optional string fingerprint_id = 1;
optional string ip = 2;
@@ -157,4 +174,9 @@ message UserAgent {
repeated string values = 1;
}
map<string,HeaderValues> header = 4;
}
enum SessionFieldName {
SESSION_FIELD_NAME_UNSPECIFIED = 0;
SESSION_FIELD_NAME_CREATION_DATE = 1;
}

View File

@@ -248,6 +248,7 @@ service SessionService {
message ListSessionsRequest{
zitadel.object.v2beta.ListQuery query = 1;
repeated SearchQuery queries = 2;
zitadel.session.v2beta.SessionFieldName sorting_column = 3;
}
message ListSessionsResponse{