diff --git a/.changeset/33758-hide-resend-invitation-cloud-managed.md b/.changeset/33758-hide-resend-invitation-cloud-managed.md new file mode 100644 index 00000000000..72005e92e11 --- /dev/null +++ b/.changeset/33758-hide-resend-invitation-cloud-managed.md @@ -0,0 +1,9 @@ +--- +'@objectstack/platform-objects': patch +'@objectstack/spec': patch +--- + +Clause-②: no +Metadata-protocol: none + +Setup → Invitations no longer offers **Resend Invitation** on a cloud-managed environment. A resend is a call to invite-member, which a cloud-managed environment refuses with `409 RESOURCE_CONFLICT`, so the action now carries the same `features.cloudManaged != true` gate as the four Invite User mirrors and Copy Invite Link, and is booked in `PUBLIC_AUTH_FEATURES.cloudManaged.gatedInputs`. Off a managed environment it is offered exactly as before. diff --git a/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts b/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts index 6d2fe3dac83..cf214fa6366 100644 --- a/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts +++ b/packages/platform-objects/src/identity/cloud-managed-visibility.test.ts @@ -6,7 +6,9 @@ * its people arrive from the organisation's identity provider. Six actions are * hidden while the flag is on — the four `invite_user` mirrors, `create_user` * and `set_user_password` — and each is offered as before when the flag is - * off (ruling 6341690661 on #25083, Q3 A and Q4 A). + * off (ruling 6341690661 on #25083, Q3 A and Q4 A). `resend_invitation` + * rides the invite mirrors' door, so it is hidden the same way (its own + * block below). * * Not pinned here: a payload that omits the flag. plugin-auth's drift guard * holds the served boolean key set stable, and this engine faults on ANY @@ -76,6 +78,42 @@ describe('features.cloudManaged hides the six doors that add people', () => { }); }); +/** + * `sys_invitation.resend_invitation` is not a door that adds a person, so it + * is not among the six above, but it rides the same door: a resend IS a call + * to invite-member, which a cloud-managed environment refuses (`409 + * RESOURCE_CONFLICT`, resends included). So it carries the same gate as the + * invite mirrors: hidden while managed, offered as before on a pending row + * (unexpired or past its `expires_at`) when the flag is off. + */ +describe('features.cloudManaged hides Resend Invitation, whose door it refuses', () => { + const resendOffered = (record: Record, features: Record): boolean | string => { + const r = celEngine.evaluate( + { dialect: 'cel', source: visibleOf(SysInvitation, 'resend_invitation') }, + { record, extra: { current_user: ADMIN, user: ADMIN, ctx: { user: ADMIN }, 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)}`; + }; + const DAY_MS = 24 * 60 * 60 * 1000; + const ROWS: ReadonlyArray<[string, Record]> = [ + ['an unexpired pending row', { id: 'inv_1', status: 'pending', email: 'b@example.com', role: 'member', expires_at: new Date(Date.now() + DAY_MS).toISOString() }], + ['a pending row past its expires_at', { id: 'inv_1', status: 'pending', email: 'b@example.com', role: 'member', expires_at: new Date(Date.now() - DAY_MS).toISOString() }], + ]; + + it.each(ROWS)('is hidden on %s while the environment is cloud-managed', (_row, record) => { + expect(resendOffered(record, { ...OTHER_FLAGS, cloudManaged: true })).toBe(false); + }); + + it.each(ROWS)('is offered on %s as before when the flag is off', (_row, record) => { + expect(resendOffered(record, { ...OTHER_FLAGS, cloudManaged: false })).toBe(true); + }); + + it('keeps its organization gate: off hides it whatever cloudManaged says', () => { + expect(resendOffered(ROWS[0][1], { organization: false, admin: true, cloudManaged: false })).toBe(false); + }); +}); + /** * The managed counterparts (cloud#4465 child 1b): `add_sso_user` and * `import_sso_users` add a PENDING person through plugin-auth's diff --git a/packages/platform-objects/src/identity/sys-invitation.object.ts b/packages/platform-objects/src/identity/sys-invitation.object.ts index bc61c78d037..81560437a0c 100644 --- a/packages/platform-objects/src/identity/sys-invitation.object.ts +++ b/packages/platform-objects/src/identity/sys-invitation.object.ts @@ -160,6 +160,11 @@ export const SysInvitation = ObjectSchema.create({ type: 'api', target: '/api/v1/auth/organization/invite-member', bodyExtra: { resend: true }, + // Hidden while cloud-managed, as the four invite mirrors and + // `copy_invitation_link` are: a resend IS a call to invite-member, + // which a managed environment refuses outright (409, resends + // included — plugin-auth's `auth-manager-before-hook.ts`). + visible: 'features.cloudManaged != true', requiresFeature: 'organization', // A resend IS a call to invite-member, so it is reached by the grades // that reach that endpoint — delegated_admin included. diff --git a/packages/platform-objects/src/platform-objects.test.ts b/packages/platform-objects/src/platform-objects.test.ts index 29b8f99bcb3..b83b2c01f77 100644 --- a/packages/platform-objects/src/platform-objects.test.ts +++ b/packages/platform-objects/src/platform-objects.test.ts @@ -786,7 +786,7 @@ describe('feature-gate lowering matrix (#2874)', () => { ['SysMember', SysMember, 'transfer_ownership', `((has(record.role) && record.role != 'owner') && ${OWNER}) && ${ORG}`], ['SysInvitation', SysInvitation, 'invite_user', `((${MANAGED}) && ${INVITE}) && ${ORG}`], ['SysInvitation', SysInvitation, 'cancel_invitation', `${ADMINS} && ${ORG}`], - ['SysInvitation', SysInvitation, 'resend_invitation', `${INVITE} && ${ORG}`], + ['SysInvitation', SysInvitation, 'resend_invitation', `((${MANAGED}) && ${INVITE}) && ${ORG}`], ['SysTeam', SysTeam, 'create_team', `${ADMINS} && ${ORG}`], ['SysTeam', SysTeam, 'update_team', `${ADMINS} && ${ORG}`], ['SysTeam', SysTeam, 'remove_team', `${ADMINS} && ${ORG}`], diff --git a/packages/spec/src/kernel/public-auth-features.ts b/packages/spec/src/kernel/public-auth-features.ts index a2fc80056ea..f5670d97b4f 100644 --- a/packages/spec/src/kernel/public-auth-features.ts +++ b/packages/spec/src/kernel/public-auth-features.ts @@ -294,6 +294,8 @@ export const PUBLIC_AUTH_FEATURES = { 'sys_member.actions.invite_user', 'sys_invitation.actions.invite_user', 'sys_organization.actions.invite_user', + // A resend is a call to invite-member, which refuses it here. + 'sys_invitation.actions.resend_invitation', // [#27843] The invitation's accept link: no invitation is handed out here. 'sys_invitation.actions.copy_invitation_link', 'sys_user.actions.create_user',