@backstage/backend-defaults 0.3.0-next.2 → 0.3.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/CHANGELOG.md +62 -0
- package/auth/package.json +6 -0
- package/cache/package.json +1 -1
- package/config.d.ts +277 -0
- package/database/package.json +1 -1
- package/discovery/package.json +1 -1
- package/dist/auth.cjs.js +1025 -0
- package/dist/auth.cjs.js.map +1 -0
- package/dist/auth.d.ts +14 -0
- package/dist/cache.cjs.js.map +1 -1
- package/dist/cache.d.ts +31 -37
- package/dist/cjs/config-BDOwXIyo.cjs.js +64 -0
- package/dist/cjs/config-BDOwXIyo.cjs.js.map +1 -0
- package/dist/cjs/createConfigSecretEnumerator-DShyoWWL.cjs.js +33 -0
- package/dist/cjs/createConfigSecretEnumerator-DShyoWWL.cjs.js.map +1 -0
- package/dist/cjs/helpers-D2f1CG0o.cjs.js +53 -0
- package/dist/cjs/helpers-D2f1CG0o.cjs.js.map +1 -0
- package/dist/database.cjs.js +59 -145
- package/dist/database.cjs.js.map +1 -1
- package/dist/database.d.ts +7 -2
- package/dist/discovery.cjs.js +6 -6
- package/dist/discovery.cjs.js.map +1 -1
- package/dist/discovery.d.ts +9 -1
- package/dist/httpAuth.cjs.js +192 -0
- package/dist/httpAuth.cjs.js.map +1 -0
- package/dist/httpAuth.d.ts +15 -0
- package/dist/httpRouter.cjs.js +191 -0
- package/dist/httpRouter.cjs.js.map +1 -0
- package/dist/httpRouter.d.ts +55 -0
- package/dist/index.cjs.js +14 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/lifecycle.cjs.js.map +1 -1
- package/dist/lifecycle.d.ts +5 -1
- package/dist/logger.cjs.js +17 -0
- package/dist/logger.cjs.js.map +1 -0
- package/dist/logger.d.ts +14 -0
- package/dist/permissions.cjs.js.map +1 -1
- package/dist/permissions.d.ts +6 -0
- package/dist/rootConfig.cjs.js +3 -0
- package/dist/rootConfig.cjs.js.map +1 -1
- package/dist/rootConfig.d.ts +17 -2
- package/dist/rootHttpRouter.cjs.js +629 -0
- package/dist/rootHttpRouter.cjs.js.map +1 -0
- package/dist/rootHttpRouter.d.ts +283 -0
- package/dist/rootLifecycle.cjs.js.map +1 -1
- package/dist/rootLifecycle.d.ts +5 -1
- package/dist/rootLogger.cjs.js +143 -0
- package/dist/rootLogger.cjs.js.map +1 -0
- package/dist/rootLogger.d.ts +58 -0
- package/dist/scheduler.cjs.js +11 -40
- package/dist/scheduler.cjs.js.map +1 -1
- package/dist/scheduler.d.ts +19 -2
- package/dist/urlReader.cjs.js +2932 -2
- package/dist/urlReader.cjs.js.map +1 -1
- package/dist/urlReader.d.ts +422 -4
- package/dist/userInfo.cjs.js +70 -0
- package/dist/userInfo.cjs.js.map +1 -0
- package/dist/userInfo.d.ts +14 -0
- package/httpAuth/package.json +6 -0
- package/httpRouter/package.json +6 -0
- package/lifecycle/package.json +1 -1
- package/logger/package.json +6 -0
- package/migrations/auth/20240327104803_public_keys.js +50 -0
- package/package.json +103 -11
- package/permissions/package.json +1 -1
- package/rootConfig/package.json +1 -1
- package/rootHttpRouter/package.json +6 -0
- package/rootLifecycle/package.json +1 -1
- package/rootLogger/package.json +6 -0
- package/scheduler/package.json +1 -1
- package/urlReader/package.json +1 -1
- package/userInfo/package.json +6 -0
package/dist/urlReader.d.ts
CHANGED
|
@@ -1,7 +1,425 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
|
-
import
|
|
3
|
+
import { UrlReaderService, 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';
|
|
5
|
+
import { Readable } from 'stream';
|
|
6
|
+
import { Config } from '@backstage/config';
|
|
7
|
+
import { AwsCredentialsManager } from '@backstage/integration-aws-node';
|
|
3
8
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
9
|
+
/**
|
|
10
|
+
* A predicate that decides whether a specific {@link @backstage/backend-plugin-api#UrlReaderService} can handle a
|
|
11
|
+
* given URL.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
type UrlReaderPredicateTuple = {
|
|
16
|
+
predicate: (url: URL) => boolean;
|
|
17
|
+
reader: UrlReaderService;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A factory function that can read config to construct zero or more
|
|
21
|
+
* {@link @backstage/backend-plugin-api#UrlReaderService}s along with a predicate for when it should be used.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
type ReaderFactory = (options: {
|
|
26
|
+
config: Config;
|
|
27
|
+
logger: LoggerService;
|
|
28
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
29
|
+
}) => UrlReaderPredicateTuple[];
|
|
30
|
+
/**
|
|
31
|
+
* An options object for {@link ReadUrlResponseFactory} factory methods.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
type ReadUrlResponseFactoryFromStreamOptions = {
|
|
36
|
+
etag?: string;
|
|
37
|
+
lastModifiedAt?: Date;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Options that control execution of {@link ReadTreeResponseFactory} methods.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
type ReadTreeResponseFactoryOptions = {
|
|
45
|
+
stream: Readable;
|
|
46
|
+
subpath?: string;
|
|
47
|
+
etag: string;
|
|
48
|
+
filter?: (path: string, info?: {
|
|
49
|
+
size: number;
|
|
50
|
+
}) => boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Options that control {@link ReadTreeResponseFactory.fromReadableArray}
|
|
54
|
+
* execution.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
type FromReadableArrayOptions = Array<{
|
|
59
|
+
/**
|
|
60
|
+
* The raw data itself.
|
|
61
|
+
*/
|
|
62
|
+
data: Readable;
|
|
63
|
+
/**
|
|
64
|
+
* The filepath of the data.
|
|
65
|
+
*/
|
|
66
|
+
path: string;
|
|
67
|
+
/**
|
|
68
|
+
* Last modified date of the file contents.
|
|
69
|
+
*/
|
|
70
|
+
lastModifiedAt?: Date;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* A factory for response factories that handle the unpacking and inspection of
|
|
74
|
+
* complex responses such as archive data.
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
interface ReadTreeResponseFactory {
|
|
79
|
+
fromTarArchive(options: ReadTreeResponseFactoryOptions & {
|
|
80
|
+
/**
|
|
81
|
+
* Strip the first parent directory of a tar archive.
|
|
82
|
+
* Defaults to true.
|
|
83
|
+
*/
|
|
84
|
+
stripFirstDirectory?: boolean;
|
|
85
|
+
}): Promise<UrlReaderServiceReadTreeResponse>;
|
|
86
|
+
fromZipArchive(options: ReadTreeResponseFactoryOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
87
|
+
fromReadableArray(options: FromReadableArrayOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
88
|
+
}
|
|
6
89
|
|
|
7
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for Azure repos.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
declare class AzureUrlReader implements UrlReaderService {
|
|
96
|
+
private readonly integration;
|
|
97
|
+
private readonly deps;
|
|
98
|
+
static factory: ReaderFactory;
|
|
99
|
+
constructor(integration: AzureIntegration, deps: {
|
|
100
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
101
|
+
credentialsProvider: AzureDevOpsCredentialsProvider;
|
|
102
|
+
});
|
|
103
|
+
read(url: string): Promise<Buffer>;
|
|
104
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
105
|
+
readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
106
|
+
search(url: string, options?: UrlReaderServiceSearchOptions): Promise<UrlReaderServiceSearchResponse>;
|
|
107
|
+
toString(): string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for files from Bitbucket Cloud.
|
|
112
|
+
*
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
declare class BitbucketCloudUrlReader implements UrlReaderService {
|
|
116
|
+
private readonly integration;
|
|
117
|
+
private readonly deps;
|
|
118
|
+
static factory: ReaderFactory;
|
|
119
|
+
constructor(integration: BitbucketCloudIntegration, deps: {
|
|
120
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
121
|
+
});
|
|
122
|
+
read(url: string): Promise<Buffer>;
|
|
123
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
124
|
+
readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
125
|
+
search(url: string, options?: UrlReaderServiceSearchOptions): Promise<UrlReaderServiceSearchResponse>;
|
|
126
|
+
toString(): string;
|
|
127
|
+
private getLastCommitShortHash;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for files from Bitbucket v1 and v2 APIs, such
|
|
132
|
+
* as the one exposed by Bitbucket Cloud itself.
|
|
133
|
+
*
|
|
134
|
+
* @public
|
|
135
|
+
* @deprecated in favor of BitbucketCloudUrlReader and BitbucketServerUrlReader
|
|
136
|
+
*/
|
|
137
|
+
declare class BitbucketUrlReader implements UrlReaderService {
|
|
138
|
+
private readonly integration;
|
|
139
|
+
private readonly deps;
|
|
140
|
+
static factory: ReaderFactory;
|
|
141
|
+
constructor(integration: BitbucketIntegration, logger: LoggerService, deps: {
|
|
142
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
143
|
+
});
|
|
144
|
+
read(url: string): Promise<Buffer>;
|
|
145
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
146
|
+
readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
147
|
+
search(url: string, options?: UrlReaderServiceSearchOptions): Promise<UrlReaderServiceSearchResponse>;
|
|
148
|
+
toString(): string;
|
|
149
|
+
private getLastCommitShortHash;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for files from Bitbucket Server APIs.
|
|
154
|
+
*
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
declare class BitbucketServerUrlReader implements UrlReaderService {
|
|
158
|
+
private readonly integration;
|
|
159
|
+
private readonly deps;
|
|
160
|
+
static factory: ReaderFactory;
|
|
161
|
+
constructor(integration: BitbucketServerIntegration, deps: {
|
|
162
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
163
|
+
});
|
|
164
|
+
read(url: string): Promise<Buffer>;
|
|
165
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
166
|
+
readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
167
|
+
search(url: string, options?: UrlReaderServiceSearchOptions): Promise<UrlReaderServiceSearchResponse>;
|
|
168
|
+
toString(): string;
|
|
169
|
+
private getLastCommitShortHash;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for files in Gerrit.
|
|
174
|
+
*
|
|
175
|
+
* @remarks
|
|
176
|
+
* To be able to link to Git contents for Gerrit providers in a user friendly
|
|
177
|
+
* way we are depending on that there is a Gitiles installation somewhere
|
|
178
|
+
* that we can link to. It is perfectly possible to integrate Gerrit with
|
|
179
|
+
* Backstage without Gitiles since all API calls goes directly to Gerrit.
|
|
180
|
+
* However if Gitiles is configured, readTree will use it to fetch
|
|
181
|
+
* an archive instead of cloning the repository.
|
|
182
|
+
*
|
|
183
|
+
* The "host" variable in the config is the Gerrit host. The address where
|
|
184
|
+
* Gitiles is installed may be on the same host but it could be on a
|
|
185
|
+
* separate host. For example a Gerrit instance could be hosted on
|
|
186
|
+
* "gerrit-review.company.com" but the repos could be browsable on a separate
|
|
187
|
+
* host, e.g. "gerrit.company.com" and the human readable URL would then
|
|
188
|
+
* not point to the API host.
|
|
189
|
+
*
|
|
190
|
+
* @public
|
|
191
|
+
*/
|
|
192
|
+
declare class GerritUrlReader implements UrlReaderService {
|
|
193
|
+
private readonly integration;
|
|
194
|
+
private readonly deps;
|
|
195
|
+
static factory: ReaderFactory;
|
|
196
|
+
constructor(integration: GerritIntegration, deps: {
|
|
197
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
198
|
+
});
|
|
199
|
+
read(url: string): Promise<Buffer>;
|
|
200
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
201
|
+
readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
202
|
+
search(): Promise<UrlReaderServiceSearchResponse>;
|
|
203
|
+
toString(): string;
|
|
204
|
+
private readTreeFromGitiles;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for files through the GitHub v3 APIs, such as
|
|
209
|
+
* the one exposed by GitHub itself.
|
|
210
|
+
*
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
213
|
+
declare class GithubUrlReader implements UrlReaderService {
|
|
214
|
+
private readonly integration;
|
|
215
|
+
private readonly deps;
|
|
216
|
+
static factory: ReaderFactory;
|
|
217
|
+
constructor(integration: GithubIntegration, deps: {
|
|
218
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
219
|
+
credentialsProvider: GithubCredentialsProvider;
|
|
220
|
+
});
|
|
221
|
+
read(url: string): Promise<Buffer>;
|
|
222
|
+
private getCredentials;
|
|
223
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
224
|
+
readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
225
|
+
search(url: string, options?: UrlReaderServiceSearchOptions): Promise<UrlReaderServiceSearchResponse>;
|
|
226
|
+
toString(): string;
|
|
227
|
+
private doReadTree;
|
|
228
|
+
private doSearch;
|
|
229
|
+
private getRepoDetails;
|
|
230
|
+
private getDefaultBranch;
|
|
231
|
+
private fetchResponse;
|
|
232
|
+
private fetchJson;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for files on GitLab.
|
|
237
|
+
*
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
declare class GitlabUrlReader implements UrlReaderService {
|
|
241
|
+
private readonly integration;
|
|
242
|
+
private readonly deps;
|
|
243
|
+
static factory: ReaderFactory;
|
|
244
|
+
constructor(integration: GitLabIntegration, deps: {
|
|
245
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
246
|
+
});
|
|
247
|
+
read(url: string): Promise<Buffer>;
|
|
248
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
249
|
+
readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
250
|
+
search(url: string, options?: UrlReaderServiceSearchOptions): Promise<UrlReaderServiceSearchResponse>;
|
|
251
|
+
/**
|
|
252
|
+
* This function splits the input globPattern string into segments using the path separator /. It then iterates over
|
|
253
|
+
* the segments from the end of the array towards the beginning, checking if the concatenated string up to that
|
|
254
|
+
* segment matches the original globPattern using the minimatch function. If a match is found, it continues iterating.
|
|
255
|
+
* If no match is found, it returns the concatenated string up to the current segment, which is the static part of the
|
|
256
|
+
* glob pattern.
|
|
257
|
+
*
|
|
258
|
+
* E.g. `catalog/foo/*.yaml` will return `catalog/foo`.
|
|
259
|
+
*
|
|
260
|
+
* @param globPattern the glob pattern
|
|
261
|
+
* @private
|
|
262
|
+
*/
|
|
263
|
+
private getStaticPart;
|
|
264
|
+
toString(): string;
|
|
265
|
+
private getGitlabFetchUrl;
|
|
266
|
+
private getGitlabArtifactFetchUrl;
|
|
267
|
+
private resolveProjectToId;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for the Gitea v1 api.
|
|
272
|
+
*
|
|
273
|
+
* @public
|
|
274
|
+
*/
|
|
275
|
+
declare class GiteaUrlReader implements UrlReaderService {
|
|
276
|
+
private readonly integration;
|
|
277
|
+
private readonly deps;
|
|
278
|
+
static factory: ReaderFactory;
|
|
279
|
+
constructor(integration: GiteaIntegration, deps: {
|
|
280
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
281
|
+
});
|
|
282
|
+
read(url: string): Promise<Buffer>;
|
|
283
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
284
|
+
readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
285
|
+
search(): Promise<UrlReaderServiceSearchResponse>;
|
|
286
|
+
toString(): string;
|
|
287
|
+
private getLastCommitHash;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for the Harness code v1 api.
|
|
292
|
+
*
|
|
293
|
+
*
|
|
294
|
+
* @public
|
|
295
|
+
*/
|
|
296
|
+
declare class HarnessUrlReader implements UrlReaderService {
|
|
297
|
+
private readonly integration;
|
|
298
|
+
private readonly deps;
|
|
299
|
+
static factory: ReaderFactory;
|
|
300
|
+
constructor(integration: HarnessIntegration, deps: {
|
|
301
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
302
|
+
});
|
|
303
|
+
read(url: string): Promise<Buffer>;
|
|
304
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
305
|
+
readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
306
|
+
search(): Promise<UrlReaderServiceSearchResponse>;
|
|
307
|
+
toString(): string;
|
|
308
|
+
private getLastCommitHash;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for AWS S3 buckets.
|
|
313
|
+
*
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
declare class AwsS3UrlReader implements UrlReaderService {
|
|
317
|
+
private readonly credsManager;
|
|
318
|
+
private readonly integration;
|
|
319
|
+
private readonly deps;
|
|
320
|
+
static factory: ReaderFactory;
|
|
321
|
+
constructor(credsManager: AwsCredentialsManager, integration: AwsS3Integration, deps: {
|
|
322
|
+
treeResponseFactory: ReadTreeResponseFactory;
|
|
323
|
+
});
|
|
324
|
+
/**
|
|
325
|
+
* If accessKeyId and secretAccessKey are missing, the standard credentials provider chain will be used:
|
|
326
|
+
* https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html
|
|
327
|
+
*/
|
|
328
|
+
private static buildStaticCredentials;
|
|
329
|
+
private static buildCredentials;
|
|
330
|
+
private buildS3Client;
|
|
331
|
+
private retrieveS3ObjectData;
|
|
332
|
+
read(url: string): Promise<Buffer>;
|
|
333
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
334
|
+
readTree(url: string, options?: UrlReaderServiceReadTreeOptions): Promise<UrlReaderServiceReadTreeResponse>;
|
|
335
|
+
search(): Promise<UrlReaderServiceSearchResponse>;
|
|
336
|
+
toString(): string;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* A {@link @backstage/backend-plugin-api#UrlReaderService} that does a plain fetch of the URL.
|
|
341
|
+
*
|
|
342
|
+
* @public
|
|
343
|
+
*/
|
|
344
|
+
declare class FetchUrlReader implements UrlReaderService {
|
|
345
|
+
/**
|
|
346
|
+
* The factory creates a single reader that will be used for reading any URL that's listed
|
|
347
|
+
* in configuration at `backend.reading.allow`. The allow list contains a list of objects describing
|
|
348
|
+
* targets to allow, containing the following fields:
|
|
349
|
+
*
|
|
350
|
+
* `host`:
|
|
351
|
+
* Either full hostnames to match, or subdomain wildcard matchers with a leading '*'.
|
|
352
|
+
* For example 'example.com' and '*.example.com' are valid values, 'prod.*.example.com' is not.
|
|
353
|
+
*
|
|
354
|
+
* `paths`:
|
|
355
|
+
* An optional list of paths which are allowed. If the list is omitted all paths are allowed.
|
|
356
|
+
*/
|
|
357
|
+
static factory: ReaderFactory;
|
|
358
|
+
read(url: string): Promise<Buffer>;
|
|
359
|
+
readUrl(url: string, options?: UrlReaderServiceReadUrlOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
360
|
+
readTree(): Promise<UrlReaderServiceReadTreeResponse>;
|
|
361
|
+
search(): Promise<UrlReaderServiceSearchResponse>;
|
|
362
|
+
toString(): string;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Utility class for UrlReader implementations to create valid ReadUrlResponse
|
|
367
|
+
* instances from common response primitives.
|
|
368
|
+
*
|
|
369
|
+
* @public
|
|
370
|
+
*/
|
|
371
|
+
declare class ReadUrlResponseFactory {
|
|
372
|
+
/**
|
|
373
|
+
* Resolves a ReadUrlResponse from a Readable stream.
|
|
374
|
+
*/
|
|
375
|
+
static fromReadable(stream: Readable, options?: ReadUrlResponseFactoryFromStreamOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
376
|
+
/**
|
|
377
|
+
* Resolves a ReadUrlResponse from an old-style NodeJS.ReadableStream.
|
|
378
|
+
*/
|
|
379
|
+
static fromNodeJSReadable(oldStyleStream: NodeJS.ReadableStream, options?: ReadUrlResponseFactoryFromStreamOptions): Promise<UrlReaderServiceReadUrlResponse>;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Creation options for {@link @backstage/backend-plugin-api#UrlReaderService}.
|
|
384
|
+
*
|
|
385
|
+
* @public
|
|
386
|
+
*/
|
|
387
|
+
type UrlReadersOptions = {
|
|
388
|
+
/** Root config object */
|
|
389
|
+
config: Config;
|
|
390
|
+
/** Logger used by all the readers */
|
|
391
|
+
logger: LoggerService;
|
|
392
|
+
/** A list of factories used to construct individual readers that match on URLs */
|
|
393
|
+
factories?: ReaderFactory[];
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* Helps construct {@link @backstage/backend-plugin-api#UrlReaderService}s.
|
|
397
|
+
*
|
|
398
|
+
* @public
|
|
399
|
+
*/
|
|
400
|
+
declare class UrlReaders {
|
|
401
|
+
/**
|
|
402
|
+
* Creates a custom {@link @backstage/backend-plugin-api#UrlReaderService} wrapper for your own set of factories.
|
|
403
|
+
*/
|
|
404
|
+
static create(options: UrlReadersOptions): UrlReaderService;
|
|
405
|
+
/**
|
|
406
|
+
* Creates a {@link @backstage/backend-plugin-api#UrlReaderService} wrapper that includes all the default factories
|
|
407
|
+
* from this package.
|
|
408
|
+
*
|
|
409
|
+
* Any additional factories passed will be loaded before the default ones.
|
|
410
|
+
*/
|
|
411
|
+
static default(options: UrlReadersOptions): UrlReaderService;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Reading content from external systems.
|
|
416
|
+
*
|
|
417
|
+
* See {@link @backstage/code-plugin-api#UrlReaderService}
|
|
418
|
+
* and {@link https://backstage.io/docs/backend-system/core-services/url-reader | the service docs}
|
|
419
|
+
* for more information.
|
|
420
|
+
*
|
|
421
|
+
* @public
|
|
422
|
+
*/
|
|
423
|
+
declare const urlReaderServiceFactory: () => _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api.UrlReaderService, "plugin">;
|
|
424
|
+
|
|
425
|
+
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, urlReaderServiceFactory };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
+
var errors = require('@backstage/errors');
|
|
5
|
+
var jose = require('jose');
|
|
6
|
+
var fetch = require('node-fetch');
|
|
7
|
+
var helpers = require('./cjs/helpers-D2f1CG0o.cjs.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
|
|
12
|
+
|
|
13
|
+
class DefaultUserInfoService {
|
|
14
|
+
discovery;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.discovery = options.discovery;
|
|
17
|
+
}
|
|
18
|
+
async getUserInfo(credentials) {
|
|
19
|
+
const internalCredentials = helpers.toInternalBackstageCredentials(credentials);
|
|
20
|
+
if (internalCredentials.principal.type !== "user") {
|
|
21
|
+
throw new Error("Only user credentials are supported");
|
|
22
|
+
}
|
|
23
|
+
if (!internalCredentials.token) {
|
|
24
|
+
throw new Error("User credentials is unexpectedly missing token");
|
|
25
|
+
}
|
|
26
|
+
const { sub: userEntityRef, ent: tokenEnt } = jose.decodeJwt(
|
|
27
|
+
internalCredentials.token
|
|
28
|
+
);
|
|
29
|
+
if (typeof userEntityRef !== "string") {
|
|
30
|
+
throw new Error("User entity ref must be a string");
|
|
31
|
+
}
|
|
32
|
+
let ownershipEntityRefs = tokenEnt;
|
|
33
|
+
if (!ownershipEntityRefs) {
|
|
34
|
+
const userInfoResp = await fetch__default.default(
|
|
35
|
+
`${await this.discovery.getBaseUrl("auth")}/v1/userinfo`,
|
|
36
|
+
{
|
|
37
|
+
headers: {
|
|
38
|
+
Authorization: `Bearer ${internalCredentials.token}`
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
if (!userInfoResp.ok) {
|
|
43
|
+
throw await errors.ResponseError.fromResponse(userInfoResp);
|
|
44
|
+
}
|
|
45
|
+
const {
|
|
46
|
+
claims: { ent }
|
|
47
|
+
} = await userInfoResp.json();
|
|
48
|
+
ownershipEntityRefs = ent;
|
|
49
|
+
}
|
|
50
|
+
if (!ownershipEntityRefs) {
|
|
51
|
+
throw new Error("Ownership entity refs can not be determined");
|
|
52
|
+
} else if (!Array.isArray(ownershipEntityRefs) || ownershipEntityRefs.some((ref) => typeof ref !== "string")) {
|
|
53
|
+
throw new Error("Ownership entity refs must be an array of strings");
|
|
54
|
+
}
|
|
55
|
+
return { userEntityRef, ownershipEntityRefs };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const userInfoServiceFactory = backendPluginApi.createServiceFactory({
|
|
60
|
+
service: backendPluginApi.coreServices.userInfo,
|
|
61
|
+
deps: {
|
|
62
|
+
discovery: backendPluginApi.coreServices.discovery
|
|
63
|
+
},
|
|
64
|
+
async factory({ discovery }) {
|
|
65
|
+
return new DefaultUserInfoService({ discovery });
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
exports.userInfoServiceFactory = userInfoServiceFactory;
|
|
70
|
+
//# sourceMappingURL=userInfo.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userInfo.cjs.js","sources":["../src/entrypoints/userInfo/DefaultUserInfoService.ts","../src/entrypoints/userInfo/userInfoServiceFactory.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 UserInfoService,\n BackstageUserInfo,\n DiscoveryService,\n BackstageCredentials,\n} from '@backstage/backend-plugin-api';\nimport { ResponseError } from '@backstage/errors';\nimport { decodeJwt } from 'jose';\nimport fetch from 'node-fetch';\nimport { toInternalBackstageCredentials } from '../auth/helpers';\n\nexport type Options = {\n discovery: DiscoveryService;\n};\n\nexport class DefaultUserInfoService implements UserInfoService {\n private readonly discovery: DiscoveryService;\n\n constructor(options: Options) {\n this.discovery = options.discovery;\n }\n\n async getUserInfo(\n credentials: BackstageCredentials,\n ): Promise<BackstageUserInfo> {\n const internalCredentials = toInternalBackstageCredentials(credentials);\n if (internalCredentials.principal.type !== 'user') {\n throw new Error('Only user credentials are supported');\n }\n if (!internalCredentials.token) {\n throw new Error('User credentials is unexpectedly missing token');\n }\n const { sub: userEntityRef, ent: tokenEnt } = decodeJwt(\n internalCredentials.token,\n );\n\n if (typeof userEntityRef !== 'string') {\n throw new Error('User entity ref must be a string');\n }\n\n let ownershipEntityRefs = tokenEnt;\n\n if (!ownershipEntityRefs) {\n const userInfoResp = await fetch(\n `${await this.discovery.getBaseUrl('auth')}/v1/userinfo`,\n {\n headers: {\n Authorization: `Bearer ${internalCredentials.token}`,\n },\n },\n );\n\n if (!userInfoResp.ok) {\n throw await ResponseError.fromResponse(userInfoResp);\n }\n\n const {\n claims: { ent },\n } = await userInfoResp.json();\n ownershipEntityRefs = ent;\n }\n\n if (!ownershipEntityRefs) {\n throw new Error('Ownership entity refs can not be determined');\n } else if (\n !Array.isArray(ownershipEntityRefs) ||\n ownershipEntityRefs.some(ref => typeof ref !== 'string')\n ) {\n throw new Error('Ownership entity refs must be an array of strings');\n }\n\n return { userEntityRef, ownershipEntityRefs };\n }\n}\n","/*\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 coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { DefaultUserInfoService } from './DefaultUserInfoService';\n\n/**\n * Authenticated user information retrieval.\n *\n * See {@link @backstage/code-plugin-api#UserInfoService}\n * and {@link https://backstage.io/docs/backend-system/core-services/user-info | the service docs}\n * for more information.\n *\n * @public\n */\nexport const userInfoServiceFactory = createServiceFactory({\n service: coreServices.userInfo,\n deps: {\n discovery: coreServices.discovery,\n },\n async factory({ discovery }) {\n return new DefaultUserInfoService({ discovery });\n },\n});\n"],"names":["toInternalBackstageCredentials","decodeJwt","fetch","ResponseError","createServiceFactory","coreServices"],"mappings":";;;;;;;;;;;;AA+BO,MAAM,sBAAkD,CAAA;AAAA,EAC5C,SAAA,CAAA;AAAA,EAEjB,YAAY,OAAkB,EAAA;AAC5B,IAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,SAAA,CAAA;AAAA,GAC3B;AAAA,EAEA,MAAM,YACJ,WAC4B,EAAA;AAC5B,IAAM,MAAA,mBAAA,GAAsBA,uCAA+B,WAAW,CAAA,CAAA;AACtE,IAAI,IAAA,mBAAA,CAAoB,SAAU,CAAA,IAAA,KAAS,MAAQ,EAAA;AACjD,MAAM,MAAA,IAAI,MAAM,qCAAqC,CAAA,CAAA;AAAA,KACvD;AACA,IAAI,IAAA,CAAC,oBAAoB,KAAO,EAAA;AAC9B,MAAM,MAAA,IAAI,MAAM,gDAAgD,CAAA,CAAA;AAAA,KAClE;AACA,IAAA,MAAM,EAAE,GAAA,EAAK,aAAe,EAAA,GAAA,EAAK,UAAa,GAAAC,cAAA;AAAA,MAC5C,mBAAoB,CAAA,KAAA;AAAA,KACtB,CAAA;AAEA,IAAI,IAAA,OAAO,kBAAkB,QAAU,EAAA;AACrC,MAAM,MAAA,IAAI,MAAM,kCAAkC,CAAA,CAAA;AAAA,KACpD;AAEA,IAAA,IAAI,mBAAsB,GAAA,QAAA,CAAA;AAE1B,IAAA,IAAI,CAAC,mBAAqB,EAAA;AACxB,MAAA,MAAM,eAAe,MAAMC,sBAAA;AAAA,QACzB,GAAG,MAAM,IAAA,CAAK,SAAU,CAAA,UAAA,CAAW,MAAM,CAAC,CAAA,YAAA,CAAA;AAAA,QAC1C;AAAA,UACE,OAAS,EAAA;AAAA,YACP,aAAA,EAAe,CAAU,OAAA,EAAA,mBAAA,CAAoB,KAAK,CAAA,CAAA;AAAA,WACpD;AAAA,SACF;AAAA,OACF,CAAA;AAEA,MAAI,IAAA,CAAC,aAAa,EAAI,EAAA;AACpB,QAAM,MAAA,MAAMC,oBAAc,CAAA,YAAA,CAAa,YAAY,CAAA,CAAA;AAAA,OACrD;AAEA,MAAM,MAAA;AAAA,QACJ,MAAA,EAAQ,EAAE,GAAI,EAAA;AAAA,OAChB,GAAI,MAAM,YAAA,CAAa,IAAK,EAAA,CAAA;AAC5B,MAAsB,mBAAA,GAAA,GAAA,CAAA;AAAA,KACxB;AAEA,IAAA,IAAI,CAAC,mBAAqB,EAAA;AACxB,MAAM,MAAA,IAAI,MAAM,6CAA6C,CAAA,CAAA;AAAA,KAE7D,MAAA,IAAA,CAAC,KAAM,CAAA,OAAA,CAAQ,mBAAmB,CAAA,IAClC,mBAAoB,CAAA,IAAA,CAAK,CAAO,GAAA,KAAA,OAAO,GAAQ,KAAA,QAAQ,CACvD,EAAA;AACA,MAAM,MAAA,IAAI,MAAM,mDAAmD,CAAA,CAAA;AAAA,KACrE;AAEA,IAAO,OAAA,EAAE,eAAe,mBAAoB,EAAA,CAAA;AAAA,GAC9C;AACF;;AC1DO,MAAM,yBAAyBC,qCAAqB,CAAA;AAAA,EACzD,SAASC,6BAAa,CAAA,QAAA;AAAA,EACtB,IAAM,EAAA;AAAA,IACJ,WAAWA,6BAAa,CAAA,SAAA;AAAA,GAC1B;AAAA,EACA,MAAM,OAAA,CAAQ,EAAE,SAAA,EAAa,EAAA;AAC3B,IAAA,OAAO,IAAI,sBAAA,CAAuB,EAAE,SAAA,EAAW,CAAA,CAAA;AAAA,GACjD;AACF,CAAC;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Authenticated user information retrieval.
|
|
5
|
+
*
|
|
6
|
+
* See {@link @backstage/code-plugin-api#UserInfoService}
|
|
7
|
+
* and {@link https://backstage.io/docs/backend-system/core-services/user-info | the service docs}
|
|
8
|
+
* for more information.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
declare const userInfoServiceFactory: () => _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api.UserInfoService, "plugin">;
|
|
13
|
+
|
|
14
|
+
export { userInfoServiceFactory };
|
package/lifecycle/package.json
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 The Backstage Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// @ts-check
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param { import("knex").Knex } knex
|
|
21
|
+
* @returns { Promise<void> }
|
|
22
|
+
*/
|
|
23
|
+
exports.up = async function up(knex) {
|
|
24
|
+
await knex.schema.createTable(
|
|
25
|
+
'backstage_backend_public_keys__keys',
|
|
26
|
+
table => {
|
|
27
|
+
table
|
|
28
|
+
.string('id')
|
|
29
|
+
.primary()
|
|
30
|
+
.notNullable()
|
|
31
|
+
.comment('The unique ID of a public key');
|
|
32
|
+
|
|
33
|
+
table.text('key').notNullable().comment('JSON serialized public key');
|
|
34
|
+
|
|
35
|
+
// Expiration is stored as a string for simplicity, all checks are done client-side
|
|
36
|
+
table
|
|
37
|
+
.string('expires_at')
|
|
38
|
+
.notNullable()
|
|
39
|
+
.comment('The time that the key expires');
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param { import("knex").Knex } knex
|
|
46
|
+
* @returns { Promise<void> }
|
|
47
|
+
*/
|
|
48
|
+
exports.down = async function down(knex) {
|
|
49
|
+
return knex.schema.dropTable('backstage_backend_public_keys__keys');
|
|
50
|
+
};
|