@sasjs/api 0.42.0 → 0.44.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.
@@ -3,6 +3,7 @@ import { assertOneFileName } from '../drive/deploymentFile.js';
3
3
  import { appSummary, checkPublishRequest, frontendFolderOf } from '../appstream/service.js';
4
4
  import { appRootOf } from '../appstream/web.js';
5
5
  import { publishRequestFor, splitAppBundle } from '../appstream/bundle.js';
6
+ import { DEFAULT_GRANTABLE_ROUTES, TOP_LEVEL_ROUTES } from '../identity/routeAccess.js';
6
7
  import { ApiError, isApiError } from '../types.js';
7
8
  import { DEPLOY_SUCCESS } from '../drive/deploy.js';
8
9
  /** The defaults sasjs/server's Client schema applies to an omitted lifetime. */
@@ -24,16 +25,22 @@ const RUN_ROUTES = [
24
25
  'POST /SASjsApi/code/trigger'
25
26
  ];
26
27
  /**
27
- * The run routes a permission rule addresses.
28
+ * The operations a permission rule addresses.
28
29
  *
29
- * The triggers are not in the inventory - the server's rules do not reach them -
30
- * so they are gated on the caller alone, exactly as they are there.
30
+ * The inventory less the two entries that name a whole surface rather than an
31
+ * operation: `/SASjsApi` and `/AppStream` are prefixes a rule can cover
32
+ * everything beneath with, not routes a request is dispatched to. This is the
33
+ * server's `isAuthorizingRoute` - the same inventory, minus the routes every
34
+ * caller sees - so a request meets a rule check on exactly the calls it does
35
+ * there: the run routes, the drive routes, and the app stream's own paths.
36
+ *
37
+ * The triggers are absent because the rules do not reach them, and the record,
38
+ * identity, info and admin routes are gated separately.
31
39
  */
32
- const GRANTED_RUN_ROUTES = [
33
- 'GET /SASjsApi/stp/execute',
34
- 'POST /SASjsApi/stp/execute',
35
- 'POST /SASjsApi/code/execute'
36
- ];
40
+ const GRANTED_ROUTES = DEFAULT_GRANTABLE_ROUTES.filter((path) => !TOP_LEVEL_ROUTES.includes(path));
41
+ // The OpenAPI route table lowercases filetree; use the inventory's spelling
42
+ // when checking rules, so dispatch and myAuthorizedRoutes agree.
43
+ const grantPath = (path) => GRANTED_ROUTES.find((candidate) => candidate.toLowerCase() === path.toLowerCase());
37
44
  /**
38
45
  * The host's own reports, which the server mounts `verifyAdmin` in front of.
39
46
  *
@@ -139,7 +146,12 @@ export const dispatch = async (services, routeId, request = {}) => {
139
146
  // permission rules address. Asked of the record service, so the answer a
140
147
  // request meets is the one `myAuthorizedRoutes` reported for the same caller.
141
148
  const adminScoped = ADMIN_ROUTES.includes(routeId) && Boolean(services.admin);
142
- const grantScoped = Boolean(records) && GRANTED_RUN_ROUTES.includes(routeId);
149
+ const grantScoped = grantPath(route.path);
150
+ // A host with identity is enforcing access and must not silently skip a
151
+ // permission gate when its record service is absent. A drive-only host has
152
+ // no identity model at all and retains its existing desktop-style behavior.
153
+ if (grantScoped && (identity || request.subject || request.token) && !records)
154
+ throw new ApiError(501, `This host has no record service, so it cannot answer ${routeId}.`);
143
155
  // The administrator routes need the record service to answer the question the
144
156
  // host's middleware answers on a server. A host that supplies the reports
145
157
  // without one is told which capability it is missing, rather than serving its
@@ -167,16 +179,27 @@ export const dispatch = async (services, routeId, request = {}) => {
167
179
  if ((identityScoped && records) ||
168
180
  (runtimeScoped && services.runtime) ||
169
181
  adminScoped ||
170
- grantScoped) {
182
+ (grantScoped && records)) {
171
183
  const callerSubject = await caller();
184
+ let publicGrant = false;
172
185
  if (!callerSubject) {
173
- // A host may serve records without a sign-in flow - it resolves the caller
174
- // itself and passes `subject`. Without one it cannot authenticate at all,
175
- // and a 401 would send every request round the login loop for ever, so it
176
- // is told which capability it is missing instead.
177
- if (!identity)
178
- throw new ApiError(501, `This host has no identity service, so it cannot answer ${routeId}.`);
179
- throw new ApiError(401, 'Unauthorized');
186
+ // An exact public-group grant also authenticates a tokenless caller on
187
+ // the server. Do not treat a parent grant as public authentication.
188
+ publicGrant = Boolean(grantScoped &&
189
+ records &&
190
+ !identityScoped &&
191
+ !runtimeScoped &&
192
+ !adminScoped &&
193
+ (await records.mayUseRoute(undefined, grantScoped)));
194
+ if (!publicGrant) {
195
+ // A host may serve records without a sign-in flow - it resolves the caller
196
+ // itself and passes `subject`. Without one it cannot authenticate at all,
197
+ // and a 401 would send every request round the login loop for ever, so it
198
+ // is told which capability it is missing instead.
199
+ if (!identity)
200
+ throw new ApiError(501, `This host has no identity service, so it cannot answer ${routeId}.`);
201
+ throw new ApiError(401, 'Unauthorized');
202
+ }
180
203
  }
181
204
  // `verifyAdmin`, in the wording a caller sees on a server - except for a
182
205
  // caller the server refuses before that middleware runs, which meets the
@@ -190,7 +213,10 @@ export const dispatch = async (services, routeId, request = {}) => {
190
213
  }
191
214
  // `authorize`: the rules this host's interface reads decide the call, not
192
215
  // only the menu entry beside it
193
- if (grantScoped && !(await records.mayUseRoute(callerSubject, route.path)))
216
+ if (grantScoped &&
217
+ records &&
218
+ !publicGrant &&
219
+ !(await records.mayUseRoute(callerSubject, grantScoped)))
194
220
  throw new ApiError(401, 'Unauthorized');
195
221
  }
196
222
  validate(route, request);
@@ -130,8 +130,9 @@ export interface RecordService {
130
130
  * rules can address. For anyone else a path outside the inventory answers
131
131
  * `false`, exactly as `myAuthorizedRoutes` omits it.
132
132
  *
133
- * `false` for a caller that is absent or deactivated, so a host answers a
134
- * `401` rather than letting the call through.
133
+ * An absent caller is admitted only by an exact public-group grant; neither
134
+ * top-level grants nor always-visible routes authenticate anonymous callers.
135
+ * A supplied caller whose account is absent or deactivated is refused.
135
136
  */
