fix server level impersonation (#14909)
This commit is contained in:
@@ -707,7 +707,7 @@ export class AuthResolver {
|
||||
|
||||
const hasServerLevelImpersonatePermission =
|
||||
impersonatorUserWorkspace.user.canImpersonate === true &&
|
||||
impersonatorUserWorkspace.workspace.allowImpersonation === true;
|
||||
toImpersonateUserWorkspace.workspace.allowImpersonation === true;
|
||||
|
||||
if (isServerLevelImpersonation) {
|
||||
if (!hasServerLevelImpersonatePermission) {
|
||||
|
||||
@@ -124,10 +124,7 @@ export class JwtAuthStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
}
|
||||
|
||||
if (payload.isImpersonating === true) {
|
||||
context.impersonationContext = await this.validateImpersonation(
|
||||
payload,
|
||||
workspace,
|
||||
);
|
||||
context.impersonationContext = await this.validateImpersonation(payload);
|
||||
}
|
||||
|
||||
const userId = payload.sub ?? payload.userId;
|
||||
@@ -179,10 +176,7 @@ export class JwtAuthStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
return context;
|
||||
}
|
||||
|
||||
private async validateImpersonation(
|
||||
payload: AccessTokenJwtPayload,
|
||||
workspace: Workspace,
|
||||
) {
|
||||
private async validateImpersonation(payload: AccessTokenJwtPayload) {
|
||||
// Validate required impersonation fields
|
||||
if (
|
||||
!payload.impersonatorUserWorkspaceId ||
|
||||
@@ -239,7 +233,7 @@ export class JwtAuthStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||
|
||||
const hasServerLevelImpersonatePermission =
|
||||
impersonatorUserWorkspace.user.canImpersonate === true &&
|
||||
workspace.allowImpersonation === true;
|
||||
impersonatedUserWorkspace.workspace.allowImpersonation === true;
|
||||
|
||||
if (isServerLevelImpersonation) {
|
||||
if (!hasServerLevelImpersonatePermission)
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ export class ImpersonationService {
|
||||
|
||||
const hasServerLevelImpersonatePermission =
|
||||
impersonatorUserWorkspace.user.canImpersonate === true &&
|
||||
impersonatorUserWorkspace.workspace.allowImpersonation === true;
|
||||
toImpersonateUserWorkspace.workspace.allowImpersonation === true;
|
||||
|
||||
if (isServerLevelImpersonation) {
|
||||
if (!hasServerLevelImpersonatePermission) {
|
||||
|
||||
Reference in New Issue
Block a user