@sap-ux/backend-proxy-middleware 0.11.2 → 0.12.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/README.md CHANGED
@@ -18,6 +18,7 @@ It can be used either with the `ui5 serve` or the `fiori run` commands.
18
18
  | `pathReplace` | `string` optional | If provided then the path will be replaced with this value before forwarding |
19
19
  | `connectPath` | `string` optional | Path used to fetch the correct credentials from the store when a full odata service url 'system' is used. |
20
20
  | `client` | `string` optional | sap-client parameter |
21
+ | `params` | `object` optional | Map of additional query parameters appended to every proxied request (e.g. `{ saml2: 'disabled' }`) |
21
22
  | `scp` | `boolean` optional | If set to true the proxy will execute the required OAuth routine for the ABAP environment on SAP BTP |
22
23
  | `apiHub` | `boolean` optional | If set to true then the proxy will connect to the SAP API Business Hub |
23
24
  | `proxy` | `string` optional | If set then it will override the proxy settings from node. |
@@ -126,6 +127,21 @@ If you want to configure the proxy to send requests from a certain path `/servic
126
127
  destination: my_example_destination
127
128
  ```
128
129
 
130
+ ### [Appending additional query parameters to proxied requests](#appending-additional-query-parameters)
131
+ If you need to append extra query parameters to all proxied backend requests (e.g. to disable SAML authentication for Basic Auth flows), use the `params` property. This is the recommended approach instead of injecting parameters via the `client` property.
132
+
133
+ ```yaml
134
+ - name: backend-proxy-middleware
135
+ afterMiddleware: compression
136
+ configuration:
137
+ backend:
138
+ path: /sap
139
+ url: https://my.backend.example:1234
140
+ client: '100'
141
+ params:
142
+ saml2: disabled
143
+ ```
144
+
129
145
  ### [Providing Proxy Configuration](#providing-proxy-configuration)
130
146
  By default the `backend-proxy-middleware` will read the proxy configuration from the OS environment variables `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` or from the Node.js environment variables `proxy`, `https-proxy` and `noproxy`. If those variables are not set, then you can also provide the proxy configuration in the `ui5.yaml` file.
131
147
 
@@ -73,6 +73,13 @@ export declare const PathRewriters: {
73
73
  * @returns a path rewrite function
74
74
  */
75
75
  replaceClient(client: string): (path: string) => string;
76
+ /**
77
+ * Append additional query parameters to every proxied request path.
78
+ *
79
+ * @param params map of query parameter key-value pairs
80
+ * @returns a path rewrite function
81
+ */
82
+ appendParams(params: Record<string, string>): (path: string) => string;
76
83
  /**
77
84
  * Create a chain of rewrite function calls based on the provided configuration.
78
85
  *
@@ -144,6 +144,23 @@ exports.PathRewriters = {
144
144
  }
145
145
  };
146
146
  },
147
+ /**
148
+ * Append additional query parameters to every proxied request path.
149
+ *
150
+ * @param params map of query parameter key-value pairs
151
+ * @returns a path rewrite function
152
+ */
153
+ appendParams(params) {
154
+ const queryString = Object.entries(params)
155
+ .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
156
+ .join('&');
157
+ return (path) => {
158
+ if (!queryString) {
159
+ return path;
160
+ }
161
+ return path.includes('?') ? `${path}&${queryString}` : `${path}?${queryString}`;
162
+ };
163
+ },
147
164
  /**
148
165
  * Create a chain of rewrite function calls based on the provided configuration.
149
166
  *
@@ -162,8 +179,15 @@ exports.PathRewriters = {
162
179
  functions.push(exports.PathRewriters.replacePrefix(config.path, config.pathReplace));
163
180
  }
164
181
  if (config.client) {
182
+ if (!/^\d{1,3}$/.test(config.client)) {
183
+ log.warn(`Invalid "client" value "${config.client}": expected a 1-3 digit SAP client number. ` +
184
+ `Use the "params" property to append additional query parameters.`);
185
+ }
165
186
  functions.push(exports.PathRewriters.replaceClient(config.client));
166
187
  }
188
+ if (config.params) {
189
+ functions.push(exports.PathRewriters.appendParams(config.params));
190
+ }
167
191
  if (config.bsp) {
168
192
  functions.push(exports.PathRewriters.convertAppDescriptorToManifest(config.bsp));
169
193
  }
@@ -13,6 +13,12 @@ export interface BaseBackendConfig {
13
13
  * sap-client parameter
14
14
  */
15
15
  client?: string;
16
+ /**
17
+ * Optional map of additional query parameters to append to every proxied request.
18
+ * Aligned with the `params` property in `UrlAbapTarget` from `@sap-ux/system-access`.
19
+ * Example: { saml2: 'disabled' }
20
+ */
21
+ params?: Record<string, string>;
16
22
  /**
17
23
  * If set to true the proxy will execute the required OAuth routine for the ABAP environment on SAP BTP
18
24
  */
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Abackend-proxy-middleware"
11
11
  },
12
- "version": "0.11.2",
12
+ "version": "0.12.0",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,14 +27,14 @@
27
27
  "chalk": "4.1.2",
28
28
  "dotenv": "17.3.1",
29
29
  "http-proxy-middleware": "3.0.5",
30
- "https-proxy-agent": "5.0.1",
31
- "i18next": "25.8.20",
30
+ "https-proxy-agent": "7.0.6",
31
+ "i18next": "25.10.10",
32
32
  "prompts": "2.4.2",
33
33
  "proxy-from-env": "1.1.0",
34
- "@sap-ux/axios-extension": "1.25.26",
35
- "@sap-ux/btp-utils": "1.1.11",
36
- "@sap-ux/logger": "0.8.3",
37
- "@sap-ux/store": "1.5.11"
34
+ "@sap-ux/axios-extension": "1.25.28",
35
+ "@sap-ux/btp-utils": "1.1.12",
36
+ "@sap-ux/logger": "0.8.4",
37
+ "@sap-ux/store": "1.5.12"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/connect": "^3.4.38",