@crombolo/api-management 0.66.0 → 0.68.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.66.0",
3
+ "version": "0.68.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.66.0",
33
- "@crombolo/contracts": "0.66.0",
34
- "@crombolo/core": "0.66.0"
32
+ "@crombolo/content": "0.68.0",
33
+ "@crombolo/contracts": "0.68.0",
34
+ "@crombolo/core": "0.68.0"
35
35
  }
36
36
  }
@@ -473,6 +473,21 @@ export function canReadDocumentAt(
473
473
  return permissionsForPath(principal.groups, chain).has(D.Read)
474
474
  }
475
475
 
476
+ /**
477
+ * What a token exchanged through a provider may not do (story 364): set or
478
+ * reset a password, change two-factor sign-in, or make an API key, any of
479
+ * which would outlast its fifteen minutes.
480
+ */
481
+ export const EXCHANGE_REFUSED_OPERATIONS: ReadonlySet<string> = new Set([
482
+ 'PostUserCurrentChangePassword',
483
+ 'PostUserByIdChangePassword',
484
+ 'PostUserByIdResetPassword',
485
+ 'PostUserCurrent2faByProviderName',
486
+ 'DeleteUserCurrent2faByProviderName',
487
+ 'DeleteUserById2faByProviderName',
488
+ 'PostUserByIdClientCredentials',
489
+ ])
490
+
476
491
  /** Evaluates the operation's section requirements, then its node rules. */
477
492
  export async function authorize(
478
493
  operation: OperationInfo,
@@ -481,6 +496,7 @@ export async function authorize(
481
496
  principal: Principal,
482
497
  nodes: NodeLookup | undefined,
483
498
  ): Promise<boolean> {
499
+ if (principal.viaExchange && EXCHANGE_REFUSED_OPERATIONS.has(operation.operationId)) return false
484
500
  const sections = sectionsOf(principal)
485
501
  for (const requirement of sectionRequirements(operation)) {
486
502
  if (requirement === 'admin') {
package/src/router.ts CHANGED
@@ -75,6 +75,13 @@ export interface Principal {
75
75
  * 351): it is them, but like CI it never decides an approval.
76
76
  */
77
77
  viaToken?: { key: string; name: string }
78
+ /**
79
+ * Set when the person acts through a token exchanged at the remote for one
80
+ * their identity provider issued (story 364), by that provider's id: it is
81
+ * them for its fifteen minutes, but it decides no approval and makes nothing
82
+ * that outlives it.
83
+ */
84
+ viaExchange?: { provider: string }
78
85
  /**
79
86
  * Set while an administrator's session views as user groups (story 314):
80
87
  * everything above is the groups', and they are who this really is.