@crombolo/api-management 0.70.0 → 0.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/api-management",
3
- "version": "0.70.0",
3
+ "version": "0.72.0",
4
4
  "description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Umbraco-compatible Management API handlers for crombolo.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -29,8 +29,8 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@crombolo/content": "0.70.0",
33
- "@crombolo/contracts": "0.70.0",
34
- "@crombolo/core": "0.70.0"
32
+ "@crombolo/content": "0.72.0",
33
+ "@crombolo/contracts": "0.72.0",
34
+ "@crombolo/core": "0.72.0"
35
35
  }
36
36
  }
@@ -106,6 +106,11 @@ const USER_PROBLEMS: Partial<Record<UserStatus, [number, string, string]>> = {
106
106
  'The admin group must have at least one user.',
107
107
  ],
108
108
  CannotDelete: [400, 'Cannot delete', "The site's built-in administrator cannot be deleted."],
109
+ ManagedOutside: [
110
+ 403,
111
+ 'Managed outside this site',
112
+ "This site's people come from a directory outside it: add, change or remove them there.",
113
+ ],
109
114
  NotGroupOwner: [
110
115
  403,
111
116
  "You don't own that group",
@@ -178,6 +183,11 @@ const GROUP_PROBLEMS: Partial<Record<UserGroupStatus, [number, string, string]>>
178
183
  'Admin group cannot be empty',
179
184
  'The admin group must have at least one user.',
180
185
  ],
186
+ ManagedOutside: [
187
+ 403,
188
+ 'Managed outside this site',
189
+ 'Whom this group holds comes from a directory outside the site: change it there.',
190
+ ],
181
191
  }
182
192
 
183
193
  function groupStatusResponse(status: UserGroupStatus): Response | undefined {
@@ -552,6 +562,8 @@ function registerUsers(router: ManagementApiRouter, users: UserPort): void {
552
562
  // Who may manage this user, by the same rule every user operation follows.
553
563
  const found = await users.get(me(ctx), ctx.params.id as string)
554
564
  if (found.status !== 'Success') return status(found.status)
565
+ const may = (await users.mayManage?.(me(ctx), ctx.params.id as string)) ?? 'Success'
566
+ if (may !== 'Success') return status(may)
555
567
  await provider.reset(ctx.params.id as string)
556
568
  return ok()
557
569
  })
@@ -45,6 +45,8 @@ export type UserStatus =
45
45
  | 'AdminGroupCannotBeEmpty'
46
46
  /** The site's built-in administrator, who is never deleted. */
47
47
  | 'CannotDelete'
48
+ /** Crombolo: the site's people come from a directory outside it (story 389). */
49
+ | 'ManagedOutside'
48
50
 
49
51
  export type UserOrder =
50
52
  | 'UserName'
@@ -141,6 +143,8 @@ export interface UserPort {
141
143
  newPassword: string,
142
144
  oldPassword: string | null,
143
145
  ): Promise<UserStatus>
146
+ /** Whether the caller may manage this user's sign-in, such as resetting their two-factor (story 389). */
147
+ mayManage?(principal: Principal, key: string): Promise<UserStatus>
144
148
  /** A generated password, which the backoffice shows once. */
145
149
  resetPassword(principal: Principal, key: string): Promise<Result<string>>
146
150
  setAvatar(principal: Principal, key: string, temporaryFileId: string): Promise<UserStatus>
@@ -224,6 +228,8 @@ export type UserGroupStatus =
224
228
  /** Crombolo: the admin group, or one holding a remote permission, has no owners (story 302). */
225
229
  | 'CannotBeOwned'
226
230
  | 'OwnerNotFound'
231
+ /** Crombolo: whom a group holds comes from a directory outside the site (story 389). */
232
+ | 'ManagedOutside'
227
233
 
228
234
  export interface UserGroupPort {
229
235
  list(skip: number, take: number): Promise<Page<UserGroupResponse>>
package/src/router.ts CHANGED
@@ -81,7 +81,9 @@ export interface Principal {
81
81
  * them for its fifteen minutes, but it decides no approval and makes nothing
82
82
  * that outlives it.
83
83
  */
84
- viaExchange?: { provider: string }
84
+ viaExchange?: { provider: string; forApplying?: true }
85
+ /** The API client an API user signed in as (story 389), for a site whose users a directory keeps. */
86
+ viaClient?: string
85
87
  /**
86
88
  * Set while an administrator's session views as user groups (story 314):
87
89
  * everything above is the groups', and they are who this really is.