@backstage/backend-defaults 0.5.3-next.3 → 0.6.0-next.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/config.d.ts +5 -10
  3. package/dist/auth.cjs.js +1 -0
  4. package/dist/auth.cjs.js.map +1 -1
  5. package/dist/auth.d.ts +27 -1
  6. package/dist/cache.d.ts +0 -1
  7. package/dist/entrypoints/auth/DefaultAuthService.cjs.js +4 -1
  8. package/dist/entrypoints/auth/DefaultAuthService.cjs.js.map +1 -1
  9. package/dist/entrypoints/auth/authServiceFactory.cjs.js +30 -9
  10. package/dist/entrypoints/auth/authServiceFactory.cjs.js.map +1 -1
  11. package/dist/entrypoints/auth/plugin/PluginTokenHandler.cjs.js +6 -10
  12. package/dist/entrypoints/auth/plugin/PluginTokenHandler.cjs.js.map +1 -1
  13. package/dist/entrypoints/cache/CacheManager.cjs.js +28 -28
  14. package/dist/entrypoints/cache/CacheManager.cjs.js.map +1 -1
  15. package/dist/entrypoints/httpAuth/httpAuthServiceFactory.cjs.js +22 -9
  16. package/dist/entrypoints/httpAuth/httpAuthServiceFactory.cjs.js.map +1 -1
  17. package/dist/entrypoints/httpRouter/http/createAuthIntegrationRouter.cjs.js.map +1 -0
  18. package/dist/entrypoints/httpRouter/http/createCookieAuthRefreshMiddleware.cjs.js.map +1 -0
  19. package/dist/entrypoints/httpRouter/http/createCredentialsBarrier.cjs.js.map +1 -0
  20. package/dist/entrypoints/httpRouter/http/createLifecycleMiddleware.cjs.js.map +1 -0
  21. package/dist/entrypoints/httpRouter/httpRouterServiceFactory.cjs.js +4 -4
  22. package/dist/entrypoints/httpRouter/httpRouterServiceFactory.cjs.js.map +1 -1
  23. package/dist/entrypoints/rootHttpRouter/http/MiddlewareFactory.cjs.js +36 -13
  24. package/dist/entrypoints/rootHttpRouter/http/MiddlewareFactory.cjs.js.map +1 -1
  25. package/dist/entrypoints/urlReader/lib/AzureBlobStorageUrlReader.cjs.js +156 -0
  26. package/dist/entrypoints/urlReader/lib/AzureBlobStorageUrlReader.cjs.js.map +1 -0
  27. package/dist/entrypoints/urlReader/lib/UrlReaders.cjs.js +2 -0
  28. package/dist/entrypoints/urlReader/lib/UrlReaders.cjs.js.map +1 -1
  29. package/dist/httpAuth.cjs.js +1 -0
  30. package/dist/httpAuth.cjs.js.map +1 -1
  31. package/dist/httpAuth.d.ts +36 -2
  32. package/dist/httpRouter.cjs.js +8 -0
  33. package/dist/httpRouter.cjs.js.map +1 -1
  34. package/dist/httpRouter.d.ts +62 -1
  35. package/dist/package.json.cjs.js +8 -8
  36. package/dist/urlReader.cjs.js +2 -0
  37. package/dist/urlReader.cjs.js.map +1 -1
  38. package/dist/urlReader.d.ts +23 -2
  39. package/package.json +24 -24
  40. package/dist/entrypoints/httpRouter/createAuthIntegrationRouter.cjs.js.map +0 -1
  41. package/dist/entrypoints/httpRouter/createCookieAuthRefreshMiddleware.cjs.js.map +0 -1
  42. package/dist/entrypoints/httpRouter/createCredentialsBarrier.cjs.js.map +0 -1
  43. package/dist/entrypoints/httpRouter/createLifecycleMiddleware.cjs.js.map +0 -1
  44. /package/dist/entrypoints/httpRouter/{createAuthIntegrationRouter.cjs.js → http/createAuthIntegrationRouter.cjs.js} +0 -0
  45. /package/dist/entrypoints/httpRouter/{createCookieAuthRefreshMiddleware.cjs.js → http/createCookieAuthRefreshMiddleware.cjs.js} +0 -0
  46. /package/dist/entrypoints/httpRouter/{createCredentialsBarrier.cjs.js → http/createCredentialsBarrier.cjs.js} +0 -0
  47. /package/dist/entrypoints/httpRouter/{createLifecycleMiddleware.cjs.js → http/createLifecycleMiddleware.cjs.js} +0 -0
@@ -1,6 +1,40 @@
1
1
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
- import { HttpAuthService } from '@backstage/backend-plugin-api';
2
+ import { AuthService, DiscoveryService, HttpAuthService, BackstagePrincipalTypes, BackstageCredentials } from '@backstage/backend-plugin-api';
3
+ import { Request, Response } from 'express';
3
4
 
