@backstage/plugin-auth-backend 0.9.0-next.0 → 0.10.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 +129 -0
- package/dist/index.cjs.js +728 -751
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +31 -123
- package/migrations/20210326100300_timestamptz.js +2 -2
- package/package.json +8 -7
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
|
|
|
@@ -103,6 +103,7 @@ declare type OAuthState = {
|
|
|
103
103
|
nonce: string;
|
|
104
104
|
env: string;
|
|
105
105
|
origin?: string;
|
|
106
|
+
scope?: string;
|
|
106
107
|
};
|
|
107
108
|
declare type OAuthStartRequest = express.Request<{}> & {
|
|
108
109
|
scope: string;
|
|
@@ -177,49 +178,6 @@ declare class CatalogIdentityClient {
|
|
|
177
178
|
resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]>;
|
|
178
179
|
}
|
|
179
180
|
|
|
180
|
-
/**
|
|
181
|
-
* A identity client to interact with auth-backend
|
|
182
|
-
* and authenticate backstage identity tokens
|
|
183
|
-
*
|
|
184
|
-
* @experimental This is not a stable API yet
|
|
185
|
-
*/
|
|
186
|
-
declare class IdentityClient {
|
|
187
|
-
private readonly discovery;
|
|
188
|
-
private readonly issuer;
|
|
189
|
-
private keyStore;
|
|
190
|
-
private keyStoreUpdated;
|
|
191
|
-
constructor(options: {
|
|
192
|
-
discovery: PluginEndpointDiscovery;
|
|
193
|
-
issuer: string;
|
|
194
|
-
});
|
|
195
|
-
/**
|
|
196
|
-
* Verifies the given backstage identity token
|
|
197
|
-
* Returns a BackstageIdentity (user) matching the token.
|
|
198
|
-
* The method throws an error if verification fails.
|
|
199
|
-
*/
|
|
200
|
-
authenticate(token: string | undefined): Promise<BackstageIdentityResponse>;
|
|
201
|
-
/**
|
|
202
|
-
* Parses the given authorization header and returns
|
|
203
|
-
* the bearer token, or null if no bearer token is given
|
|
204
|
-
*/
|
|
205
|
-
static getBearerToken(authorizationHeader: string | undefined): string | undefined;
|
|
206
|
-
/**
|
|
207
|
-
* Returns the public signing key matching the given jwt token,
|
|
208
|
-
* or null if no matching key was found
|
|
209
|
-
*/
|
|
210
|
-
private getKey;
|
|
211
|
-
/**
|
|
212
|
-
* Lists public part of keys used to sign Backstage Identity tokens
|
|
213
|
-
*/
|
|
214
|
-
listPublicKeys(): Promise<{
|
|
215
|
-
keys: JSONWebKey[];
|
|
216
|
-
}>;
|
|
217
|
-
/**
|
|
218
|
-
* Fetches public keys and caches them locally
|
|
219
|
-
*/
|
|
220
|
-
private refreshKeyStore;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
181
|
declare function getEntityClaims(entity: UserEntity): TokenParams['claims'];
|
|
224
182
|
|
|
225
183
|
/**
|
|
@@ -232,6 +190,22 @@ declare type AuthResolverContext = {
|
|
|
232
190
|
catalogIdentityClient: CatalogIdentityClient;
|
|
233
191
|
logger: Logger;
|
|
234
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
|
+
};
|
|
235
209
|
declare type AuthProviderConfig = {
|
|
236
210
|
/**
|
|
237
211
|
* The protocol://domain[:port] where the app is hosted. This is used to construct the
|
|
@@ -246,6 +220,10 @@ declare type AuthProviderConfig = {
|
|
|
246
220
|
* A function that is called to check whether an origin is allowed to receive the authentication result.
|
|
247
221
|
*/
|
|
248
222
|
isOriginAllowed: (origin: string) => boolean;
|
|
223
|
+
/**
|
|
224
|
+
* The function used to resolve cookie configuration based on the auth provider options.
|
|
225
|
+
*/
|
|
226
|
+
cookieConfigurer?: CookieConfigurer;
|
|
249
227
|
};
|
|
250
228
|
declare type RedirectInfo = {
|
|
251
229
|
/**
|
|
@@ -324,77 +302,6 @@ declare type AuthResponse<ProviderInfo> = {
|
|
|
324
302
|
profile: ProfileInfo;
|
|
325
303
|
backstageIdentity?: BackstageIdentityResponse;
|
|
326
304
|
};
|
|
327
|
-
/**
|
|
328
|
-
* User identity information within Backstage.
|
|
329
|
-
*
|
|
330
|
-
* @public
|
|
331
|
-
*/
|
|
332
|
-
declare type BackstageUserIdentity = {
|
|
333
|
-
/**
|
|
334
|
-
* The type of identity that this structure represents. In the frontend app
|
|
335
|
-
* this will currently always be 'user'.
|
|
336
|
-
*/
|
|
337
|
-
type: 'user';
|
|
338
|
-
/**
|
|
339
|
-
* The entityRef of the user in the catalog.
|
|
340
|
-
* For example User:default/sandra
|
|
341
|
-
*/
|
|
342
|
-
userEntityRef: string;
|
|
343
|
-
/**
|
|
344
|
-
* The user and group entities that the user claims ownership through
|
|
345
|
-
*/
|
|
346
|
-
ownershipEntityRefs: string[];
|
|
347
|
-
};
|
|
348
|
-
/**
|
|
349
|
-
* A representation of a successful Backstage sign-in.
|
|
350
|
-
*
|
|
351
|
-
* Compared to the {@link BackstageIdentityResponse} this type omits
|
|
352
|
-
* the decoded identity information embedded in the token.
|
|
353
|
-
*
|
|
354
|
-
* @public
|
|
355
|
-
*/
|
|
356
|
-
interface BackstageSignInResult {
|
|
357
|
-
/**
|
|
358
|
-
* An opaque ID that uniquely identifies the user within Backstage.
|
|
359
|
-
*
|
|
360
|
-
* This is typically the same as the user entity `metadata.name`.
|
|
361
|
-
*
|
|
362
|
-
* @deprecated Use the `identity` field instead
|
|
363
|
-
*/
|
|
364
|
-
id: string;
|
|
365
|
-
/**
|
|
366
|
-
* The entity that the user is represented by within Backstage.
|
|
367
|
-
*
|
|
368
|
-
* This entity may or may not exist within the Catalog, and it can be used
|
|
369
|
-
* to read and store additional metadata about the user.
|
|
370
|
-
*
|
|
371
|
-
* @deprecated Use the `identity` field instead.
|
|
372
|
-
*/
|
|
373
|
-
entity?: Entity;
|
|
374
|
-
/**
|
|
375
|
-
* The token used to authenticate the user within Backstage.
|
|
376
|
-
*/
|
|
377
|
-
token: string;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* The old exported symbol for {@link BackstageSignInResult}.
|
|
381
|
-
*
|
|
382
|
-
* @public
|
|
383
|
-
* @deprecated Use the {@link BackstageSignInResult} instead.
|
|
384
|
-
*/
|
|
385
|
-
declare type BackstageIdentity = BackstageSignInResult;
|
|
386
|
-
/**
|
|
387
|
-
* Response object containing the {@link BackstageUserIdentity} and the token
|
|
388
|
-
* from the authentication provider.
|
|
389
|
-
*
|
|
390
|
-
* @public
|
|
391
|
-
*/
|
|
392
|
-
interface BackstageIdentityResponse extends BackstageSignInResult {
|
|
393
|
-
/**
|
|
394
|
-
* A plaintext description of the identity that is encapsulated within the token.
|
|
395
|
-
*/
|
|
396
|
-
identity: BackstageUserIdentity;
|
|
397
|
-
}
|
|
398
305
|
/**
|
|
399
306
|
* Used to display login information to user, i.e. sidebar popup.
|
|
400
307
|
*
|
|
@@ -438,7 +345,7 @@ declare type SignInInfo<TAuthResult> = {
|
|
|
438
345
|
};
|
|
439
346
|
/**
|
|
440
347
|
* Describes the function which handles the result of a successful
|
|
441
|
-
* authentication. Must return a valid {@link BackstageSignInResult}.
|
|
348
|
+
* authentication. Must return a valid {@link @backstage/plugin-auth-node#BackstageSignInResult}.
|
|
442
349
|
*
|
|
443
350
|
* @public
|
|
444
351
|
*/
|
|
@@ -492,12 +399,13 @@ declare type Options = {
|
|
|
492
399
|
appOrigin: string;
|
|
493
400
|
tokenIssuer: TokenIssuer;
|
|
494
401
|
isOriginAllowed: (origin: string) => boolean;
|
|
495
|
-
callbackUrl
|
|
402
|
+
callbackUrl: string;
|
|
496
403
|
};
|
|
497
404
|
declare class OAuthAdapter implements AuthProviderRouteHandlers {
|
|
498
405
|
private readonly handlers;
|
|
499
406
|
private readonly options;
|
|
500
407
|
static fromConfig(config: AuthProviderConfig, handlers: OAuthHandlers, options: Pick<Options, 'providerId' | 'persistScopes' | 'disableRefresh' | 'tokenIssuer' | 'callbackUrl'>): OAuthAdapter;
|
|
408
|
+
private readonly baseCookieOptions;
|
|
501
409
|
constructor(handlers: OAuthHandlers, options: Options);
|
|
502
410
|
start(req: express.Request, res: express.Response): Promise<void>;
|
|
503
411
|
frameHandler(req: express.Request, res: express.Response): Promise<void>;
|
|
@@ -509,8 +417,8 @@ declare class OAuthAdapter implements AuthProviderRouteHandlers {
|
|
|
509
417
|
*/
|
|
510
418
|
private populateIdentity;
|
|
511
419
|
private setNonceCookie;
|
|
512
|
-
private
|
|
513
|
-
private
|
|
420
|
+
private setGrantedScopeCookie;
|
|
421
|
+
private getGrantedScopeFromCookie;
|
|
514
422
|
private setRefreshTokenCookie;
|
|
515
423
|
private removeRefreshTokenCookie;
|
|
516
424
|
}
|
|
@@ -815,7 +723,7 @@ declare type OidcAuthResult = {
|
|
|
815
723
|
* can be passed while creating a OIDC provider.
|
|
816
724
|
*
|
|
817
725
|
* authHandler : called after sign in was successful, a new object must be returned which includes a profile
|
|
818
|
-
* 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}
|
|
819
727
|
*
|
|
820
728
|
* Both options are optional. There is fallback for authHandler where the default handler expect an e-mail explicitly
|
|
821
729
|
* otherwise it throws an error
|
|
@@ -961,7 +869,7 @@ declare const factories: {
|
|
|
961
869
|
|
|
962
870
|
/**
|
|
963
871
|
* Parses a Backstage-issued token and decorates the
|
|
964
|
-
* {@link BackstageIdentityResponse} with identity information sourced from the
|
|
872
|
+
* {@link @backstage/plugin-auth-node#BackstageIdentityResponse} with identity information sourced from the
|
|
965
873
|
* token.
|
|
966
874
|
*
|
|
967
875
|
* @public
|
|
@@ -997,4 +905,4 @@ declare type WebMessageResponse = {
|
|
|
997
905
|
declare const postMessageResponse: (res: express.Response, appOrigin: string, response: WebMessageResponse) => void;
|
|
998
906
|
declare const ensuresXRequestedWith: (req: express.Request) => boolean;
|
|
999
907
|
|
|
1000
|
-
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.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -30,11 +30,12 @@
|
|
|
30
30
|
"clean": "backstage-cli clean"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@backstage/backend-common": "^0.10.
|
|
34
|
-
"@backstage/catalog-client": "^0.
|
|
33
|
+
"@backstage/backend-common": "^0.10.7",
|
|
34
|
+
"@backstage/catalog-client": "^0.6.0",
|
|
35
35
|
"@backstage/catalog-model": "^0.9.10",
|
|
36
36
|
"@backstage/config": "^0.1.13",
|
|
37
37
|
"@backstage/errors": "^0.2.0",
|
|
38
|
+
"@backstage/plugin-auth-node": "^0.1.0",
|
|
38
39
|
"@backstage/types": "^0.1.1",
|
|
39
40
|
"@google-cloud/firestore": "^5.0.2",
|
|
40
41
|
"@types/express": "^4.17.6",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"helmet": "^4.0.0",
|
|
51
52
|
"jose": "^1.27.1",
|
|
52
53
|
"jwt-decode": "^3.1.0",
|
|
53
|
-
"knex": "^0.
|
|
54
|
+
"knex": "^1.0.2",
|
|
54
55
|
"lodash": "^4.17.21",
|
|
55
56
|
"luxon": "^2.0.2",
|
|
56
57
|
"minimatch": "^3.0.3",
|
|
@@ -73,8 +74,8 @@
|
|
|
73
74
|
"yn": "^4.0.0"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
|
-
"@backstage/cli": "^0.13.
|
|
77
|
-
"@backstage/test-utils": "^0.2.
|
|
77
|
+
"@backstage/cli": "^0.13.2",
|
|
78
|
+
"@backstage/test-utils": "^0.2.4",
|
|
78
79
|
"@types/body-parser": "^1.19.0",
|
|
79
80
|
"@types/cookie-parser": "^1.4.2",
|
|
80
81
|
"@types/express-session": "^1.17.2",
|
|
@@ -94,5 +95,5 @@
|
|
|
94
95
|
"config.d.ts"
|
|
95
96
|
],
|
|
96
97
|
"configSchema": "config.d.ts",
|
|
97
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "4f4bc77a4152d372b10a4e8d97d92f00e23f3b56"
|
|
98
99
|
}
|