@wbce-d9/api 12.5.8 → 12.5.10

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.
@@ -17,6 +17,23 @@ import { getIPFromReq } from '../../utils/get-ip-from-req.js';
17
17
  import { Url } from '../../utils/url.js';
18
18
  import { isRedirectAllowedOnLogin } from '../../utils/is-redirect-allowed-on-login.js';
19
19
  import { BaseOAuthDriver } from './baseoauth.js';
20
+ // Authorization-request parameters the caller must never control
21
+ const RESERVED_AUTH_PARAMS = new Set([
22
+ 'prompt',
23
+ 'redirect',
24
+ 'scope',
25
+ 'access_type',
26
+ 'code_challenge',
27
+ 'code_challenge_method',
28
+ 'state',
29
+ 'nonce',
30
+ 'redirect_uri',
31
+ 'client_id',
32
+ 'response_type',
33
+ 'response_mode',
34
+ 'request',
35
+ 'request_uri',
36
+ ]);
20
37
  export class OpenIDAuthDriver extends BaseOAuthDriver {
21
38
  client;
22
39
  redirectUrl;
@@ -75,6 +92,7 @@ export class OpenIDAuthDriver extends BaseOAuthDriver {
75
92
  const codeChallenge = await oidc.calculatePKCECodeChallenge(codeVerifier);
76
93
  const paramsConfig = typeof this.config['params'] === 'object' ? this.config['params'] : {};
77
94
  const params = {
95
+ ...additionalParams,
78
96
  scope: this.config['scope'] ?? 'openid profile email',
79
97
  access_type: 'offline',
80
98
  ...paramsConfig,
@@ -84,7 +102,6 @@ export class OpenIDAuthDriver extends BaseOAuthDriver {
84
102
  state: codeChallenge,
85
103
  nonce: codeChallenge,
86
104
  redirect_uri: this.redirectUrl,
87
- ...additionalParams,
88
105
  };
89
106
  if (prompt) {
90
107
  params.prompt = 'consent';
@@ -155,7 +172,7 @@ export function createOpenIDAuthRouter(providerName) {
155
172
  issuer: 'directus',
156
173
  });
157
174
  const additionalParams = Object.fromEntries(Object.entries(req.query)
158
- .filter(([k, v]) => k !== 'prompt' && k !== 'redirect' && typeof v === 'string')
175
+ .filter(([k, v]) => RESERVED_AUTH_PARAMS.has(k) === false && typeof v === 'string')
159
176
  .map(([k, v]) => [k, v]));
160
177
  const authUrl = await provider.generateAuthUrl(codeVerifier, prompt, additionalParams);
161
178
  const urlParams = new URL(authUrl);
@@ -0,0 +1 @@
1
+ export {};
@@ -5,9 +5,17 @@ import { version } from './package.js';
5
5
  export function getCacheKey(req) {
6
6
  const path = url.parse(req.originalUrl).pathname;
7
7
  const isGraphQl = path?.startsWith('/graphql');
8
+ const accountability = req.accountability;
9
+ // Include every accountability field that affects permission resolution (see get-permissions.ts),
10
+ // so responses are never shared across roles, shares or share scopes
8
11
  const info = {
9
12
  version,
10
- user: req.accountability?.user || null,
13
+ user: accountability?.user || null,
14
+ role: accountability?.role || null,
15
+ admin: accountability?.admin || false,
16
+ app: accountability?.app || false,
17
+ share: accountability?.share || null,
18
+ share_scope: accountability?.share_scope || null,
11
19
  path,
12
20
  query: isGraphQl ? getGraphqlQueryAndVariables(req) : req.sanitizedQuery,
13
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wbce-d9/api",
3
- "version": "12.5.8",
3
+ "version": "12.5.10",
4
4
  "description": "Directus is a real-time API and App dashboard for managing SQL database content",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -143,15 +143,15 @@
143
143
  "tmp-promise": "3.0.3",
144
144
  "tsx": "3.12.6",
145
145
  "uuid-validate": "0.0.3",
146
- "@wbce-d9/app": "11.0.0",
147
146
  "@wbce-d9/constants": "10.0.0",
148
147
  "@wbce-d9/exceptions": "10.0.0",
149
148
  "@wbce-d9/extensions-sdk": "10.0.4",
150
149
  "@wbce-d9/schema": "10.0.0",
151
- "@wbce-d9/storage-driver-azure": "10.0.3",
152
150
  "@wbce-d9/specs": "9.26.5",
153
151
  "@wbce-d9/storage": "10.0.0",
152
+ "@wbce-d9/storage-driver-azure": "10.0.3",
154
153
  "@wbce-d9/storage-driver-cloudinary": "10.0.4",
154
+ "@wbce-d9/app": "11.0.0",
155
155
  "@wbce-d9/storage-driver-gcs": "10.0.3",
156
156
  "@wbce-d9/storage-driver-local": "10.0.3",
157
157
  "@wbce-d9/storage-driver-s3": "10.0.3",