5
+ /**
6
+ * @public
7
+ * Options for creating a DefaultHttpAuthService.
8
+ */
9
+ interface DefaultHttpAuthServiceOptions {
10
+ auth: AuthService;
11
+ discovery: DiscoveryService;
12
+ pluginId: string;
13
+ /**
14
+ * Optionally override logic for extracting the token from the request.
15
+ */
16
+ getTokenFromRequest?: (req: Request) => {
17
+ token?: string;
18
+ };
19
+ }
20
+ /**
21
+ * @public
22
+ * DefaultHttpAuthService is the default implementation of the HttpAuthService
23
+ */
24
+ declare class DefaultHttpAuthService implements HttpAuthService {
25
+ #private;
26
+ private constructor();
27
+ static create(options: DefaultHttpAuthServiceOptions): DefaultHttpAuthService;
28
+ credentials<TAllowed extends keyof BackstagePrincipalTypes = 'unknown'>(req: Request, options?: {
29
+ allow?: Array<TAllowed>;
30
+ allowLimitedAccess?: boolean;
31
+ }): Promise<BackstageCredentials<BackstagePrincipalTypes[TAllowed]>>;
32
+ issueUserCookie(res: Response, options?: {
33
+ credentials?: BackstageCredentials;
34
+ }): Promise<{
35
+ expiresAt: Date;
36
+ }>;
37
+ }
4
38
  /**
5
39
  * Authentication of HTTP requests.
6
40
  *
@@ -12,4 +46,4 @@ import { HttpAuthService } from '@backstage/backend-plugin-api';
12
46
  */
13
47
  declare const httpAuthServiceFactory: _backstage_backend_plugin_api.ServiceFactory<HttpAuthService, "plugin", "singleton">;
14
48
 
15
- export { httpAuthServiceFactory };
49
+ export { DefaultHttpAuthService, type DefaultHttpAuthServiceOptions, httpAuthServiceFactory };
@@ -1,8 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  var httpRouterServiceFactory = require('./entrypoints/httpRouter/httpRouterServiceFactory.cjs.js');
4
+ var createAuthIntegrationRouter = require('./entrypoints/httpRouter/http/createAuthIntegrationRouter.cjs.js');
5
+ var createCredentialsBarrier = require('./entrypoints/httpRouter/http/createCredentialsBarrier.cjs.js');
6
+ var createLifecycleMiddleware = require('./entrypoints/httpRouter/http/createLifecycleMiddleware.cjs.js');
7
+ var createCookieAuthRefreshMiddleware = require('./entrypoints/httpRouter/http/createCookieAuthRefreshMiddleware.cjs.js');
4
8
 
5
9
 
6
10
 
7
11
  exports.httpRouterServiceFactory = httpRouterServiceFactory.httpRouterServiceFactory;
12
+ exports.createAuthIntegrationRouter = createAuthIntegrationRouter.createAuthIntegrationRouter;
13
+ exports.createCredentialsBarrier = createCredentialsBarrier.createCredentialsBarrier;
14
+ exports.createLifecycleMiddleware = createLifecycleMiddleware.createLifecycleMiddleware;
15
+ exports.createCookieAuthRefreshMiddleware = createCookieAuthRefreshMiddleware.createCookieAuthRefreshMiddleware;
8
16
  //# sourceMappingURL=httpRouter.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpRouter.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"httpRouter.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -1,4 +1,9 @@
1
+ /// <reference types="express" />
1
2
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
3
+ import { AuthService, HttpAuthService, RootConfigService, HttpRouterServiceAuthPolicy, LifecycleService } from '@backstage/backend-plugin-api';
4
+ import * as express from 'express';
5
+ import express__default, { RequestHandler } from 'express';
6
+ import { HumanDuration } from '@backstage/types';
2
7
 
3
8
  /**
4
9
  * HTTP route registration for plugins.
@@ -11,4 +16,60 @@ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
11
16
  */
12
17
  declare const httpRouterServiceFactory: _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api.HttpRouterService, "plugin", "singleton">;
13
18
 
14
- export { httpRouterServiceFactory };
19
+ /**
20
+ * @public
21
+ */
22
+ declare function createAuthIntegrationRouter(options: {
23
+ auth: AuthService;
24
+ }): express__default.Router;
25
+
26
+ /**
27
+ * @public
28
+ */
29
+ declare function createCredentialsBarrier(options: {
30
+ httpAuth: HttpAuthService;
31
+ config: RootConfigService;
32
+ }): {
33
+ middleware: RequestHandler;
34
+ addAuthPolicy: (policy: HttpRouterServiceAuthPolicy) => void;
35
+ };
36
+
37
+ /**
38
+ * Options for {@link createLifecycleMiddleware}.
39
+ * @public
40
+ */
41
+ interface LifecycleMiddlewareOptions {
42
+ lifecycle: LifecycleService;
43
+ /**
44
+ * The maximum time that paused requests will wait for the service to start, before returning an error.
45
+ *
46
+ * Defaults to 5 seconds.
47
+ */
48
+ startupRequestPauseTimeout?: HumanDuration;
49
+ }
50
+ /**
51
+ * Creates a middleware that pauses requests until the service has started.
52
+ *
53
+ * @remarks
54
+ *
55
+ * Requests that arrive before the service has started will be paused until startup is complete.
56
+ * If the service does not start within the provided timeout, the request will be rejected with a
57
+ * {@link @backstage/errors#ServiceUnavailableError}.
58
+ *
59
+ * If the service is shutting down, all requests will be rejected with a
60
+ * {@link @backstage/errors#ServiceUnavailableError}.
61
+ *
62
+ * @public
63
+ */
64
+ declare function createLifecycleMiddleware(options: LifecycleMiddlewareOptions): RequestHandler;
65
+
66
+ /**
67
+ * @public
68
+ * Creates a middleware that can be used to refresh the cookie for the user.
69
+ */
70
+ declare function createCookieAuthRefreshMiddleware(options: {
71
+ auth: AuthService;
72
+ httpAuth: HttpAuthService;
73
+ }): express.Router;
74
+
75
+ export { type LifecycleMiddlewareOptions, createAuthIntegrationRouter, createCookieAuthRefreshMiddleware, createCredentialsBarrier, createLifecycleMiddleware, httpRouterServiceFactory };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var name = "@backstage/backend-defaults";
6
- var version = "0.5.3-next.3";
6
+ var version = "0.6.0-next.0";
7
7
  var description = "Backend defaults used by Backstage backend apps";
