@backstage/backend-defaults 0.4.4 → 0.5.0-next.1
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/CHANGELOG.md +143 -9
- package/auth/package.json +1 -1
- package/cache/package.json +1 -1
- package/config.d.ts +221 -0
- package/database/package.json +1 -1
- package/discovery/package.json +1 -1
- package/dist/auth.cjs.js +17 -45
- package/dist/auth.cjs.js.map +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/cache.cjs.js +28 -17
- package/dist/cache.cjs.js.map +1 -1
- package/dist/cache.d.ts +5 -12
- package/dist/database.cjs.js +18 -65
- package/dist/database.cjs.js.map +1 -1
- package/dist/database.d.ts +7 -23
- package/dist/discovery.cjs.js +4 -3
- package/dist/discovery.cjs.js.map +1 -1
- package/dist/discovery.d.ts +5 -7
- package/dist/httpAuth.d.ts +1 -1
- package/dist/httpRouter.d.ts +1 -1
- package/dist/index.cjs.js +118 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/permissions.cjs.js +3 -5
- package/dist/permissions.cjs.js.map +1 -1
- package/dist/permissions.d.ts +1 -1
- package/dist/rootConfig.cjs.js +1 -1
- package/dist/rootConfig.cjs.js.map +1 -1
- package/dist/rootHealth.d.ts +1 -1
- package/dist/rootHttpRouter.cjs.js +1 -1
- package/dist/rootHttpRouter.cjs.js.map +1 -1
- package/dist/rootLifecycle.d.ts +1 -1
- package/dist/rootLogger.d.ts +1 -1
- package/dist/scheduler.cjs.js +20 -5
- package/dist/scheduler.cjs.js.map +1 -1
- package/dist/scheduler.d.ts +1 -1
- package/dist/urlReader.cjs.js +2 -1
- package/dist/urlReader.cjs.js.map +1 -1
- package/dist/urlReader.d.ts +4 -5
- package/dist/userInfo.d.ts +1 -1
- package/httpAuth/package.json +1 -1
- package/httpRouter/package.json +1 -1
- package/lifecycle/package.json +1 -1
- package/logger/package.json +1 -1
- package/package.json +11 -10
- package/permissions/package.json +1 -1
- package/rootConfig/package.json +1 -1
- package/rootHealth/package.json +1 -1
- package/rootHttpRouter/package.json +1 -1
- package/rootLifecycle/package.json +1 -1
- package/rootLogger/package.json +1 -1
- package/scheduler/package.json +1 -1
- package/urlReader/package.json +1 -1
- package/userInfo/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,23 +1,157 @@
|
|
|
1
1
|
# @backstage/backend-defaults
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.5.0-next.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a4bac3c: **BREAKING**: You can no longer supply a `basePath` option to the host discovery implementation. In the new backend system, the ability to choose this path has been removed anyway at the plugin router level.
|
|
8
|
+
- 055b75b: **BREAKING**: Simplifications and cleanup as part of the Backend System 1.0 work.
|
|
9
|
+
|
|
10
|
+
For the `/database` subpath exports:
|
|
11
|
+
|
|
12
|
+
- The deprecated `dropDatabase` function has now been removed, without replacement.
|
|
13
|
+
- The deprecated `LegacyRootDatabaseService` type has now been removed.
|
|
14
|
+
- The return type from `DatabaseManager.forPlugin` is now directly a `DatabaseService`, as arguably expected.
|
|
15
|
+
- `DatabaseManager.forPlugin` now requires the `deps` argument, with the logger and lifecycle services.
|
|
16
|
+
|
|
17
|
+
For the `/cache` subpath exports:
|
|
18
|
+
|
|
19
|
+
- The `PluginCacheManager` type has been removed. You can still import it from `@backstage/backend-common`, but it's deprecated there, and you should move off of that package by migrating fully to the new backend system.
|
|
20
|
+
- Accordingly, `CacheManager.forPlugin` immediately returns a `CacheService` instead of a `PluginCacheManager`. The outcome of this is that you no longer need to make the extra `.getClient()` call. The old `CacheManager` with the old behavior still exists on `@backstage/backend-common`, but the above recommendations apply.
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
6
23
|
|
|
24
|
+
- 622360e: Move down the discovery config to be in the root
|
|
25
|
+
- fe6fd8c: Accept `ConfigService` instead of `Config` in constructors/factories
|
|
26
|
+
- 5705424: Wrap scheduled tasks from the scheduler core service now in OpenTelemetry spans
|
|
27
|
+
- b2a329d: Properly indent the config schema
|
|
7
28
|
- Updated dependencies
|
|
8
|
-
- @backstage/backend-common@0.
|
|
9
|
-
- @backstage/
|
|
10
|
-
- @backstage/
|
|
11
|
-
- @backstage/
|
|
12
|
-
- @backstage/plugin-
|
|
13
|
-
- @backstage/
|
|
29
|
+
- @backstage/backend-common@0.25.0-next.1
|
|
30
|
+
- @backstage/plugin-auth-node@0.5.2-next.1
|
|
31
|
+
- @backstage/backend-app-api@0.10.0-next.1
|
|
32
|
+
- @backstage/backend-dev-utils@0.1.5
|
|
33
|
+
- @backstage/backend-plugin-api@0.9.0-next.1
|
|
34
|
+
- @backstage/cli-common@0.1.14
|
|
35
|
+
- @backstage/cli-node@0.2.7
|
|
36
|
+
- @backstage/config@1.2.0
|
|
14
37
|
- @backstage/config-loader@1.9.0
|
|
38
|
+
- @backstage/errors@1.2.4
|
|
39
|
+
- @backstage/integration@1.14.0
|
|
40
|
+
- @backstage/integration-aws-node@0.1.12
|
|
41
|
+
- @backstage/types@1.1.1
|
|
42
|
+
- @backstage/plugin-events-node@0.4.0-next.1
|
|
43
|
+
- @backstage/plugin-permission-node@0.8.3-next.1
|
|
44
|
+
|
|
45
|
+
## 0.5.0-next.0
|
|
46
|
+
|
|
47
|
+
### Minor Changes
|
|
48
|
+
|
|
49
|
+
- 359fcd7: **BREAKING**: The backwards compatibility with plugins using legacy auth through the token manager service has been removed. This means that instead of falling back to using the old token manager, requests towards plugins that don't support the new auth system will simply fail. Please make sure that all plugins in your deployment are hosted within a backend instance from the new backend system.
|
|
50
|
+
- d425fc4: **BREAKING**: The return values from `createBackendPlugin`, `createBackendModule`, and `createServiceFactory` are now simply `BackendFeature` and `ServiceFactory`, instead of the previously deprecated form of a function that returns them. For this reason, `createServiceFactory` also no longer accepts the callback form where you provide direct options to the service. This also affects all `coreServices.*` service refs.
|
|
51
|
+
|
|
52
|
+
This may in particular affect tests; if you were effectively doing `createBackendModule({...})()` (note the parentheses), you can now remove those extra parentheses at the end. You may encounter cases of this in your `packages/backend/src/index.ts` too, where you add plugins, modules, and services. If you were using `createServiceFactory` with a function as its argument for the purpose of passing in options, this pattern has been deprecated for a while and is no longer supported. You may want to explore the new multiton patterns to achieve your goals, or moving settings to app-config.
|
|
53
|
+
|
|
54
|
+
As part of this change, the `IdentityFactoryOptions` type was removed, and can no longer be used to tweak that service. The identity service was also deprecated some time ago, and you will want to [migrate to the new auth system](https://backstage.io/docs/tutorials/auth-service-migration) if you still rely on it.
|
|
55
|
+
|
|
56
|
+
- 19ff127: **BREAKING**: The default backend instance no longer provides implementations for the identity and token manager services, which have been removed from `@backstage/backend-plugin-api`.
|
|
57
|
+
|
|
58
|
+
If you rely on plugins that still require these services, you can add them to your own backend by re-creating the service reference and factory.
|
|
15
59
|
|
|
16
|
-
|
|
60
|
+
The following can be used to implement the identity service:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import {
|
|
64
|
+
coreServices,
|
|
65
|
+
createServiceFactory,
|
|
66
|
+
createServiceRef,
|
|
67
|
+
} from '@backstage/backend-plugin-api';
|
|
68
|
+
import {
|
|
69
|
+
DefaultIdentityClient,
|
|
70
|
+
IdentityApi,
|
|
71
|
+
} from '@backstage/plugin-auth-node';
|
|
72
|
+
|
|
73
|
+
backend.add(
|
|
74
|
+
createServiceFactory({
|
|
75
|
+
service: createServiceRef<IdentityApi>({ id: 'core.identity' }),
|
|
76
|
+
deps: {
|
|
77
|
+
discovery: coreServices.discovery,
|
|
78
|
+
},
|
|
79
|
+
async factory({ discovery }) {
|
|
80
|
+
return DefaultIdentityClient.create({ discovery });
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The following can be used to implement the token manager service:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { ServerTokenManager, TokenManager } from '@backstage/backend-common';
|
|
90
|
+
import { createBackend } from '@backstage/backend-defaults';
|
|
91
|
+
import {
|
|
92
|
+
coreServices,
|
|
93
|
+
createServiceFactory,
|
|
94
|
+
createServiceRef,
|
|
95
|
+
} from '@backstage/backend-plugin-api';
|
|
96
|
+
|
|
97
|
+
backend.add(
|
|
98
|
+
createServiceFactory({
|
|
99
|
+
service: createServiceRef<TokenManager>({ id: 'core.tokenManager' }),
|
|
100
|
+
deps: {
|
|
101
|
+
config: coreServices.rootConfig,
|
|
102
|
+
logger: coreServices.rootLogger,
|
|
103
|
+
},
|
|
104
|
+
createRootContext({ config, logger }) {
|
|
105
|
+
return ServerTokenManager.fromConfig(config, {
|
|
106
|
+
logger,
|
|
107
|
+
allowDisabledTokenManager: true,
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
async factory(_deps, tokenManager) {
|
|
111
|
+
return tokenManager;
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
```
|
|
17
116
|
|
|
18
117
|
### Patch Changes
|
|
19
118
|
|
|
20
|
-
-
|
|
119
|
+
- 7f779c7: `auth.externalAccess` should be optional in the config schema
|
|
120
|
+
- 7a72ec8: Exports the `discoveryFeatureLoader` as a replacement for the deprecated `featureDiscoveryService`.
|
|
121
|
+
The `discoveryFeatureLoader` is a new backend system [feature loader](https://backstage.io/docs/backend-system/architecture/feature-loaders/) that discovers backend features from the current `package.json` and its dependencies.
|
|
122
|
+
Here is an example using the `discoveryFeatureLoader` loader in a new backend instance:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { createBackend } from '@backstage/backend-defaults';
|
|
126
|
+
import { discoveryFeatureLoader } from '@backstage/backend-defaults';
|
|
127
|
+
//...
|
|
128
|
+
|
|
129
|
+
const backend = createBackend();
|
|
130
|
+
//...
|
|
131
|
+
backend.add(discoveryFeatureLoader);
|
|
132
|
+
//...
|
|
133
|
+
backend.start();
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- 66dbf0a: Allow the cache service to accept the human duration format for TTL
|
|
137
|
+
- 5a8fcb4: Added the option to skip database migrations by setting `skipMigrations: true` in config. This can be done globally in the database config or by plugin id.
|
|
138
|
+
- 0b2a402: Updates to the config schema to match reality
|
|
139
|
+
- Updated dependencies
|
|
140
|
+
- @backstage/backend-app-api@0.10.0-next.0
|
|
141
|
+
- @backstage/backend-plugin-api@0.9.0-next.0
|
|
142
|
+
- @backstage/plugin-permission-node@0.8.3-next.0
|
|
143
|
+
- @backstage/backend-common@0.25.0-next.0
|
|
144
|
+
- @backstage/plugin-events-node@0.4.0-next.0
|
|
145
|
+
- @backstage/plugin-auth-node@0.5.2-next.0
|
|
146
|
+
- @backstage/backend-dev-utils@0.1.5
|
|
147
|
+
- @backstage/cli-common@0.1.14
|
|
148
|
+
- @backstage/cli-node@0.2.7
|
|
149
|
+
- @backstage/config@1.2.0
|
|
150
|
+
- @backstage/config-loader@1.9.0
|
|
151
|
+
- @backstage/errors@1.2.4
|
|
152
|
+
- @backstage/integration@1.14.0
|
|
153
|
+
- @backstage/integration-aws-node@0.1.12
|
|
154
|
+
- @backstage/types@1.1.1
|
|
21
155
|
|
|
22
156
|
## 0.4.2
|
|
23
157
|
|
package/auth/package.json
CHANGED
package/cache/package.json
CHANGED
package/config.d.ts
CHANGED
|
@@ -14,8 +14,51 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { HumanDuration } from '@backstage/types';
|
|
18
|
+
|
|
17
19
|
export interface Config {
|
|
20
|
+
app: {
|
|
21
|
+
baseUrl: string; // defined in core, but repeated here without doc
|
|
22
|
+
};
|
|
23
|
+
|
|
18
24
|
backend?: {
|
|
25
|
+
/**
|
|
26
|
+
* The full base URL of the backend, as seen from the browser's point of
|
|
27
|
+
* view as it makes calls to the backend.
|
|
28
|
+
*/
|
|
29
|
+
baseUrl: string;
|
|
30
|
+
|
|
31
|
+
/** Address that the backend should listen to. */
|
|
32
|
+
listen?:
|
|
33
|
+
| string
|
|
34
|
+
| {
|
|
35
|
+
/** Address of the interface that the backend should bind to. */
|
|
36
|
+
host?: string;
|
|
37
|
+
/** Port that the backend should listen to. */
|
|
38
|
+
port?: string | number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* HTTPS configuration for the backend. If omitted the backend will serve HTTP.
|
|
43
|
+
*
|
|
44
|
+
* Setting this to `true` will cause self-signed certificates to be generated, which
|
|
45
|
+
* can be useful for local development or other non-production scenarios.
|
|
46
|
+
*/
|
|
47
|
+
https?:
|
|
48
|
+
| true
|
|
49
|
+
| {
|
|
50
|
+
/** Certificate configuration */
|
|
51
|
+
certificate?: {
|
|
52
|
+
/** PEM encoded certificate. Use $file to load in a file */
|
|
53
|
+
cert: string;
|
|
54
|
+
/**
|
|
55
|
+
* PEM encoded certificate key. Use $file to load in a file.
|
|
56
|
+
* @visibility secret
|
|
57
|
+
*/
|
|
58
|
+
key: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
19
62
|
/**
|
|
20
63
|
* Options used by the default auth, httpAuth and userInfo services.
|
|
21
64
|
*/
|
|
@@ -330,6 +373,184 @@ export interface Config {
|
|
|
330
373
|
}
|
|
331
374
|
>;
|
|
332
375
|
};
|
|
376
|
+
|
|
377
|
+
/** Database connection configuration, select base database type using the `client` field */
|
|
378
|
+
database: {
|
|
379
|
+
/** Default database client to use */
|
|
380
|
+
client: 'better-sqlite3' | 'sqlite3' | 'pg';
|
|
381
|
+
/**
|
|
382
|
+
* Base database connection string, or object with individual connection properties
|
|
383
|
+
* @visibility secret
|
|
384
|
+
*/
|
|
385
|
+
connection:
|
|
386
|
+
| string
|
|
387
|
+
| {
|
|
388
|
+
/**
|
|
389
|
+
* Password that belongs to the client User
|
|
390
|
+
* @visibility secret
|
|
391
|
+
*/
|
|
392
|
+
password?: string;
|
|
393
|
+
/**
|
|
394
|
+
* Other connection settings
|
|
395
|
+
*/
|
|
396
|
+
[key: string]: unknown;
|
|
397
|
+
};
|
|
398
|
+
/** Database name prefix override */
|
|
399
|
+
prefix?: string;
|
|
400
|
+
/**
|
|
401
|
+
* Whether to ensure the given database exists by creating it if it does not.
|
|
402
|
+
* Defaults to true if unspecified.
|
|
403
|
+
*/
|
|
404
|
+
ensureExists?: boolean;
|
|
405
|
+
/**
|
|
406
|
+
* Whether to ensure the given database schema exists by creating it if it does not.
|
|
407
|
+
* Defaults to false if unspecified.
|
|
408
|
+
*
|
|
409
|
+
* NOTE: Currently only supported by the `pg` client when pluginDivisionMode: schema
|
|
410
|
+
*/
|
|
411
|
+
ensureSchemaExists?: boolean;
|
|
412
|
+
/**
|
|
413
|
+
* How plugins databases are managed/divided in the provided database instance.
|
|
414
|
+
*
|
|
415
|
+
* `database` -> Plugins are each given their own database to manage their schemas/tables.
|
|
416
|
+
*
|
|
417
|
+
* `schema` -> Plugins will be given their own schema (in the specified/default database)
|
|
418
|
+
* to manage their tables.
|
|
419
|
+
*
|
|
420
|
+
* NOTE: Currently only supported by the `pg` client.
|
|
421
|
+
*
|
|
422
|
+
* @default database
|
|
423
|
+
*/
|
|
424
|
+
pluginDivisionMode?: 'database' | 'schema';
|
|
425
|
+
/** Configures the ownership of newly created schemas in pg databases. */
|
|
426
|
+
role?: string;
|
|
427
|
+
/**
|
|
428
|
+
* Arbitrary config object to pass to knex when initializing
|
|
429
|
+
* (https://knexjs.org/#Installation-client). Most notable is the debug
|
|
430
|
+
* and asyncStackTraces booleans
|
|
431
|
+
*/
|
|
432
|
+
knexConfig?: object;
|
|
433
|
+
/** Skip running database migrations. */
|
|
434
|
+
skipMigrations?: boolean;
|
|
435
|
+
/** Plugin specific database configuration and client override */
|
|
436
|
+
plugin?: {
|
|
437
|
+
[pluginId: string]: {
|
|
438
|
+
/** Database client override */
|
|
439
|
+
client?: 'better-sqlite3' | 'sqlite3' | 'pg';
|
|
440
|
+
/**
|
|
441
|
+
* Database connection string or Knex object override
|
|
442
|
+
* @visibility secret
|
|
443
|
+
*/
|
|
444
|
+
connection?: string | object;
|
|
445
|
+
/**
|
|
446
|
+
* Whether to ensure the given database exists by creating it if it does not.
|
|
447
|
+
* Defaults to base config if unspecified.
|
|
448
|
+
*/
|
|
449
|
+
ensureExists?: boolean;
|
|
450
|
+
/**
|
|
451
|
+
* Whether to ensure the given database schema exists by creating it if it does not.
|
|
452
|
+
* Defaults to false if unspecified.
|
|
453
|
+
*
|
|
454
|
+
* NOTE: Currently only supported by the `pg` client when pluginDivisionMode: schema
|
|
455
|
+
*/
|
|
456
|
+
ensureSchemaExists?: boolean;
|
|
457
|
+
/**
|
|
458
|
+
* Arbitrary config object to pass to knex when initializing
|
|
459
|
+
* (https://knexjs.org/#Installation-client). Most notable is the
|
|
460
|
+
* debug and asyncStackTraces booleans.
|
|
461
|
+
*
|
|
462
|
+
* This is merged recursively into the base knexConfig
|
|
463
|
+
*/
|
|
464
|
+
knexConfig?: object;
|
|
465
|
+
/** Configures the ownership of newly created schemas in pg databases. */
|
|
466
|
+
role?: string;
|
|
467
|
+
/** Skip running database migrations. */
|
|
468
|
+
skipMigrations?: boolean;
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
/** Cache connection configuration, select cache type using the `store` field */
|
|
474
|
+
cache?:
|
|
475
|
+
| {
|
|
476
|
+
store: 'memory';
|
|
477
|
+
/** An optional default TTL (in milliseconds). */
|
|
478
|
+
defaultTtl?: number | HumanDuration;
|
|
479
|
+
}
|
|
480
|
+
| {
|
|
481
|
+
store: 'redis';
|
|
482
|
+
/**
|
|
483
|
+
* A redis connection string in the form `redis://user:pass@host:port`.
|
|
484
|
+
* @visibility secret
|
|
485
|
+
*/
|
|
486
|
+
connection: string;
|
|
487
|
+
/** An optional default TTL (in milliseconds). */
|
|
488
|
+
defaultTtl?: number | HumanDuration;
|
|
489
|
+
/**
|
|
490
|
+
* Whether or not [useRedisSets](https://github.com/jaredwray/keyv/tree/main/packages/redis#useredissets) should be configured to this redis cache.
|
|
491
|
+
* Defaults to true if unspecified.
|
|
492
|
+
*/
|
|
493
|
+
useRedisSets?: boolean;
|
|
494
|
+
}
|
|
495
|
+
| {
|
|
496
|
+
store: 'memcache';
|
|
497
|
+
/**
|
|
498
|
+
* A memcache connection string in the form `user:pass@host:port`.
|
|
499
|
+
* @visibility secret
|
|
500
|
+
*/
|
|
501
|
+
connection: string;
|
|
502
|
+
/** An optional default TTL (in milliseconds). */
|
|
503
|
+
defaultTtl?: number | HumanDuration;
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
cors?: {
|
|
507
|
+
origin?: string | string[];
|
|
508
|
+
methods?: string | string[];
|
|
509
|
+
allowedHeaders?: string | string[];
|
|
510
|
+
exposedHeaders?: string | string[];
|
|
511
|
+
credentials?: boolean;
|
|
512
|
+
maxAge?: number;
|
|
513
|
+
preflightContinue?: boolean;
|
|
514
|
+
optionsSuccessStatus?: number;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Content Security Policy options.
|
|
519
|
+
*
|
|
520
|
+
* The keys are the plain policy ID, e.g. "upgrade-insecure-requests". The
|
|
521
|
+
* values are on the format that the helmet library expects them, as an
|
|
522
|
+
* array of strings. There is also the special value false, which means to
|
|
523
|
+
* remove the default value that Backstage puts in place for that policy.
|
|
524
|
+
*/
|
|
525
|
+
csp?: { [policyId: string]: string[] | false };
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Configuration related to URL reading, used for example for reading catalog info
|
|
529
|
+
* files, scaffolder templates, and techdocs content.
|
|
530
|
+
*/
|
|
531
|
+
reading?: {
|
|
532
|
+
/**
|
|
533
|
+
* A list of targets to allow outgoing requests to. Users will be able to make
|
|
534
|
+
* requests on behalf of the backend to the targets that are allowed by this list.
|
|
535
|
+
*/
|
|
536
|
+
allow?: Array<{
|
|
537
|
+
/**
|
|
538
|
+
* A host to allow outgoing requests to, being either a full host or
|
|
539
|
+
* a subdomain wildcard pattern with a leading `*`. For example `example.com`
|
|
540
|
+
* and `*.example.com` are valid values, `prod.*.example.com` is not.
|
|
541
|
+
* The host may also contain a port, for example `example.com:8080`.
|
|
542
|
+
*/
|
|
543
|
+
host: string;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* An optional list of paths. In case they are present only targets matching
|
|
547
|
+
* any of them will are allowed. You can use trailing slashes to make sure only
|
|
548
|
+
* subdirectories are allowed, for example `/mydir/` will allow targets with
|
|
549
|
+
* paths like `/mydir/a` but will block paths like `/mydir2`.
|
|
550
|
+
*/
|
|
551
|
+
paths?: string[];
|
|
552
|
+
}>;
|
|
553
|
+
};
|
|
333
554
|
};
|
|
334
555
|
|
|
335
556
|
/**
|
package/database/package.json
CHANGED
package/discovery/package.json
CHANGED
package/dist/auth.cjs.js
CHANGED
|
@@ -11,15 +11,13 @@ var luxon = require('luxon');
|
|
|
11
11
|
var fs = require('fs');
|
|
12
12
|
|
|
13
13
|
class DefaultAuthService {
|
|
14
|
-
constructor(userTokenHandler, pluginTokenHandler, externalTokenHandler,
|
|
14
|
+
constructor(userTokenHandler, pluginTokenHandler, externalTokenHandler, pluginId, disableDefaultAuthPolicy, pluginKeySource) {
|
|
15
15
|
this.userTokenHandler = userTokenHandler;
|
|
16
16
|
this.pluginTokenHandler = pluginTokenHandler;
|
|
17
17
|
this.externalTokenHandler = externalTokenHandler;
|
|
18
|
-
this.tokenManager = tokenManager;
|
|
19
18
|
this.pluginId = pluginId;
|
|
20
19
|
this.disableDefaultAuthPolicy = disableDefaultAuthPolicy;
|
|
21
20
|
this.pluginKeySource = pluginKeySource;
|
|
22
|
-
this.logger = logger;
|
|
23
21
|
}
|
|
24
22
|
async authenticate(token, options) {
|
|
25
23
|
const pluginResult = await this.pluginTokenHandler.verifyToken(token);
|
|
@@ -85,45 +83,26 @@ class DefaultAuthService {
|
|
|
85
83
|
if (type === "none" && this.disableDefaultAuthPolicy) {
|
|
86
84
|
return { token: "" };
|
|
87
85
|
}
|
|
88
|
-
const targetSupportsNewAuth = await this.pluginTokenHandler.isTargetPluginSupported(targetPluginId);
|
|
89
86
|
switch (type) {
|
|
87
|
+
// TODO: Check whether the principal is ourselves
|
|
90
88
|
case "service":
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
targetPluginId
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
this.logger.warn(
|
|
98
|
-
`DEPRECATION WARNING: A call to the '${targetPluginId}' plugin had to fall back to using deprecated auth via the token manager service. Please migrate all plugins to the new auth service, see https://backstage.io/docs/tutorials/auth-service-migration for more information`
|
|
99
|
-
);
|
|
100
|
-
return this.tokenManager.getToken().catch((error) => {
|
|
101
|
-
throw new errors.ForwardedError(
|
|
102
|
-
`Unable to generate legacy token for communication with the '${targetPluginId}' plugin. You will typically encounter this error when attempting to call a plugin that does not exist, or is deployed with an old version of Backstage`,
|
|
103
|
-
error
|
|
104
|
-
);
|
|
89
|
+
return this.pluginTokenHandler.issueToken({
|
|
90
|
+
pluginId: this.pluginId,
|
|
91
|
+
targetPluginId
|
|
105
92
|
});
|
|
106
93
|
case "user": {
|
|
107
94
|
const { token } = internalForward;
|
|
108
95
|
if (!token) {
|
|
109
96
|
throw new Error("User credentials is unexpectedly missing token");
|
|
110
97
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
if (this.userTokenHandler.isLimitedUserToken(token)) {
|
|
122
|
-
throw new errors.AuthenticationError(
|
|
123
|
-
`Unable to call '${targetPluginId}' plugin on behalf of user, because the target plugin does not support on-behalf-of tokens or the plugin doesn't exist`
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
return { token };
|
|
98
|
+
const onBehalfOf = await this.userTokenHandler.createLimitedUserToken(
|
|
99
|
+
token
|
|
100
|
+
);
|
|
101
|
+
return this.pluginTokenHandler.issueToken({
|
|
102
|
+
pluginId: this.pluginId,
|
|
103
|
+
targetPluginId,
|
|
104
|
+
onBehalfOf
|
|
105
|
+
});
|
|
127
106
|
}
|
|
128
107
|
default:
|
|
129
108
|
throw new errors.AuthenticationError(
|
|
@@ -622,7 +601,7 @@ class PluginTokenHandler {
|
|
|
622
601
|
}
|
|
623
602
|
if (!await this.isTargetPluginSupported(pluginId)) {
|
|
624
603
|
throw new errors.AuthenticationError(
|
|
625
|
-
`Received a plugin token where the source '${pluginId}' plugin unexpectedly does not have a JWKS endpoint
|
|
604
|
+
`Received a plugin token where the source '${pluginId}' plugin unexpectedly does not have a JWKS endpoint. The target plugin needs to be migrated to be installed in an app using the new backend system.`
|
|
626
605
|
);
|
|
627
606
|
}
|
|
628
607
|
const newClient = new JwksClient(async () => {
|
|
@@ -980,14 +959,9 @@ const authServiceFactory = backendPluginApi.createServiceFactory({
|
|
|
980
959
|
logger: backendPluginApi.coreServices.rootLogger,
|
|
981
960
|
discovery: backendPluginApi.coreServices.discovery,
|
|
982
961
|
plugin: backendPluginApi.coreServices.pluginMetadata,
|
|
983
|
-
database: backendPluginApi.coreServices.database
|
|
984
|
-
// Re-using the token manager makes sure that we use the same generated keys for
|
|
985
|
-
// development as plugins that have not yet been migrated. It's important that this
|
|
986
|
-
// keeps working as long as there are plugins that have not been migrated to the
|
|
987
|
-
// new auth services in the new backend system.
|
|
988
|
-
tokenManager: backendPluginApi.coreServices.tokenManager
|
|
962
|
+
database: backendPluginApi.coreServices.database
|
|
989
963
|
},
|
|
990
|
-
async factory({ config, discovery, plugin,
|
|
964
|
+
async factory({ config, discovery, plugin, logger, database }) {
|
|
991
965
|
const disableDefaultAuthPolicy = config.getOptionalBoolean(
|
|
992
966
|
"backend.auth.dangerouslyDisableDefaultAuthPolicy"
|
|
993
967
|
) ?? false;
|
|
@@ -1017,11 +991,9 @@ const authServiceFactory = backendPluginApi.createServiceFactory({
|
|
|
1017
991
|
userTokens,
|
|
1018
992
|
pluginTokens,
|
|
1019
993
|
externalTokens,
|
|
1020
|
-
tokenManager,
|
|
1021
994
|
plugin.getId(),
|
|
1022
995
|
disableDefaultAuthPolicy,
|
|
1023
|
-
keySource
|
|
1024
|
-
logger
|
|
996
|
+
keySource
|
|
1025
997
|
);
|
|
1026
998
|
}
|
|
1027
999
|
});
|