fix server level impersonation (#14909)

This commit is contained in:
Etienne
2025-10-06 14:18:20 +02:00
committed by GitHub
parent 6f4c12922b
commit c1671c6ff6
3 changed files with 5 additions and 11 deletions
@@ -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)
@@ -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) {