136
137
  mayUseRoute(caller: Subject | undefined, path: string): Promise<boolean>;
137
138
  listPermissions(caller: Subject | undefined): Promise<PermissionResponse[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../src/identity/records.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,oBAAoB,EAGpB,aAAa,EAEb,OAAO,EACR,MAAM,YAAY,CAAA;AAEnB,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,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AAI,OAAO,OAAO,KAAG,MAKf,CAAA;AAetC,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B;AAED,eAAO,MAAM,mBAAmB,GAC9B,OAAO,aAAa,EACpB,UAAS,oBAAyB,KACjC,aAmgBF,CAAA"}
@@ -350,6 +350,16 @@ export const createRecordService = (store, options = {}) => {
350
350
  return Boolean(await readerOf(store, caller));
351
351
  },
352
352
  async mayUseRoute(caller, path) {
353
+ if (!caller) {
354
+ const rules = await store.permissions();
355
+ if (!rules.some((rule) => rule.group !== undefined))
356
+ return false;
357
+ const publicGroup = (await store.groups()).find((group) => group.name === PUBLIC_GROUP);
358
+ return Boolean(publicGroup &&
359
+ rules.some((rule) => rule.group === publicGroup.uid &&
360
+ rule.path === path &&
361
+ rule.setting === 'Grant'));
362
+ }
353
363
  const reader = await readerOf(store, caller);
354
364
  if (!reader)
355
365
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"generated.d.ts","sourceRoot":"","sources":["../../../src/routes/generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,gBAAgB,EAAE,cAAc,EA0nE5C,CAAA"}
1
+ {"version":3,"file":"generated.d.ts","sourceRoot":"","sources":["../../../src/routes/generated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,gBAAgB,EAAE,cAAc,EA0qE5C,CAAA"}
@@ -555,6 +555,10 @@ export const GENERATED_ROUTES = [
555
555
  status: 400,
556
556
  description: 'Invalid Format'
557
557
  },
558
+ {
559
+ status: 401,
560
+ description: 'Unauthorized'
561
+ },
558
562
  {
559
563
  status: 404,
560
564
  description: 'No app is published with that id'
@@ -621,6 +625,10 @@ export const GENERATED_ROUTES = [
621
625
  status: 400,
622
626
  description: 'Invalid Format'
623
627
  },
628
+ {
629
+ status: 401,
630
+ description: 'Unauthorized'
631
+ },
624
632
  {
625
633
  status: 413,
626
634
  description: 'File tree exceeds the deploy limit'
@@ -691,6 +699,10 @@ export const GENERATED_ROUTES = [
691
699
  status: 400,
692
700
  description: 'Invalid Format'
693
701
  },
702
+ {
703
+ status: 401,
704
+ description: 'Unauthorized'
705
+ },
694
706
  {
695
707
  status: 413,
696
708
  description: 'File tree exceeds the deploy limit'
@@ -725,6 +737,10 @@ export const GENERATED_ROUTES = [
725
737
  status: 400,
726
738
  description: "Can't delete file outside drive"
727
739
  },
740
+ {
741
+ status: 401,
742
+ description: 'Unauthorized'
743
+ },
728
744
  {
729
745
  status: 404,
730
746
  description: "File doesn't exist"
@@ -765,6 +781,10 @@ export const GENERATED_ROUTES = [
765
781
  status: 400,
766
782
  description: 'A path outside the drive, a refused extension, or a request naming neither or both'
767
783
  },
784
+ {
785
+ status: 401,
786
+ description: 'Unauthorized'
787
+ },
768
788
  {
769
789
  status: 404,
770
790
  description: "File doesn't exist"
@@ -807,6 +827,10 @@ export const GENERATED_ROUTES = [
807
827
  status: 400,
808
828
  description: "Can't modify file outside drive"
809
829
  },
830
+ {
831
+ status: 401,
832
+ description: 'Unauthorized'
833
+ },
810
834
  {
811
835
  status: 404,
812
836
  description: "File doesn't exist"
@@ -849,6 +873,10 @@ export const GENERATED_ROUTES = [
849
873
  status: 400,
850
874
  description: "Can't put file outside drive"
851
875
  },
876
+ {
877
+ status: 401,
878
+ description: 'Unauthorized'
879
+ },
852
880
  {
853
881
  status: 409,
854
882
  description: 'File already exists'
@@ -874,6 +902,10 @@ export const GENERATED_ROUTES = [
874
902
  {
875
903
  status: 200,
876
904
  description: 'Ok'
905
+ },
906
+ {
907
+ status: 401,
908
+ description: 'Unauthorized'
877
909
  }
878
910
  ]
879
911
  },
@@ -901,6 +933,10 @@ export const GENERATED_ROUTES = [
901
933
  status: 400,
902
934
  description: "Can't delete folder outside drive"
903
935
  },
936
+ {
937
+ status: 401,
938
+ description: 'Unauthorized'
939
+ },
904
940
  {
905
941
  status: 404,
906
942
  description: "Folder doesn't exist"
@@ -931,6 +967,10 @@ export const GENERATED_ROUTES = [
931
967
  status: 400,
932
968
  description: "Can't get folder outside drive"
933
969
  },
970
+ {
971
+ status: 401,
972
+ description: 'Unauthorized'
973
+ },
934
974
  {
935
975
  status: 404,
936
976
  description: "Folder doesn't exist"
@@ -961,6 +1001,10 @@ export const GENERATED_ROUTES = [
961
1001
  status: 400,
962
1002
  description: "Can't put folder outside drive"
963
1003
  },
1004
+ {
1005
+ status: 401,
1006
+ description: 'Unauthorized'
1007
+ },
964
1008
  {
965
1009
  status: 409,
966
1010
  description: 'Folder already exists. The body is that message as plain text.'
@@ -997,6 +1041,10 @@ export const GENERATED_ROUTES = [
997
1041
  status: 400,
998
1042
  description: "Can't rename outside drive"
999
1043
  },
1044
+ {
1045
+ status: 401,
1046
+ description: 'Unauthorized'
1047
+ },
1000
1048
  {
1001
1049
  status: 404,
1002
1050
  description: 'No file/folder found for provided path'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sasjs/api",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "description": "The SASjs Server API, described once - a generated route table, the services behind it, and the conformance corpus both hosts run",
5
5
  "license": "MIT",
6
6
  "author": "SASjs",
@@ -76,6 +76,6 @@
76
76
  "minimatch": "11.0.4"
77
77
  },
78
78
  "dependencies": {
79
- "@sasjs/lint": "^5.5.3"
79
+ "@sasjs/lint": "5.5.7"
80
80
  }
81
81
  }