@backstage/plugin-auth-backend 0.9.0 → 0.10.2
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 +116 -0
- package/dist/index.cjs.js +661 -730
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +27 -121
- package/migrations/20210326100300_timestamptz.js +2 -2
- package/package.json +24 -21
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { Logger } from 'winston';
|
|
|
4
4
|
import { Config } from '@backstage/config';
|
|
5
5
|
import { TokenManager, PluginEndpointDiscovery, PluginDatabaseManager } from '@backstage/backend-common';
|
|
6
6
|
import { CatalogApi } from '@backstage/catalog-client';
|
|
7
|
-
import {
|
|
7
|
+
import { BackstageSignInResult, BackstageIdentityResponse } from '@backstage/plugin-auth-node';
|
|
8
8
|
import { Profile } from 'passport';
|
|
9
|
-
import {
|
|
9
|
+
import { UserEntity } from '@backstage/catalog-model';
|
|
10
10
|
import { TokenSet, UserinfoResponse } from 'openid-client';
|
|
11
11
|
import { JsonValue } from '@backstage/types';
|
|
12
12
|
|
|
@@ -178,49 +178,6 @@ declare class CatalogIdentityClient {
|
|
|
178
178
|
resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]>;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
/**
|
|
182
|
-
* A identity client to interact with auth-backend
|
|
183
|
-
* and authenticate backstage identity tokens
|
|
184
|
-
*
|
|
185
|
-
* @experimental This is not a stable API yet
|
|
186
|
-
*/
|
|
187
|
-
declare class IdentityClient {
|
|
188
|
-
private readonly discovery;
|
|
189
|
-
private readonly issuer;
|
|
190
|
-
private keyStore;
|
|
191
|
-
private keyStoreUpdated;
|
|
192
|
-
constructor(options: {
|
|
193
|
-
discovery: PluginEndpointDiscovery;
|
|
194
|
-
issuer: string;
|
|
195
|
-
});
|
|
196
|
-
/**
|
|
197
|
-
* Verifies the given backstage identity token
|
|
198
|
-
* Returns a BackstageIdentity (user) matching the token.
|
|
199
|
-
* The method throws an error if verification fails.
|
|
200
|
-
*/
|
|
201
|
-
authenticate(token: string | undefined): Promise<BackstageIdentityResponse>;
|
|
202
|
-
/**
|
|
203
|
-
* Parses the given authorization header and returns
|
|
204
|
-
* the bearer token, or null if no bearer token is given
|
|
205
|
-
*/
|
|
206
|
-
static getBearerToken(authorizationHeader: string | undefined): string | undefined;
|
|
207
|
-
/**
|
|
208
|
-
* Returns the public signing key matching the given jwt token,
|
|
209
|
-
* or null if no matching key was found
|
|
210
|
-
*/
|
|
211
|
-
private getKey;
|
|
212
|
-
/**
|
|
213
|
-
* Lists public part of keys used to sign Backstage Identity tokens
|
|
214
|
-
*/
|
|
215
|
-
listPublicKeys(): Promise<{
|
|
216
|
-
keys: JSONWebKey[];
|
|
217
|
-
}>;
|
|
218
|
-
/**
|
|
219
|
-
* Fetches public keys and caches them locally
|
|
220
|
-
*/
|
|
221
|
-
private refreshKeyStore;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
181
|
declare function getEntityClaims(entity: UserEntity): TokenParams['claims'];
|
|
225
182
|
|
|
226
183
|
/**
|
|
@@ -233,6 +190,22 @@ declare type AuthResolverContext = {
|
|
|
233
190
|
catalogIdentityClient: CatalogIdentityClient;
|
|
234
191
|
logger: Logger;
|
|
235
192
|
};
|
|
193
|
+
/**
|
|
194
|
+
* The callback used to resolve the cookie configuration for auth providers that use cookies.
|
|
195
|
+
* @public
|
|
196
|
+
*/
|
|
197
|
+
declare type CookieConfigurer = (ctx: {
|
|
198
|
+
/** ID of the auth provider that this configuration applies to */
|
|
199
|
+
providerId: string;
|
|
200
|
+
/** The externally reachable base URL of the auth-backend plugin */
|
|
201
|
+
baseUrl: string;
|
|
202
|
+
/** The configured callback URL of the auth provider */
|
|
203
|
+
callbackUrl: string;
|
|
204
|
+
}) => {
|
|
205
|
+
domain: string;
|
|
206
|
+
path: string;
|
|
207
|
+
secure: boolean;
|
|
208
|
+
};
|
|
236
209
|
declare type AuthProviderConfig = {
|
|
237
210
|
/**
|
|
238
211
|
* The protocol://domain[:port] where the app is hosted. This is used to construct the
|
|
@@ -247,6 +220,10 @@ declare type AuthProviderConfig = {
|
|
|
247
220
|
* A function that is called to check whether an origin is allowed to receive the authentication result.
|
|
248
221
|
*/
|
|
249
222
|
isOriginAllowed: (origin: string) => boolean;
|
|
223
|
+
/**
|
|
224
|
+
* The function used to resolve cookie configuration based on the auth provider options.
|
|
225
|
+
*/
|
|
226
|
+
cookieConfigurer?: CookieConfigurer;
|
|
250
227
|
};
|
|
251
228
|
declare type RedirectInfo = {
|
|
252
229
|
/**
|
|
@@ -325,77 +302,6 @@ declare type AuthResponse<ProviderInfo> = {
|
|
|
325
302
|
profile: ProfileInfo;
|
|
326
303
|
backstageIdentity?: BackstageIdentityResponse;
|
|
327
304
|
};
|
|
328
|
-
/**
|
|
329
|
-
* User identity information within Backstage.
|
|
330
|
-
*
|
|
331
|
-
* @public
|
|
332
|
-
*/
|
|
333
|
-
declare type BackstageUserIdentity = {
|
|
334
|
-
/**
|
|
335
|
-
* The type of identity that this structure represents. In the frontend app
|
|
336
|
-
* this will currently always be 'user'.
|
|
337
|
-
*/
|
|
338
|
-
type: 'user';
|
|
339
|
-
/**
|
|
340
|
-
* The entityRef of the user in the catalog.
|
|
341
|
-
* For example User:default/sandra
|
|
342
|
-
*/
|
|
343
|
-
userEntityRef: string;
|
|
344
|
-
/**
|
|
345
|
-
* The user and group entities that the user claims ownership through
|
|
346
|
-
*/
|
|
347
|
-
ownershipEntityRefs: string[];
|
|
348
|
-
};
|
|
349
|
-
/**
|
|
350
|
-
* A representation of a successful Backstage sign-in.
|
|
351
|
-
*
|
|
352
|
-
* Compared to the {@link BackstageIdentityResponse} this type omits
|
|
353
|
-
* the decoded identity information embedded in the token.
|
|
354
|
-
*
|
|
355
|
-
* @public
|
|
356
|
-
*/
|
|
357
|
-
interface BackstageSignInResult {
|
|
358
|
-
/**
|
|
359
|
-
* An opaque ID that uniquely identifies the user within Backstage.
|
|
360
|
-
*
|
|
361
|
-
* This is typically the same as the user entity `metadata.name`.
|
|
362
|
-
*
|
|
363
|
-
* @deprecated Use the `identity` field instead
|
|
364
|
-
*/
|
|
365
|
-
id: string;
|
|
366
|
-
/**
|
|
367
|
-
* The entity that the user is represented by within Backstage.
|
|
368
|
-
*
|
|
369
|
-
* This entity may or may not exist within the Catalog, and it can be used
|
|
370
|
-
* to read and store additional metadata about the user.
|
|
371
|
-
*
|
|
372
|
-
* @deprecated Use the `identity` field instead.
|
|
373
|
-
*/
|
|
374
|
-
entity?: Entity;
|
|
375
|
-
/**
|
|
376
|
-
* The token used to authenticate the user within Backstage.
|
|
377
|
-
*/
|
|
378
|
-
token: string;
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* The old exported symbol for {@link BackstageSignInResult}.
|
|
382
|
-
*
|
|
383
|
-
* @public
|
|
384
|
-
* @deprecated Use the {@link BackstageSignInResult} instead.
|
|
385
|
-
*/
|
|
386
|
-
declare type BackstageIdentity = BackstageSignInResult;
|
|
387
|
-
/**
|
|
388
|
-
* Response object containing the {@link BackstageUserIdentity} and the token
|
|
389
|
-
* from the authentication provider.
|
|
390
|
-
*
|
|
391
|
-
* @public
|
|
392
|
-
*/
|
|
393
|
-
interface BackstageIdentityResponse extends BackstageSignInResult {
|
|
394
|
-
/**
|
|
395
|
-
* A plaintext description of the identity that is encapsulated within the token.
|
|
396
|
-
*/
|
|
397
|
-
identity: BackstageUserIdentity;
|
|
398
|
-
}
|
|
399
305
|
/**
|
|
400
306
|
* Used to display login information to user, i.e. sidebar popup.
|
|
401
307
|
*
|
|
@@ -439,7 +345,7 @@ declare type SignInInfo<TAuthResult> = {
|
|
|
439
345
|
};
|
|
440
346
|
/**
|
|
441
347
|
* Describes the function which handles the result of a successful
|
|
442
|
-
* authentication. Must return a valid {@link BackstageSignInResult}.
|
|
348
|
+
* authentication. Must return a valid {@link @backstage/plugin-auth-node#BackstageSignInResult}.
|
|
443
349
|
*
|
|
444
350
|
* @public
|
|
445
351
|
*/
|
|
@@ -493,7 +399,7 @@ declare type Options = {
|
|
|
493
399
|
appOrigin: string;
|
|
494
400
|
tokenIssuer: TokenIssuer;
|
|
495
401
|
isOriginAllowed: (origin: string) => boolean;
|
|
496
|
-
callbackUrl
|
|
402
|
+
callbackUrl: string;
|
|
497
403
|
};
|
|
498
404
|
declare class OAuthAdapter implements AuthProviderRouteHandlers {
|
|
499
405
|
private readonly handlers;
|
|
@@ -817,7 +723,7 @@ declare type OidcAuthResult = {
|
|
|
817
723
|
* can be passed while creating a OIDC provider.
|
|
818
724
|
*
|
|
819
725
|
* authHandler : called after sign in was successful, a new object must be returned which includes a profile
|
|
820
|
-
* signInResolver: called after sign in was successful, expects to return a new {@link BackstageSignInResult}
|
|
726
|
+
* signInResolver: called after sign in was successful, expects to return a new {@link @backstage/plugin-auth-node#BackstageSignInResult}
|
|
821
727
|
*
|
|
822
728
|
* Both options are optional. There is fallback for authHandler where the default handler expect an e-mail explicitly
|
|
823
729
|
* otherwise it throws an error
|
|
@@ -963,7 +869,7 @@ declare const factories: {
|
|
|
963
869
|
|
|
964
870
|
/**
|
|
965
871
|
* Parses a Backstage-issued token and decorates the
|
|
966
|
-
* {@link BackstageIdentityResponse} with identity information sourced from the
|
|
872
|
+
* {@link @backstage/plugin-auth-node#BackstageIdentityResponse} with identity information sourced from the
|
|
967
873
|
* token.
|
|
968
874
|
*
|
|
969
875
|
* @public
|
|
@@ -999,4 +905,4 @@ declare type WebMessageResponse = {
|
|
|
999
905
|
declare const postMessageResponse: (res: express.Response, appOrigin: string, response: WebMessageResponse) => void;
|
|
1000
906
|
declare const ensuresXRequestedWith: (req: express.Request) => boolean;
|
|
1001
907
|
|
|
1002
|
-
export { AtlassianAuthProvider, AtlassianProviderOptions, Auth0ProviderOptions, AuthHandler, AuthHandlerResult, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResolverContext, AuthResponse, AwsAlbProviderOptions,
|
|
908
|
+
export { AtlassianAuthProvider, AtlassianProviderOptions, Auth0ProviderOptions, AuthHandler, AuthHandlerResult, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResolverContext, AuthResponse, AwsAlbProviderOptions, BitbucketOAuthResult, BitbucketPassportProfile, BitbucketProviderOptions, CatalogIdentityClient, CookieConfigurer, GcpIapProviderOptions, GcpIapResult, GcpIapTokenInfo, GithubOAuthResult, GithubProviderOptions, GitlabProviderOptions, GoogleProviderOptions, MicrosoftProviderOptions, OAuth2ProviderOptions, OAuth2ProxyResult, OAuthAdapter, OAuthEnvironmentHandler, OAuthHandlers, OAuthProviderInfo, OAuthProviderOptions, OAuthRefreshRequest, OAuthResponse, OAuthResult, OAuthStartRequest, OAuthState, Oauth2ProxyProviderOptions, OidcAuthResult, OidcProviderOptions, OktaProviderOptions, OneLoginProviderOptions, ProfileInfo, RouterOptions, SamlAuthResult, SamlProviderOptions, SignInInfo, SignInResolver, TokenIssuer, WebMessageResponse, bitbucketUserIdSignInResolver, bitbucketUsernameSignInResolver, createAtlassianProvider, createAuth0Provider, createAwsAlbProvider, createBitbucketProvider, createGcpIapProvider, createGithubProvider, createGitlabProvider, createGoogleProvider, createMicrosoftProvider, createOAuth2Provider, createOauth2ProxyProvider, createOidcProvider, createOktaProvider, createOneLoginProvider, createOriginFilter, createRouter, createSamlProvider, factories as defaultAuthProviderFactories, encodeState, ensuresXRequestedWith, getEntityClaims, googleEmailSignInResolver, microsoftEmailSignInResolver, oktaEmailSignInResolver, postMessageResponse, prepareBackstageIdentityResponse, readState, verifyNonce };
|
|
@@ -28,7 +28,7 @@ exports.up = async function up(knex) {
|
|
|
28
28
|
.notNullable()
|
|
29
29
|
.defaultTo(knex.fn.now())
|
|
30
30
|
.comment('The creation time of the key')
|
|
31
|
-
.alter();
|
|
31
|
+
.alter({ alterType: true });
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
};
|
|
@@ -45,7 +45,7 @@ exports.down = async function down(knex) {
|
|
|
45
45
|
.notNullable()
|
|
46
46
|
.defaultTo(knex.fn.now())
|
|
47
47
|
.comment('The creation time of the key')
|
|
48
|
-
.alter();
|
|
48
|
+
.alter({ alterType: true });
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-auth-backend",
|
|
3
3
|
"description": "A Backstage backend plugin that handles authentication",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.2",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"main": "dist/index.cjs.js",
|
|
12
12
|
"types": "dist/index.d.ts"
|
|
13
13
|
},
|
|
14
|
+
"backstage": {
|
|
15
|
+
"role": "backend-plugin"
|
|
16
|
+
},
|
|
14
17
|
"homepage": "https://backstage.io",
|
|
15
18
|
"repository": {
|
|
16
19
|
"type": "git",
|
|
@@ -21,21 +24,22 @@
|
|
|
21
24
|
"backstage"
|
|
22
25
|
],
|
|
23
26
|
"scripts": {
|
|
24
|
-
"start": "backstage-cli
|
|
25
|
-
"build": "backstage-cli
|
|
26
|
-
"lint": "backstage-cli lint",
|
|
27
|
-
"test": "backstage-cli test",
|
|
28
|
-
"prepack": "backstage-cli prepack",
|
|
29
|
-
"postpack": "backstage-cli postpack",
|
|
30
|
-
"clean": "backstage-cli clean"
|
|
27
|
+
"start": "backstage-cli package start",
|
|
28
|
+
"build": "backstage-cli package build",
|
|
29
|
+
"lint": "backstage-cli package lint",
|
|
30
|
+
"test": "backstage-cli package test",
|
|
31
|
+
"prepack": "backstage-cli package prepack",
|
|
32
|
+
"postpack": "backstage-cli package postpack",
|
|
33
|
+
"clean": "backstage-cli package clean"
|
|
31
34
|
},
|
|
32
35
|
"dependencies": {
|
|
33
|
-
"@backstage/backend-common": "^0.10.
|
|
34
|
-
"@backstage/catalog-client": "^0.
|
|
35
|
-
"@backstage/catalog-model": "^0.
|
|
36
|
-
"@backstage/config": "^0.1.
|
|
37
|
-
"@backstage/errors": "^0.2.
|
|
38
|
-
"@backstage/
|
|
36
|
+
"@backstage/backend-common": "^0.10.9",
|
|
37
|
+
"@backstage/catalog-client": "^0.7.1",
|
|
38
|
+
"@backstage/catalog-model": "^0.10.1",
|
|
39
|
+
"@backstage/config": "^0.1.15",
|
|
40
|
+
"@backstage/errors": "^0.2.2",
|
|
41
|
+
"@backstage/plugin-auth-node": "^0.1.2",
|
|
42
|
+
"@backstage/types": "^0.1.3",
|
|
39
43
|
"@google-cloud/firestore": "^5.0.2",
|
|
40
44
|
"@types/express": "^4.17.6",
|
|
41
45
|
"@types/passport": "^1.0.3",
|
|
@@ -47,16 +51,15 @@
|
|
|
47
51
|
"express-session": "^1.17.1",
|
|
48
52
|
"fs-extra": "9.1.0",
|
|
49
53
|
"google-auth-library": "^7.6.1",
|
|
50
|
-
"helmet": "^4.0.0",
|
|
51
54
|
"jose": "^1.27.1",
|
|
52
55
|
"jwt-decode": "^3.1.0",
|
|
53
|
-
"knex": "^0.
|
|
56
|
+
"knex": "^1.0.2",
|
|
54
57
|
"lodash": "^4.17.21",
|
|
55
58
|
"luxon": "^2.0.2",
|
|
56
59
|
"minimatch": "^3.0.3",
|
|
57
60
|
"morgan": "^1.10.0",
|
|
58
61
|
"node-cache": "^5.1.2",
|
|
59
|
-
"node-fetch": "^2.6.
|
|
62
|
+
"node-fetch": "^2.6.7",
|
|
60
63
|
"openid-client": "^4.2.1",
|
|
61
64
|
"passport": "^0.5.2",
|
|
62
65
|
"passport-bitbucket-oauth2": "^0.1.2",
|
|
@@ -64,7 +67,7 @@
|
|
|
64
67
|
"passport-gitlab2": "^5.0.0",
|
|
65
68
|
"passport-google-oauth20": "^2.0.0",
|
|
66
69
|
"passport-microsoft": "^0.1.0",
|
|
67
|
-
"passport-oauth2": "^1.
|
|
70
|
+
"passport-oauth2": "^1.6.1",
|
|
68
71
|
"passport-okta-oauth": "^0.0.1",
|
|
69
72
|
"passport-onelogin-oauth": "^0.0.1",
|
|
70
73
|
"passport-saml": "^3.1.2",
|
|
@@ -73,8 +76,8 @@
|
|
|
73
76
|
"yn": "^4.0.0"
|
|
74
77
|
},
|
|
75
78
|
"devDependencies": {
|
|
76
|
-
"@backstage/cli": "^0.
|
|
77
|
-
"@backstage/test-utils": "^0.2.
|
|
79
|
+
"@backstage/cli": "^0.14.0",
|
|
80
|
+
"@backstage/test-utils": "^0.2.5",
|
|
78
81
|
"@types/body-parser": "^1.19.0",
|
|
79
82
|
"@types/cookie-parser": "^1.4.2",
|
|
80
83
|
"@types/express-session": "^1.17.2",
|
|
@@ -94,5 +97,5 @@
|
|
|
94
97
|
"config.d.ts"
|
|
95
98
|
],
|
|
96
99
|
"configSchema": "config.d.ts",
|
|
97
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "e244b348c473700e7d5e5fbcef38bd9f9fd1d0ba"
|
|
98
101
|
}
|