Skip to content

Commit 45c04ca

Browse files
trshJanis Taranda
andauthored
feat: 418 Impersonation (#181)
* feat: 418 Impersonation * fix: 418 added comment for subject field * fix: 418 impersonated_by moved to token data, impersonate responses now return token data * fix: 418 fixing request type for end impersonation --------- Co-authored-by: Janis Taranda <janis.taranda@n-fuse.co>
1 parent 47d4d6f commit 45c04ca

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

packages/protos/io/restorecommerce/auth.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ message Tokens {
2323
optional bool interactive = 6;
2424
optional google.protobuf.Timestamp last_login = 7;
2525
optional string client_id = 8;
26+
optional string impersonated_by = 9; // ID of the impersonator
2627
}
2728

2829
message HierarchicalScope {

packages/protos/io/restorecommerce/user.proto

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ service UserService {
5858
rpc ResetTOTP (ResetTOTPRequest) returns (io.restorecommerce.status.OperationStatusObj);
5959
rpc MfaStatus (MfaStatusRequest) returns (MfaStatusResponse);
6060
rpc GetUnauthenticatedSubjectTokenForTenant(TenantRequest) returns (TenantResponse);
61+
rpc Impersonate (ImpersonateRequest) returns (ImpersonateResponse);
62+
rpc EndImpersonation (EndImpersonationRequest) returns (EndImpersonateResponse);
6163
}
6264

6365
/**
@@ -70,6 +72,33 @@ message LoginRequest {
7072
optional string token = 3;
7173
}
7274

75+
message ImpersonateRequest {
76+
optional string identifier = 1; // Username to impersonate
77+
optional io.restorecommerce.auth.Subject subject = 2; // Impersonator's subject
78+
}
79+
80+
message AccessTokenData {
81+
optional string access_token = 1;
82+
optional google.protobuf.Timestamp expires_in = 2;
83+
optional string token_type = 3;
84+
optional string scope = 4;
85+
optional string token_name = 5;
86+
}
87+
88+
message ImpersonateResponse {
89+
optional io.restorecommerce.status.Status status = 1;
90+
optional AccessTokenData payload = 2;
91+
}
92+
93+
message EndImpersonationRequest {
94+
optional io.restorecommerce.auth.Subject subject = 1;
95+
}
96+
97+
message EndImpersonateResponse {
98+
optional io.restorecommerce.status.Status status = 1;
99+
optional AccessTokenData payload = 2;
100+
}
101+
73102
message LoginResponse {
74103
optional User payload = 1;
75104
optional io.restorecommerce.status.Status status = 2;

0 commit comments

Comments
 (0)