8
8
  var backstage = {
9
9
  role: "node-library"
@@ -122,8 +122,9 @@ var dependencies = {
122
122
  "@aws-sdk/client-s3": "^3.350.0",
123
123
  "@aws-sdk/credential-providers": "^3.350.0",
124
124
  "@aws-sdk/types": "^3.347.0",
125
+ "@azure/identity": "^4.0.0",
126
+ "@azure/storage-blob": "^12.5.0",
125
127
  "@backstage/backend-app-api": "workspace:^",
126
- "@backstage/backend-common": "^0.25.0",
127
128
  "@backstage/backend-dev-utils": "workspace:^",
128
129
  "@backstage/backend-plugin-api": "workspace:^",
129
130
  "@backstage/cli-common": "workspace:^",
@@ -138,8 +139,8 @@ var dependencies = {
138
139
  "@backstage/plugin-permission-node": "workspace:^",
139
140
  "@backstage/types": "workspace:^",
140
141
  "@google-cloud/storage": "^7.0.0",
141
- "@keyv/memcache": "^1.3.5",
142
- "@keyv/redis": "^2.5.3",
142
+ "@keyv/memcache": "^2.0.1",
143
+ "@keyv/redis": "^4.0.1",
143
144
  "@manypkg/get-packages": "^1.1.3",
144
145
  "@octokit/rest": "^19.0.3",
145
146
  "@opentelemetry/api": "^1.3.0",
@@ -160,14 +161,13 @@ var dependencies = {
160
161
  helmet: "^6.0.0",
161
162
  "isomorphic-git": "^1.23.0",
162
163
  jose: "^5.0.0",
163
- keyv: "^4.5.2",
164
+ keyv: "^5.2.1",
164
165
  knex: "^3.0.0",
165
166
  lodash: "^4.17.21",
166
167
  logform: "^2.3.2",
167
168
  luxon: "^3.0.0",
168
169
  minimatch: "^9.0.0",
169
170
  minimist: "^1.2.5",
170
- morgan: "^1.10.0",
171
171
  mysql2: "^3.0.0",
172
172
  "node-fetch": "^2.7.0",
173
173
  "node-forge": "^1.3.1",
@@ -181,7 +181,7 @@ var dependencies = {
181
181
  stoppable: "^1.1.0",
182
182
  tar: "^6.1.12",
183
183
  "triple-beam": "^1.4.1",
184
- uuid: "^9.0.0",
184
+ uuid: "^11.0.0",
185
185
  winston: "^3.2.1",
186
186
  "winston-transport": "^4.5.0",
187
187
  yauzl: "^3.0.0",
@@ -197,7 +197,6 @@ var devDependencies = {
197
197
  "@types/base64-stream": "^1.0.2",
198
198
  "@types/concat-stream": "^2.0.0",
199
199
  "@types/http-errors": "^2.0.0",
200
- "@types/morgan": "^1.9.0",
201
200
  "@types/node-forge": "^1.3.0",
202
201
  "@types/pg-format": "^1.0.5",
203
202
  "@types/stoppable": "^1.1.0",
@@ -205,6 +204,7 @@ var devDependencies = {
205
204
  "aws-sdk-client-mock": "^4.0.0",
206
205
  "http-errors": "^2.0.0",
207
206
  msw: "^1.0.0",
207
+ "node-mocks-http": "^1.0.0",
208
208
  supertest: "^7.0.0",
209
209
  "wait-for-expect": "^3.0.2"
210
210
  };
@@ -10,6 +10,7 @@ var GitlabUrlReader = require('./entrypoints/urlReader/lib/GitlabUrlReader.cjs.j
10
10
  var GiteaUrlReader = require('./entrypoints/urlReader/lib/GiteaUrlReader.cjs.js');
11
11
  var HarnessUrlReader = require('./entrypoints/urlReader/lib/HarnessUrlReader.cjs.js');
12
12
  var AwsS3UrlReader = require('./entrypoints/urlReader/lib/AwsS3UrlReader.cjs.js');
13
+ var AzureBlobStorageUrlReader = require('./entrypoints/urlReader/lib/AzureBlobStorageUrlReader.cjs.js');
13
14
  var FetchUrlReader = require('./entrypoints/urlReader/lib/FetchUrlReader.cjs.js');
14
15
  var ReadUrlResponseFactory = require('./entrypoints/urlReader/lib/ReadUrlResponseFactory.cjs.js');
15
16
  var UrlReaders = require('./entrypoints/urlReader/lib/UrlReaders.cjs.js');
@@ -27,6 +28,7 @@ exports.GitlabUrlReader = GitlabUrlReader.GitlabUrlReader;
27
28
  exports.GiteaUrlReader = GiteaUrlReader.GiteaUrlReader;
28
29
  exports.HarnessUrlReader = HarnessUrlReader.HarnessUrlReader;
29
30
  exports.AwsS3UrlReader = AwsS3UrlReader.AwsS3UrlReader;
31
+ exports.AzureBlobStorageUrlReader = AzureBlobStorageUrlReader.AzureBlobStorageUrlReader;
30
32
  exports.FetchUrlReader = FetchUrlReader.FetchUrlReader;
31
33
  exports.ReadUrlResponseFactory = ReadUrlResponseFactory.ReadUrlResponseFactory;
32
34
  exports.UrlReaders = UrlReaders.UrlReaders;
@@ -1 +1 @@
1
- {"version":3,"file":"urlReader.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"urlReader.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
3
3
  import { UrlReaderService, RootConfigService, LoggerService, UrlReaderServiceReadTreeResponse, UrlReaderServiceReadUrlOptions, UrlReaderServiceReadUrlResponse, UrlReaderServiceReadTreeOptions, UrlReaderServiceSearchOptions, UrlReaderServiceSearchResponse } from '@backstage/backend-plugin-api';
4
- import { AzureIntegration, AzureDevOpsCredentialsProvider, BitbucketCloudIntegration, BitbucketIntegration, BitbucketServerIntegration, GerritIntegration, GithubIntegration, GithubCredentialsProvider, GitLabIntegration, GiteaIntegration, HarnessIntegration, AwsS3Integration } from '@backstage/integration';
4
+ import { AzureIntegration, AzureDevOpsCredentialsProvider, BitbucketCloudIntegration, BitbucketIntegration, BitbucketServerIntegration, GerritIntegration, GithubIntegration, GithubCredentialsProvider, GitLabIntegration, GiteaIntegration, HarnessIntegration, AwsS3Integration, AzureCredentialsManager, AzureBlobStorageIntergation } from '@backstage/integration';
5
5
  import { Readable } from 'stream';
6
6
  import { AwsCredentialsManager } from '@backstage/integration-aws-node';
7
7
 
@@ -334,6 +334,27 @@ declare class AwsS3UrlReader implements UrlReaderService {
334
334
  toString(): string;
335
335
  }
336
336
 
337
+ /**
338
+ * Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for Azure storage accounts urls.
339
+ *
340
+ * @public
341
+ */
342
+ declare class AzureBlobStorageUrlReader implements UrlReaderService {
343
+ private readonly credsManager;
344
+ private readonly integration;
345
+ private readonly deps;
346
+ static factory: ReaderFactory;
347
+ constructor(credsManager: AzureCredentialsManager, integration: AzureBlobStorageIntergation, deps: {
348
+ treeResponseFactory: ReadTreeResponseFactory;
349
+ });
350
+ private createContainerClient;
351
+ read(url: string): Promise<Buffer>;
352
+ readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
353
+ readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
354
+ search(): Promise<UrlReaderServiceSearchResponse>;
355
+ toString(): string;
356
+ }
357
+
337
358
  /**
338
359
  * A {@link @backstage/backend-plugin-api#UrlReaderService} that does a plain fetch of the URL.
339
360
  *
@@ -437,4 +458,4 @@ declare const urlReaderFactoriesServiceRef: _backstage_backend_plugin_api.Servic
437
458
  */
438
459
  declare const urlReaderServiceFactory: _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api.UrlReaderService, "plugin", "singleton">;
439
460
 
440
- export { AwsS3UrlReader, AzureUrlReader, BitbucketCloudUrlReader, BitbucketServerUrlReader, BitbucketUrlReader, FetchUrlReader, type FromReadableArrayOptions, GerritUrlReader, GiteaUrlReader, GithubUrlReader, GitlabUrlReader, HarnessUrlReader, type ReadTreeResponseFactory, type ReadTreeResponseFactoryOptions, ReadUrlResponseFactory, type ReadUrlResponseFactoryFromStreamOptions, type ReaderFactory, type UrlReaderPredicateTuple, UrlReaders, type UrlReadersOptions, urlReaderFactoriesServiceRef, urlReaderServiceFactory };
461
+ export { AwsS3UrlReader, AzureBlobStorageUrlReader, AzureUrlReader, BitbucketCloudUrlReader, BitbucketServerUrlReader, BitbucketUrlReader, FetchUrlReader, type FromReadableArrayOptions, GerritUrlReader, GiteaUrlReader, GithubUrlReader, GitlabUrlReader, HarnessUrlReader, type ReadTreeResponseFactory, type ReadTreeResponseFactoryOptions, ReadUrlResponseFactory, type ReadUrlResponseFactoryFromStreamOptions, type ReaderFactory, type UrlReaderPredicateTuple, UrlReaders, type UrlReadersOptions, urlReaderFactoriesServiceRef, urlReaderServiceFactory };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-defaults",
3
- "version": "0.5.3-next.3",
3
+ "version": "0.6.0-next.0",
4
4
  "description": "Backend defaults used by Backstage backend apps",
5
5
  "backstage": {
6
6
  "role": "node-library"
@@ -191,24 +191,25 @@
191
191
  "@aws-sdk/client-s3": "^3.350.0",
192
192
  "@aws-sdk/credential-providers": "^3.350.0",
193
193
  "@aws-sdk/types": "^3.347.0",
194
- "@backstage/backend-app-api": "1.0.2-next.2",
195
- "@backstage/backend-common": "^0.25.0",
194
+ "@azure/identity": "^4.0.0",
195
+ "@azure/storage-blob": "^12.5.0",
196
+ "@backstage/backend-app-api": "1.0.3-next.0",
196
197
  "@backstage/backend-dev-utils": "0.1.5",
197
- "@backstage/backend-plugin-api": "1.0.2-next.2",
198
- "@backstage/cli-common": "0.1.15-next.0",
199
- "@backstage/cli-node": "0.2.10-next.0",
200
- "@backstage/config": "1.2.0",
201
- "@backstage/config-loader": "1.9.2-next.0",
202
- "@backstage/errors": "1.2.4",
203
- "@backstage/integration": "1.15.1",
204
- "@backstage/integration-aws-node": "0.1.13-next.0",
205
- "@backstage/plugin-auth-node": "0.5.4-next.2",
206
- "@backstage/plugin-events-node": "0.4.5-next.3",
207
- "@backstage/plugin-permission-node": "0.8.5-next.2",
208
- "@backstage/types": "1.1.1",
198
+ "@backstage/backend-plugin-api": "1.0.3-next.0",
199
+ "@backstage/cli-common": "0.1.15",
200
+ "@backstage/cli-node": "0.2.11-next.0",
201
+ "@backstage/config": "1.3.0",
202
+ "@backstage/config-loader": "1.9.2",
203
+ "@backstage/errors": "1.2.5",
204
+ "@backstage/integration": "1.16.0-next.0",
205
+ "@backstage/integration-aws-node": "0.1.13",
206
+ "@backstage/plugin-auth-node": "0.5.5-next.0",
207
+ "@backstage/plugin-events-node": "0.4.6-next.0",
208
+ "@backstage/plugin-permission-node": "0.8.6-next.0",
209
+ "@backstage/types": "1.2.0",
209
210
  "@google-cloud/storage": "^7.0.0",
210
- "@keyv/memcache": "^1.3.5",
211
- "@keyv/redis": "^2.5.3",
211
+ "@keyv/memcache": "^2.0.1",
212
+ "@keyv/redis": "^4.0.1",
212
213
  "@manypkg/get-packages": "^1.1.3",
213
214
  "@octokit/rest": "^19.0.3",
214
215
  "@opentelemetry/api": "^1.3.0",
@@ -229,14 +230,13 @@
229
230
  "helmet": "^6.0.0",
230
231
  "isomorphic-git": "^1.23.0",
231
232
  "jose": "^5.0.0",
232
- "keyv": "^4.5.2",
233
+ "keyv": "^5.2.1",
233
234
  "knex": "^3.0.0",
234
235
  "lodash": "^4.17.21",
235
236
  "logform": "^2.3.2",
236
237
  "luxon": "^3.0.0",
237
238
  "minimatch": "^9.0.0",
238
239
  "minimist": "^1.2.5",
239
- "morgan": "^1.10.0",
240
240
  "mysql2": "^3.0.0",
241
241
  "node-fetch": "^2.7.0",
242
242
  "node-forge": "^1.3.1",
@@ -250,7 +250,7 @@
250
250
  "stoppable": "^1.1.0",
251
251
  "tar": "^6.1.12",
252
252
  "triple-beam": "^1.4.1",
253
- "uuid": "^9.0.0",
253
+ "uuid": "^11.0.0",
254
254
  "winston": "^3.2.1",
255
255
  "winston-transport": "^4.5.0",
256
256
  "yauzl": "^3.0.0",
@@ -259,14 +259,13 @@
259
259
  },
260
260
  "devDependencies": {
261
261
  "@aws-sdk/util-stream-node": "^3.350.0",
262
- "@backstage/backend-plugin-api": "1.0.2-next.2",
263
- "@backstage/backend-test-utils": "1.1.0-next.3",
264
- "@backstage/cli": "0.29.0-next.3",
262
+ "@backstage/backend-plugin-api": "1.0.3-next.0",
263
+ "@backstage/backend-test-utils": "1.2.0-next.0",
264
+ "@backstage/cli": "0.29.3-next.0",
265
265
  "@types/archiver": "^6.0.0",
266
266
  "@types/base64-stream": "^1.0.2",
267
267
  "@types/concat-stream": "^2.0.0",
268
268
  "@types/http-errors": "^2.0.0",
269
- "@types/morgan": "^1.9.0",
270
269
  "@types/node-forge": "^1.3.0",
271
270
  "@types/pg-format": "^1.0.5",
272
271
  "@types/stoppable": "^1.1.0",
@@ -274,6 +273,7 @@
274
273
  "aws-sdk-client-mock": "^4.0.0",
275
274
  "http-errors": "^2.0.0",
276
275
  "msw": "^1.0.0",
276
+ "node-mocks-http": "^1.0.0",
277
277
  "supertest": "^7.0.0",
278
278
  "wait-for-expect": "^3.0.2"
279
279
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"createAuthIntegrationRouter.cjs.js","sources":["../../../src/entrypoints/httpRouter/createAuthIntegrationRouter.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AuthService } from '@backstage/backend-plugin-api';\nimport express from 'express';\nimport Router from 'express-promise-router';\n\nexport function createAuthIntegrationRouter(options: {\n auth: AuthService;\n}): express.Router {\n const router = Router();\n\n router.get('/.backstage/auth/v1/jwks.json', async (_req, res) => {\n const { keys } = await options.auth.listPublicServiceKeys();\n\n res.json({ keys });\n });\n\n return router;\n}\n"],"names":["Router"],"mappings":";;;;;;;;AAoBO,SAAS,4BAA4B,OAEzB,EAAA;AACjB,EAAA,MAAM,SAASA,uBAAO,EAAA;AAEtB,EAAA,MAAA,CAAO,GAAI,CAAA,+BAAA,EAAiC,OAAO,IAAA,EAAM,GAAQ,KAAA;AAC/D,IAAA,MAAM,EAAE,IAAK,EAAA,GAAI,MAAM,OAAA,CAAQ,KAAK,qBAAsB,EAAA;AAE1D,IAAI,GAAA,CAAA,IAAA,CAAK,EAAE,IAAA,EAAM,CAAA;AAAA,GAClB,CAAA;AAED,EAAO,OAAA,MAAA;AACT;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createCookieAuthRefreshMiddleware.cjs.js","sources":["../../../src/entrypoints/httpRouter/createCookieAuthRefreshMiddleware.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AuthService, HttpAuthService } from '@backstage/backend-plugin-api';\nimport Router from 'express-promise-router';\n\nconst WELL_KNOWN_COOKIE_PATH_V1 = '/.backstage/auth/v1/cookie';\n\n/**\n * @public\n * Creates a middleware that can be used to refresh the cookie for the user.\n */\nexport function createCookieAuthRefreshMiddleware(options: {\n auth: AuthService;\n httpAuth: HttpAuthService;\n}) {\n const { auth, httpAuth } = options;\n const router = Router();\n\n // Endpoint that sets the cookie for the user\n router.get(WELL_KNOWN_COOKIE_PATH_V1, async (_, res) => {\n const { expiresAt } = await httpAuth.issueUserCookie(res);\n res.json({ expiresAt: expiresAt.toISOString() });\n });\n\n // Endpoint that removes the cookie for the user\n router.delete(WELL_KNOWN_COOKIE_PATH_V1, async (_, res) => {\n const credentials = await auth.getNoneCredentials();\n await httpAuth.issueUserCookie(res, { credentials });\n res.status(204).end();\n });\n\n return router;\n}\n"],"names":["Router"],"mappings":";;;;;;;;AAmBA,MAAM,yBAA4B,GAAA,4BAAA;AAM3B,SAAS,kCAAkC,OAG/C,EAAA;AACD,EAAM,MAAA,EAAE,IAAM,EAAA,QAAA,EAAa,GAAA,OAAA;AAC3B,EAAA,MAAM,SAASA,uBAAO,EAAA;AAGtB,EAAA,MAAA,CAAO,GAAI,CAAA,yBAAA,EAA2B,OAAO,CAAA,EAAG,GAAQ,KAAA;AACtD,IAAA,MAAM,EAAE,SAAU,EAAA,GAAI,MAAM,QAAA,CAAS,gBAAgB,GAAG,CAAA;AACxD,IAAA,GAAA,CAAI,KAAK,EAAE,SAAA,EAAW,SAAU,CAAA,WAAA,IAAe,CAAA;AAAA,GAChD,CAAA;AAGD,EAAA,MAAA,CAAO,MAAO,CAAA,yBAAA,EAA2B,OAAO,CAAA,EAAG,GAAQ,KAAA;AACzD,IAAM,MAAA,WAAA,GAAc,MAAM,IAAA,CAAK,kBAAmB,EAAA;AAClD,IAAA,MAAM,QAAS,CAAA,eAAA,CAAgB,GAAK,EAAA,EAAE,aAAa,CAAA;AACnD,IAAI,GAAA,CAAA,MAAA,CAAO,GAAG,CAAA,CAAE,GAAI,EAAA;AAAA,GACrB,CAAA;AAED,EAAO,OAAA,MAAA;AACT;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createCredentialsBarrier.cjs.js","sources":["../../../src/entrypoints/httpRouter/createCredentialsBarrier.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n HttpAuthService,\n HttpRouterServiceAuthPolicy,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport { RequestHandler } from 'express';\nimport { pathToRegexp } from 'path-to-regexp';\n\nexport function createPathPolicyPredicate(policyPath: string) {\n if (policyPath === '/' || policyPath === '*') {\n return () => true;\n }\n\n const { regexp: pathRegex } = pathToRegexp(policyPath, {\n end: false,\n });\n\n return (path: string): boolean => {\n return pathRegex.test(path);\n };\n}\n\nexport function createCredentialsBarrier(options: {\n httpAuth: HttpAuthService;\n config: RootConfigService;\n}): {\n middleware: RequestHandler;\n addAuthPolicy: (policy: HttpRouterServiceAuthPolicy) => void;\n} {\n const { httpAuth, config } = options;\n\n const disableDefaultAuthPolicy = config.getOptionalBoolean(\n 'backend.auth.dangerouslyDisableDefaultAuthPolicy',\n );\n\n if (disableDefaultAuthPolicy) {\n return {\n middleware: (_req, _res, next) => next(),\n addAuthPolicy: () => {},\n };\n }\n\n const unauthenticatedPredicates = new Array<(path: string) => boolean>();\n const cookiePredicates = new Array<(path: string) => boolean>();\n\n const middleware: RequestHandler = (req, _, next) => {\n const allowsUnauthenticated = unauthenticatedPredicates.some(predicate =>\n predicate(req.path),\n );\n\n if (allowsUnauthenticated) {\n next();\n return;\n }\n\n const allowsCookie = cookiePredicates.some(predicate =>\n predicate(req.path),\n );\n\n httpAuth\n .credentials(req, {\n allow: ['user', 'service'],\n allowLimitedAccess: allowsCookie,\n })\n .then(\n () => next(),\n err => next(err),\n );\n };\n\n const addAuthPolicy = (policy: HttpRouterServiceAuthPolicy) => {\n if (policy.allow === 'unauthenticated') {\n unauthenticatedPredicates.push(createPathPolicyPredicate(policy.path));\n } else if (policy.allow === 'user-cookie') {\n cookiePredicates.push(createPathPolicyPredicate(policy.path));\n } else {\n throw new Error('Invalid auth policy');\n }\n };\n\n return { middleware, addAuthPolicy };\n}\n"],"names":["pathToRegexp"],"mappings":";;;;AAwBO,SAAS,0BAA0B,UAAoB,EAAA;AAC5D,EAAI,IAAA,UAAA,KAAe,GAAO,IAAA,UAAA,KAAe,GAAK,EAAA;AAC5C,IAAA,OAAO,MAAM,IAAA;AAAA;AAGf,EAAA,MAAM,EAAE,MAAA,EAAQ,SAAU,EAAA,GAAIA,0BAAa,UAAY,EAAA;AAAA,IACrD,GAAK,EAAA;AAAA,GACN,CAAA;AAED,EAAA,OAAO,CAAC,IAA0B,KAAA;AAChC,IAAO,OAAA,SAAA,CAAU,KAAK,IAAI,CAAA;AAAA,GAC5B;AACF;AAEO,SAAS,yBAAyB,OAMvC,EAAA;AACA,EAAM,MAAA,EAAE,QAAU,EAAA,MAAA,EAAW,GAAA,OAAA;AAE7B,EAAA,MAAM,2BAA2B,MAAO,CAAA,kBAAA;AAAA,IACtC;AAAA,GACF;AAEA,EAAA,IAAI,wBAA0B,EAAA;AAC5B,IAAO,OAAA;AAAA,MACL,UAAY,EAAA,CAAC,IAAM,EAAA,IAAA,EAAM,SAAS,IAAK,EAAA;AAAA,MACvC,eAAe,MAAM;AAAA;AAAC,KACxB;AAAA;AAGF,EAAM,MAAA,yBAAA,GAA4B,IAAI,KAAiC,EAAA;AACvE,EAAM,MAAA,gBAAA,GAAmB,IAAI,KAAiC,EAAA;AAE9D,EAAA,MAAM,UAA6B,GAAA,CAAC,GAAK,EAAA,CAAA,EAAG,IAAS,KAAA;AACnD,IAAA,MAAM,wBAAwB,yBAA0B,CAAA,IAAA;AAAA,MAAK,CAAA,SAAA,KAC3D,SAAU,CAAA,GAAA,CAAI,IAAI;AAAA,KACpB;AAEA,IAAA,IAAI,qBAAuB,EAAA;AACzB,MAAK,IAAA,EAAA;AACL,MAAA;AAAA;AAGF,IAAA,MAAM,eAAe,gBAAiB,CAAA,IAAA;AAAA,MAAK,CAAA,SAAA,KACzC,SAAU,CAAA,GAAA,CAAI,IAAI;AAAA,KACpB;AAEA,IAAA,QAAA,CACG,YAAY,GAAK,EAAA;AAAA,MAChB,KAAA,EAAO,CAAC,MAAA,EAAQ,SAAS,CAAA;AAAA,MACzB,kBAAoB,EAAA;AAAA,KACrB,CACA,CAAA,IAAA;AAAA,MACC,MAAM,IAAK,EAAA;AAAA,MACX,CAAA,GAAA,KAAO,KAAK,GAAG;AAAA,KACjB;AAAA,GACJ;AAEA,EAAM,MAAA,aAAA,GAAgB,CAAC,MAAwC,KAAA;AAC7D,IAAI,IAAA,MAAA,CAAO,UAAU,iBAAmB,EAAA;AACtC,MAAA,yBAAA,CAA0B,IAAK,CAAA,yBAAA,CAA0B,MAAO,CAAA,IAAI,CAAC,CAAA;AAAA,KACvE,MAAA,IAAW,MAAO,CAAA,KAAA,KAAU,aAAe,EAAA;AACzC,MAAA,gBAAA,CAAiB,IAAK,CAAA,yBAAA,CAA0B,MAAO,CAAA,IAAI,CAAC,CAAA;AAAA,KACvD,MAAA;AACL,MAAM,MAAA,IAAI,MAAM,qBAAqB,CAAA;AAAA;AACvC,GACF;AAEA,EAAO,OAAA,EAAE,YAAY,aAAc,EAAA;AACrC;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createLifecycleMiddleware.cjs.js","sources":["../../../src/entrypoints/httpRouter/createLifecycleMiddleware.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { LifecycleService } from '@backstage/backend-plugin-api';\nimport { ServiceUnavailableError } from '@backstage/errors';\nimport { HumanDuration, durationToMilliseconds } from '@backstage/types';\nimport { RequestHandler } from 'express';\n\nexport const DEFAULT_TIMEOUT = { seconds: 5 };\n\n/**\n * Options for {@link createLifecycleMiddleware}.\n * @internal\n */\nexport interface LifecycleMiddlewareOptions {\n lifecycle: LifecycleService;\n /**\n * The maximum time that paused requests will wait for the service to start, before returning an error.\n *\n * Defaults to 5 seconds.\n */\n startupRequestPauseTimeout?: HumanDuration;\n}\n\n/**\n * Creates a middleware that pauses requests until the service has started.\n *\n * @remarks\n *\n * Requests that arrive before the service has started will be paused until startup is complete.\n * If the service does not start within the provided timeout, the request will be rejected with a\n * {@link @backstage/errors#ServiceUnavailableError}.\n *\n * If the service is shutting down, all requests will be rejected with a\n * {@link @backstage/errors#ServiceUnavailableError}.\n *\n * @internal\n */\nexport function createLifecycleMiddleware(\n options: LifecycleMiddlewareOptions,\n): RequestHandler {\n const { lifecycle, startupRequestPauseTimeout = DEFAULT_TIMEOUT } = options;\n\n let state: 'init' | 'up' | 'down' = 'init';\n const waiting = new Set<{\n next: (err?: Error) => void;\n timeout: NodeJS.Timeout;\n }>();\n\n lifecycle.addStartupHook(async () => {\n if (state === 'init') {\n state = 'up';\n for (const item of waiting) {\n clearTimeout(item.timeout);\n item.next();\n }\n waiting.clear();\n }\n });\n\n lifecycle.addShutdownHook(async () => {\n state = 'down';\n\n for (const item of waiting) {\n clearTimeout(item.timeout);\n item.next(new ServiceUnavailableError('Service is shutting down'));\n }\n waiting.clear();\n });\n\n const timeoutMs = durationToMilliseconds(startupRequestPauseTimeout);\n\n return (_req, _res, next) => {\n if (state === 'up') {\n next();\n return;\n } else if (state === 'down') {\n next(new ServiceUnavailableError('Service is shutting down'));\n return;\n }\n\n const item = {\n next,\n timeout: setTimeout(() => {\n if (waiting.delete(item)) {\n next(new ServiceUnavailableError('Service has not started up yet'));\n }\n }, timeoutMs),\n };\n\n waiting.add(item);\n };\n}\n"],"names":["ServiceUnavailableError","durationToMilliseconds"],"mappings":";;;;;AAqBa,MAAA,eAAA,GAAkB,EAAE,OAAA,EAAS,CAAE;AA8BrC,SAAS,0BACd,OACgB,EAAA;AAChB,EAAA,MAAM,EAAE,SAAA,EAAW,0BAA6B,GAAA,eAAA,EAAoB,GAAA,OAAA;AAEpE,EAAA,IAAI,KAAgC,GAAA,MAAA;AACpC,EAAM,MAAA,OAAA,uBAAc,GAGjB,EAAA;AAEH,EAAA,SAAA,CAAU,eAAe,YAAY;AACnC,IAAA,IAAI,UAAU,MAAQ,EAAA;AACpB,MAAQ,KAAA,GAAA,IAAA;AACR,MAAA,KAAA,MAAW,QAAQ,OAAS,EAAA;AAC1B,QAAA,YAAA,CAAa,KAAK,OAAO,CAAA;AACzB,QAAA,IAAA,CAAK,IAAK,EAAA;AAAA;AAEZ,MAAA,OAAA,CAAQ,KAAM,EAAA;AAAA;AAChB,GACD,CAAA;AAED,EAAA,SAAA,CAAU,gBAAgB,YAAY;AACpC,IAAQ,KAAA,GAAA,MAAA;AAER,IAAA,KAAA,MAAW,QAAQ,OAAS,EAAA;AAC1B,MAAA,YAAA,CAAa,KAAK,OAAO,CAAA;AACzB,MAAA,IAAA,CAAK,IAAK,CAAA,IAAIA,8BAAwB,CAAA,0BAA0B,CAAC,CAAA;AAAA;AAEnE,IAAA,OAAA,CAAQ,KAAM,EAAA;AAAA,GACf,CAAA;AAED,EAAM,MAAA,SAAA,GAAYC,6BAAuB,0BAA0B,CAAA;AAEnE,EAAO,OAAA,CAAC,IAAM,EAAA,IAAA,EAAM,IAAS,KAAA;AAC3B,IAAA,IAAI,UAAU,IAAM,EAAA;AAClB,MAAK,IAAA,EAAA;AACL,MAAA;AAAA,KACF,MAAA,IAAW,UAAU,MAAQ,EAAA;AAC3B,MAAK,IAAA,CAAA,IAAID,8BAAwB,CAAA,0BAA0B,CAAC,CAAA;AAC5D,MAAA;AAAA;AAGF,IAAA,MAAM,IAAO,GAAA;AAAA,MACX,IAAA;AAAA,MACA,OAAA,EAAS,WAAW,MAAM;AACxB,QAAI,IAAA,OAAA,CAAQ,MAAO,CAAA,IAAI,CAAG,EAAA;AACxB,UAAK,IAAA,CAAA,IAAIA,8BAAwB,CAAA,gCAAgC,CAAC,CAAA;AAAA;AACpE,SACC,SAAS;AAAA,KACd;AAEA,IAAA,OAAA,CAAQ,IAAI,IAAI,CAAA;AAAA,GAClB;AACF;;;;;"}