Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/35220-remove-pending-sso-user-action.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/platform-objects': patch
---

feat(platform-objects): Setup → Users can take a pending person back out on a managed environment

Clause-②: no
Metadata-protocol: none

`sys_user` gains a row action, `remove_sso_user` (Remove Pending User), on the Users list row and the user record header. It posts the row's id as `userId` to plugin-auth's `admin/remove-sso-user`, which removes a person added ahead of their first sign-in and cancels their invitation at the hosting organization. It is offered only where that door answers: to a platform administrator, on a cloud-managed environment, on a row that is still pending (`source` is `idp_pending`). A confirmation dialog asks first and says that no one is removed when the person has signed in meanwhile or the hosting organization cannot be reached. The door itself is unchanged. Its labels are added to the translation bundles, translated for zh-CN, ja-JP and es-ES.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const arObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "Remove Pending User",
confirmText: "Remove this person, who has not signed in yet, and cancel their invitation? If they have signed in meanwhile, or the hosting organization cannot be reached, no one is removed.",
successMessage: "Pending user removed"
},
set_user_password: {
label: "تعيين كلمة المرور",
successMessage: "تم تحديث كلمة المرور",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,8 @@ export const arGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81",
"objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b",
"objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222",
"objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb",
"objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98",
"objects.sys_user._actions.remove_sso_user.successMessage": "45facf16a8b5ebc7",
"objects.sys_user.fields.source.options.idp_pending": "3751093c5b65b072",
};
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const deObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "Remove Pending User",
confirmText: "Remove this person, who has not signed in yet, and cancel their invitation? If they have signed in meanwhile, or the hosting organization cannot be reached, no one is removed.",
successMessage: "Pending user removed"
},
set_user_password: {
label: "Passwort festlegen",
successMessage: "Passwort aktualisiert",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ export const deGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_user._actions.add_sso_user.params.positions.label": "9a24c02e441eb0b4",
"objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222",
"objects.sys_user._actions.register_service_account.params.name.label": "5274417ff1ccaf01",
"objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb",
"objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98",
"objects.sys_user._actions.remove_sso_user.successMessage": "45facf16a8b5ebc7",
"objects.sys_user.fields.name.label": "5274417ff1ccaf01",
"objects.sys_user.fields.principal_kind.options.human": "ed18d3469e10aef2",
"objects.sys_user.fields.source.options.idp_pending": "3751093c5b65b072",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const enObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "Remove Pending User",
confirmText: "Remove this person, who has not signed in yet, and cancel their invitation? If they have signed in meanwhile, or the hosting organization cannot be reached, no one is removed.",
successMessage: "Pending user removed"
},
set_user_password: {
label: "Set Password",
successMessage: "Password updated",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const esESObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "Quitar usuario pendiente",
confirmText: "¿Quitar a esta persona, que aún no ha iniciado sesión, y cancelar su invitación? Si ha iniciado sesión mientras tanto o no se puede contactar con la organización anfitriona, no se quita a nadie.",
successMessage: "Usuario pendiente quitado"
},
set_user_password: {
label: "Establecer contraseña",
successMessage: "Contraseña actualizada",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const frObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "Remove Pending User",
confirmText: "Remove this person, who has not signed in yet, and cancel their invitation? If they have signed in meanwhile, or the hosting organization cannot be reached, no one is removed.",
successMessage: "Pending user removed"
},
set_user_password: {
label: "Définir le mot de passe",
successMessage: "Mot de passe mis à jour",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,8 @@ export const frGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b",
"objects.sys_two_factor.fields.secret.label": "03cb32e33fa5cc45",
"objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222",
"objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb",
"objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98",
"objects.sys_user._actions.remove_sso_user.successMessage": "45facf16a8b5ebc7",
"objects.sys_user.fields.source.options.idp_pending": "3751093c5b65b072",
};
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const jaJPObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "保留中のユーザーを削除",
confirmText: "まだサインインしていないこのユーザーを削除し、招待を取り消しますか?その間にサインインした場合、またはホスト組織に接続できない場合は、誰も削除されません。",
successMessage: "保留中のユーザーを削除しました"
},
set_user_password: {
label: "パスワードを設定",
successMessage: "パスワードを更新しました",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const koObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "Remove Pending User",
confirmText: "Remove this person, who has not signed in yet, and cancel their invitation? If they have signed in meanwhile, or the hosting organization cannot be reached, no one is removed.",
successMessage: "Pending user removed"
},
set_user_password: {
label: "비밀번호 설정",
successMessage: "비밀번호 업데이트됨",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,8 @@ export const koGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81",
"objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b",
"objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222",
"objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb",
"objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98",
"objects.sys_user._actions.remove_sso_user.successMessage": "45facf16a8b5ebc7",
"objects.sys_user.fields.source.options.idp_pending": "3751093c5b65b072",
};
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const ptBRObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "Remove Pending User",
confirmText: "Remove this person, who has not signed in yet, and cancel their invitation? If they have signed in meanwhile, or the hosting organization cannot be reached, no one is removed.",
successMessage: "Pending user removed"
},
set_user_password: {
label: "Definir senha",
successMessage: "Senha atualizada",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,8 @@ export const ptBRGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81",
"objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b",
"objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222",
"objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb",
"objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98",
"objects.sys_user._actions.remove_sso_user.successMessage": "45facf16a8b5ebc7",
"objects.sys_user.fields.source.options.idp_pending": "3751093c5b65b072",
};
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const ruObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "Remove Pending User",
confirmText: "Remove this person, who has not signed in yet, and cancel their invitation? If they have signed in meanwhile, or the hosting organization cannot be reached, no one is removed.",
successMessage: "Pending user removed"
},
set_user_password: {
label: "Задать пароль",
successMessage: "Пароль обновлён",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@ export const ruGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81",
"objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b",
"objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222",
"objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb",
"objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98",
"objects.sys_user._actions.remove_sso_user.successMessage": "45facf16a8b5ebc7",
"objects.sys_user.fields.source.options.idp_pending": "3751093c5b65b072",
};
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const zhCNObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "移除待登录用户",
confirmText: "移除这位尚未登录的人员并取消其邀请?如果对方在此期间已经登录,或无法联系到托管组织,则不会移除任何人。",
successMessage: "已移除待登录用户"
},
set_user_password: {
label: "设置密码",
successMessage: "密码已更新",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ export const zhHantObjects: NonNullable<TranslationData['objects']> = {
}
}
},
remove_sso_user: {
label: "Remove Pending User",
confirmText: "Remove this person, who has not signed in yet, and cancel their invitation? If they have signed in meanwhile, or the hosting organization cannot be reached, no one is removed.",
successMessage: "Pending user removed"
},
set_user_password: {
label: "設定密碼",
successMessage: "密碼已更新",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,8 @@ export const zhHantGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_sso_provider.fields.sign_out_of_idp.help": "ab8ff5fce3001c81",
"objects.sys_sso_provider.fields.sign_out_of_idp.label": "212587b8191bb91b",
"objects.sys_user._actions.import_sso_users.params.csv.label": "bfb77802b66a9222",
"objects.sys_user._actions.remove_sso_user.confirmText": "843b7846781ae0eb",
"objects.sys_user._actions.remove_sso_user.label": "27e40f055ed9dc98",
"objects.sys_user._actions.remove_sso_user.successMessage": "45facf16a8b5ebc7",
"objects.sys_user.fields.source.options.idp_pending": "3751093c5b65b072",
};
1 change: 1 addition & 0 deletions packages/platform-objects/src/feature-gate-guard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ function resolveGatedInput(path: string): { visibleSource: string | undefined }
const SHOWN_WHEN_ON: ReadonlyArray<[string, PublicAuthFeatureName]> = [
['sys_user.actions.add_sso_user', 'cloudManaged'],
['sys_user.actions.import_sso_users', 'cloudManaged'],
['sys_user.actions.remove_sso_user', 'cloudManaged'],
];

describe('feature-gate completeness guard (#2874)', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* Setup → Users' Remove Pending User (`sys_user.remove_sso_user`) takes back a
* person added on a cloud-managed environment who has not signed in yet, and
* so cancels their invitation. Its door, plugin-auth's
* `admin/remove-sso-user`, answers only a platform administrator, only on a
* cloud-managed environment, and only for a row that is still pending
* (`source == 'idp_pending'`). So the row action is offered exactly there:
* pending row AND managed flag on AND the platform-admin standing. Each
* CONTROL drops one of the three and the action is hidden, never faulted.
*
* The predicate is EVALUATED through the canonical engine the console
* delegates to (`@objectstack/formula`) on the parsed object, as its sibling
* `cloud-managed-visibility.test.ts` does for Add / Import.
*/

import { describe, expect, it } from 'vitest';
import { celEngine } from '@objectstack/formula';
import { SysUser } from './sys-user.object.js';

const ADMIN = { id: 'u_admin', email: 'admin@example.com', positions: ['org_owner'], isPlatformAdmin: true };
/** Every grade below the rung: the organization owner. */
const ORG_OWNER = { id: 'u_owner', email: 'owner@example.com', positions: ['org_owner'], isPlatformAdmin: false };

const MANAGED = { organization: true, admin: true, cloudManaged: true };
const PENDING_ROW = { id: 'usr_pending', email: 'typo@example.com', source: 'idp_pending' };

function declared(): Record<string, unknown> {
const action = ((SysUser.actions ?? []) as Array<Record<string, unknown>>).find((a) => a.name === 'remove_sso_user');
if (!action) throw new Error('sys_user declares no action named "remove_sso_user"');
return action;
}

function visibleSource(): string {
const raw = declared().visible;
const source = typeof raw === 'string' ? raw : (raw as { source?: unknown } | undefined)?.source;
if (typeof source !== 'string') throw new Error('remove_sso_user has no CEL source');
return source;
}

/** The verdict, or the fault spelled out so a faulting predicate fails loudly. */
function offered(subject: typeof ADMIN, record: Record<string, unknown>, features: Record<string, unknown>): boolean | string {
const r = celEngine.evaluate(
{ dialect: 'cel', source: visibleSource() },
{ record, extra: { current_user: subject, user: subject, ctx: { user: subject }, features } },
);
if (!r.ok) return `FAULT ${r.error.message.split('\n')[0].trim()}`;
return typeof r.value === 'boolean' ? r.value : `NON-BOOLEAN ${JSON.stringify(r.value)}`;
}

describe('Setup → Users offers Remove Pending User on a pending row, managed, to a platform admin only', () => {
it('is a row action that posts the row id to the remove-sso-user door behind a confirmation', () => {
const action = declared();
expect(action.type).toBe('api');
expect(action.target).toBe('/api/v1/auth/admin/remove-sso-user');
expect(action.recordIdParam).toBe('userId');
expect(action.locations).toEqual(['list_item', 'record_header']);
// A confirmation is asked first (the parsed template, whatever its words).
expect((action.confirmText as { source?: unknown } | undefined)?.source).toEqual(expect.any(String));
// The door mounts with or without the better-auth admin plugin, as Add / Import do.
expect(action.requiresFeature).toBeUndefined();
// No params: the door's body is the closed key set `{ userId }`.
expect(action.params ?? []).toEqual([]);
});

it('is offered to the platform admin on a pending row while the environment is cloud-managed', () => {
expect(offered(ADMIN, PENDING_ROW, MANAGED)).toBe(true);
});

it.each([
['a person who has signed in (idp_provisioned)', { ...PENDING_ROW, source: 'idp_provisioned' }],
['a local account (env_native)', { ...PENDING_ROW, source: 'env_native' }],
['a row the console did not project source for', { id: 'usr_pending', email: 'typo@example.com' }],
])('CONTROL: is hidden on %s', (_row, record) => {
expect(offered(ADMIN, record, MANAGED)).toBe(false);
});

it.each([
['the flag is off', { ...MANAGED, cloudManaged: false }],
['no flag is served', { organization: true, admin: true }],
])('CONTROL: is hidden on a pending row when %s', (_case, features) => {
expect(offered(ADMIN, PENDING_ROW, features)).toBe(false);
});

it('CONTROL: is hidden from an organization owner below the platform-admin rung, on a pending managed row', () => {
expect(offered(ORG_OWNER, PENDING_ROW, MANAGED)).toBe(false);
});
});
34 changes: 34 additions & 0 deletions packages/platform-objects/src/identity/sys-user.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ const SERVICE_ACCOUNT_ADMIN_VISIBLE = [
const MANAGED_ADD_PERSON_VISIBLE =
'current_user.isPlatformAdmin == true && has(features.cloudManaged) && features.cloudManaged == true';

/**
* Who is offered `remove_sso_user`, and on which row: the same standing and
* managed flag as Add / Import, then a row that is still pending
* (`source == 'idp_pending'`), the one row its door removes. Any other row is
* answered `409` there (a person who has signed in is deactivated instead).
* `has()` keeps it hidden on a row the console did not project `source` for.
*/
const MANAGED_REMOVE_PENDING_PERSON_VISIBLE =
`${MANAGED_ADD_PERSON_VISIBLE} && has(record.source) && record.source == 'idp_pending'`;

const TEMPORARY_PASSWORD_LABEL = 'Temporary password: copy it now, it is shown only once and never stored';

/**
Expand Down Expand Up @@ -583,6 +593,30 @@ export const SysUser = ObjectSchema.create({
],
},
},
// The undo of the two above: take a pending person back out, which also
// cancels their invitation. The door is plugin-auth's
// `admin/remove-sso-user` (`{ userId }`), platform-admin gated, answering
// only on a managed environment and only for a row that is still pending;
// it asks the hosting organisation first and removes no one when that
// organisation cannot be reached or refuses. No params, so the question
// rides `confirmText`. No `ai` block, as for its siblings.
{
name: 'remove_sso_user',
label: 'Remove Pending User',
icon: 'user-minus',
variant: 'danger',
locations: ['list_item', 'record_header'],
type: 'api',
target: '/api/v1/auth/admin/remove-sso-user',
requiredPermissions: [...PLATFORM_ADMIN_USERS_GATE],
visible: MANAGED_REMOVE_PENDING_PERSON_VISIBLE,
recordIdParam: 'userId',
confirmText:
'Remove this person, who has not signed in yet, and cancel their invitation? '
+ 'If they have signed in meanwhile, or the hosting organization cannot be reached, no one is removed.',
successMessage: 'Pending user removed',
refreshAfter: true,
},
{
name: 'set_user_password',
label: 'Set Password',
Expand Down
Loading