@backstage/plugin-auth-backend 0.5.1 → 0.6.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 +75 -0
- package/dist/index.cjs.js +1218 -1050
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +238 -133
- package/package.json +13 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { Logger } from 'winston';
|
|
4
|
+
import { Config } from '@backstage/config';
|
|
4
5
|
import { PluginEndpointDiscovery, PluginDatabaseManager } from '@backstage/backend-common';
|
|
5
6
|
import { CatalogApi } from '@backstage/catalog-client';
|
|
6
7
|
import { UserEntity, Entity } from '@backstage/catalog-model';
|
|
7
|
-
import { Config } from '@backstage/config';
|
|
8
8
|
import { Profile } from 'passport';
|
|
9
9
|
import { JSONWebKey } from 'jose';
|
|
10
10
|
import { TokenSet, UserinfoResponse } from 'openid-client';
|
|
11
|
+
import { JsonValue } from '@backstage/types';
|
|
11
12
|
|
|
12
13
|
/** Represents any form of serializable JWK */
|
|
13
14
|
interface AnyJWK extends Record<string, string> {
|
|
@@ -97,10 +98,6 @@ declare type OAuthProviderInfo = {
|
|
|
97
98
|
* Scopes granted for the access token.
|
|
98
99
|
*/
|
|
99
100
|
scope: string;
|
|
100
|
-
/**
|
|
101
|
-
* A refresh token issued for the signed in user
|
|
102
|
-
*/
|
|
103
|
-
refreshToken?: string;
|
|
104
101
|
};
|
|
105
102
|
declare type OAuthState = {
|
|
106
103
|
nonce: string;
|
|
@@ -119,17 +116,16 @@ declare type OAuthRefreshRequest = express.Request<{}> & {
|
|
|
119
116
|
* Any OAuth provider needs to implement this interface which has provider specific
|
|
120
117
|
* handlers for different methods to perform authentication, get access tokens,
|
|
121
118
|
* refresh tokens and perform sign out.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
122
121
|
*/
|
|
123
122
|
interface OAuthHandlers {
|
|
124
123
|
/**
|
|
125
|
-
*
|
|
126
|
-
* @param {express.Request} req
|
|
127
|
-
* @param options
|
|
124
|
+
* Initiate a sign in request with an auth provider.
|
|
128
125
|
*/
|
|
129
126
|
start(req: OAuthStartRequest): Promise<RedirectInfo>;
|
|
130
127
|
/**
|
|
131
|
-
*
|
|
132
|
-
* @param {express.Request} req
|
|
128
|
+
* Handle the redirect from the auth provider when the user has signed in.
|
|
133
129
|
*/
|
|
134
130
|
handler(req: express.Request): Promise<{
|
|
135
131
|
response: OAuthResponse;
|
|
@@ -137,10 +133,11 @@ interface OAuthHandlers {
|
|
|
137
133
|
}>;
|
|
138
134
|
/**
|
|
139
135
|
* (Optional) Given a refresh token and scope fetches a new access token from the auth provider.
|
|
140
|
-
* @param {string} refreshToken
|
|
141
|
-
* @param {string} scope
|
|
142
136
|
*/
|
|
143
|
-
refresh?(req: OAuthRefreshRequest): Promise<
|
|
137
|
+
refresh?(req: OAuthRefreshRequest): Promise<{
|
|
138
|
+
response: OAuthResponse;
|
|
139
|
+
refreshToken?: string;
|
|
140
|
+
}>;
|
|
144
141
|
/**
|
|
145
142
|
* (Optional) Sign out of the auth provider.
|
|
146
143
|
*/
|
|
@@ -256,10 +253,10 @@ declare type RedirectInfo = {
|
|
|
256
253
|
*
|
|
257
254
|
* The routes in the auth backend API are tied to these methods like below
|
|
258
255
|
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
256
|
+
* `/auth/[provider]/start -> start`
|
|
257
|
+
* `/auth/[provider]/handler/frame -> frameHandler`
|
|
258
|
+
* `/auth/[provider]/refresh -> refresh`
|
|
259
|
+
* `/auth/[provider]/logout -> logout`
|
|
263
260
|
*/
|
|
264
261
|
interface AuthProviderRouteHandlers {
|
|
265
262
|
/**
|
|
@@ -270,9 +267,6 @@ interface AuthProviderRouteHandlers {
|
|
|
270
267
|
* Response
|
|
271
268
|
* - redirect to the auth provider for the user to sign in or consent.
|
|
272
269
|
* - sets a nonce cookie and also pass the nonce as 'state' query parameter in the redirect request
|
|
273
|
-
*
|
|
274
|
-
* @param {express.Request} req
|
|
275
|
-
* @param {express.Response} res
|
|
276
270
|
*/
|
|
277
271
|
start(req: express.Request, res: express.Response): Promise<void>;
|
|
278
272
|
/**
|
|
@@ -284,9 +278,6 @@ interface AuthProviderRouteHandlers {
|
|
|
284
278
|
* Response
|
|
285
279
|
* - postMessage to the window with a payload that contains accessToken, expiryInSeconds?, idToken? and scope.
|
|
286
280
|
* - sets a refresh token cookie if the auth provider supports refresh tokens
|
|
287
|
-
*
|
|
288
|
-
* @param {express.Request} req
|
|
289
|
-
* @param {express.Response} res
|
|
290
281
|
*/
|
|
291
282
|
frameHandler(req: express.Request, res: express.Response): Promise<void>;
|
|
292
283
|
/**
|
|
@@ -297,9 +288,6 @@ interface AuthProviderRouteHandlers {
|
|
|
297
288
|
* - to contain a refresh token cookie and scope (Optional) query parameter.
|
|
298
289
|
* Response
|
|
299
290
|
* - payload with accessToken, expiryInSeconds?, idToken?, scope and user profile information.
|
|
300
|
-
*
|
|
301
|
-
* @param {express.Request} req
|
|
302
|
-
* @param {express.Response} res
|
|
303
291
|
*/
|
|
304
292
|
refresh?(req: express.Request, res: express.Response): Promise<void>;
|
|
305
293
|
/**
|
|
@@ -307,9 +295,6 @@ interface AuthProviderRouteHandlers {
|
|
|
307
295
|
*
|
|
308
296
|
* Response
|
|
309
297
|
* - removes the refresh token cookie
|
|
310
|
-
*
|
|
311
|
-
* @param {express.Request} req
|
|
312
|
-
* @param {express.Response} res
|
|
313
298
|
*/
|
|
314
299
|
logout?(req: express.Request, res: express.Response): Promise<void>;
|
|
315
300
|
}
|
|
@@ -382,12 +367,15 @@ interface BackstageSignInResult {
|
|
|
382
367
|
}
|
|
383
368
|
/**
|
|
384
369
|
* The old exported symbol for {@link BackstageSignInResult}.
|
|
370
|
+
*
|
|
385
371
|
* @public
|
|
386
|
-
* @deprecated Use the
|
|
372
|
+
* @deprecated Use the {@link BackstageSignInResult} instead.
|
|
387
373
|
*/
|
|
388
374
|
declare type BackstageIdentity = BackstageSignInResult;
|
|
389
375
|
/**
|
|
390
|
-
* Response object containing the {@link BackstageUserIdentity} and the token
|
|
376
|
+
* Response object containing the {@link BackstageUserIdentity} and the token
|
|
377
|
+
* from the authentication provider.
|
|
378
|
+
*
|
|
391
379
|
* @public
|
|
392
380
|
*/
|
|
393
381
|
interface BackstageIdentityResponse extends BackstageSignInResult {
|
|
@@ -400,7 +388,8 @@ interface BackstageIdentityResponse extends BackstageSignInResult {
|
|
|
400
388
|
* Used to display login information to user, i.e. sidebar popup.
|
|
401
389
|
*
|
|
402
390
|
* It is also temporarily used as the profile of the signed-in user's Backstage
|
|
403
|
-
* identity, but we want to replace that with data from identity and/org catalog
|
|
391
|
+
* identity, but we want to replace that with data from identity and/org catalog
|
|
392
|
+
* service
|
|
404
393
|
*
|
|
405
394
|
* @public
|
|
406
395
|
*/
|
|
@@ -420,47 +409,56 @@ declare type ProfileInfo = {
|
|
|
420
409
|
picture?: string;
|
|
421
410
|
};
|
|
422
411
|
/**
|
|
423
|
-
*
|
|
412
|
+
* Type of sign in information context. Includes the profile information and
|
|
413
|
+
* authentication result which contains auth related information.
|
|
414
|
+
*
|
|
424
415
|
* @public
|
|
425
416
|
*/
|
|
426
|
-
declare type SignInInfo<
|
|
417
|
+
declare type SignInInfo<TAuthResult> = {
|
|
427
418
|
/**
|
|
428
419
|
* The simple profile passed down for use in the frontend.
|
|
429
420
|
*/
|
|
430
421
|
profile: ProfileInfo;
|
|
431
422
|
/**
|
|
432
|
-
* The authentication result that was received from the authentication
|
|
423
|
+
* The authentication result that was received from the authentication
|
|
424
|
+
* provider.
|
|
433
425
|
*/
|
|
434
|
-
result:
|
|
426
|
+
result: TAuthResult;
|
|
435
427
|
};
|
|
436
428
|
/**
|
|
437
|
-
*
|
|
438
|
-
*
|
|
429
|
+
* Describes the function which handles the result of a successful
|
|
430
|
+
* authentication. Must return a valid {@link BackstageSignInResult}.
|
|
431
|
+
*
|
|
439
432
|
* @public
|
|
440
433
|
*/
|
|
441
|
-
declare type SignInResolver<
|
|
434
|
+
declare type SignInResolver<TAuthResult> = (info: SignInInfo<TAuthResult>, context: {
|
|
442
435
|
tokenIssuer: TokenIssuer;
|
|
443
436
|
catalogIdentityClient: CatalogIdentityClient;
|
|
444
437
|
logger: Logger;
|
|
445
438
|
}) => Promise<BackstageSignInResult>;
|
|
446
439
|
/**
|
|
447
|
-
* The return type of authentication handler
|
|
440
|
+
* The return type of an authentication handler. Must contain valid profile
|
|
441
|
+
* information.
|
|
442
|
+
*
|
|
448
443
|
* @public
|
|
449
444
|
*/
|
|
450
445
|
declare type AuthHandlerResult = {
|
|
451
446
|
profile: ProfileInfo;
|
|
452
447
|
};
|
|
453
448
|
/**
|
|
454
|
-
* The AuthHandler function is called every time the user authenticates using
|
|
449
|
+
* The AuthHandler function is called every time the user authenticates using
|
|
450
|
+
* the provider.
|
|
455
451
|
*
|
|
456
|
-
* The handler should return a profile that represents the session for the user
|
|
452
|
+
* The handler should return a profile that represents the session for the user
|
|
453
|
+
* in the frontend.
|
|
457
454
|
*
|
|
458
|
-
* Throwing an error in the function will cause the authentication to fail,
|
|
459
|
-
* possible to use this function as a way to limit access to a certain
|
|
455
|
+
* Throwing an error in the function will cause the authentication to fail,
|
|
456
|
+
* making it possible to use this function as a way to limit access to a certain
|
|
457
|
+
* group of users.
|
|
460
458
|
*
|
|
461
459
|
* @public
|
|
462
460
|
*/
|
|
463
|
-
declare type AuthHandler<
|
|
461
|
+
declare type AuthHandler<TAuthResult> = (input: TAuthResult) => Promise<AuthHandlerResult>;
|
|
464
462
|
declare type StateEncoder = (req: OAuthStartRequest) => Promise<{
|
|
465
463
|
encodedState: string;
|
|
466
464
|
}>;
|
|
@@ -513,6 +511,134 @@ declare const readState: (stateString: string) => OAuthState;
|
|
|
513
511
|
declare const encodeState: (state: OAuthState) => string;
|
|
514
512
|
declare const verifyNonce: (req: express.Request, providerId: string) => void;
|
|
515
513
|
|
|
514
|
+
declare type AtlassianAuthProviderOptions = OAuthProviderOptions & {
|
|
515
|
+
scopes: string;
|
|
516
|
+
signInResolver?: SignInResolver<OAuthResult>;
|
|
517
|
+
authHandler: AuthHandler<OAuthResult>;
|
|
518
|
+
tokenIssuer: TokenIssuer;
|
|
519
|
+
catalogIdentityClient: CatalogIdentityClient;
|
|
520
|
+
logger: Logger;
|
|
521
|
+
};
|
|
522
|
+
declare class AtlassianAuthProvider implements OAuthHandlers {
|
|
523
|
+
private readonly _strategy;
|
|
524
|
+
private readonly signInResolver?;
|
|
525
|
+
private readonly authHandler;
|
|
526
|
+
private readonly tokenIssuer;
|
|
527
|
+
private readonly catalogIdentityClient;
|
|
528
|
+
private readonly logger;
|
|
529
|
+
constructor(options: AtlassianAuthProviderOptions);
|
|
530
|
+
start(req: OAuthStartRequest): Promise<RedirectInfo>;
|
|
531
|
+
handler(req: express.Request): Promise<{
|
|
532
|
+
response: OAuthResponse;
|
|
533
|
+
refreshToken: string | undefined;
|
|
534
|
+
}>;
|
|
535
|
+
private handleResult;
|
|
536
|
+
refresh(req: OAuthRefreshRequest): Promise<{
|
|
537
|
+
response: OAuthResponse;
|
|
538
|
+
refreshToken: string | undefined;
|
|
539
|
+
}>;
|
|
540
|
+
}
|
|
541
|
+
declare type AtlassianProviderOptions = {
|
|
542
|
+
/**
|
|
543
|
+
* The profile transformation function used to verify and convert the auth response
|
|
544
|
+
* into the profile that will be presented to the user.
|
|
545
|
+
*/
|
|
546
|
+
authHandler?: AuthHandler<OAuthResult>;
|
|
547
|
+
/**
|
|
548
|
+
* Configure sign-in for this provider, without it the provider can not be used to sign users in.
|
|
549
|
+
*/
|
|
550
|
+
signIn?: {
|
|
551
|
+
resolver: SignInResolver<OAuthResult>;
|
|
552
|
+
};
|
|
553
|
+
};
|
|
554
|
+
declare const createAtlassianProvider: (options?: AtlassianProviderOptions | undefined) => AuthProviderFactory;
|
|
555
|
+
|
|
556
|
+
/** @public */
|
|
557
|
+
declare type Auth0ProviderOptions = {
|
|
558
|
+
/**
|
|
559
|
+
* The profile transformation function used to verify and convert the auth response
|
|
560
|
+
* into the profile that will be presented to the user.
|
|
561
|
+
*/
|
|
562
|
+
authHandler?: AuthHandler<OAuthResult>;
|
|
563
|
+
/**
|
|
564
|
+
* Configure sign-in for this provider, without it the provider can not be used to sign users in.
|
|
565
|
+
*/
|
|
566
|
+
signIn?: {
|
|
567
|
+
/**
|
|
568
|
+
* Maps an auth result to a Backstage identity for the user.
|
|
569
|
+
*/
|
|
570
|
+
resolver: SignInResolver<OAuthResult>;
|
|
571
|
+
};
|
|
572
|
+
};
|
|
573
|
+
/** @public */
|
|
574
|
+
declare const createAuth0Provider: (options?: Auth0ProviderOptions | undefined) => AuthProviderFactory;
|
|
575
|
+
|
|
576
|
+
declare type AwsAlbResult = {
|
|
577
|
+
fullProfile: Profile;
|
|
578
|
+
expiresInSeconds?: number;
|
|
579
|
+
accessToken: string;
|
|
580
|
+
};
|
|
581
|
+
declare type AwsAlbProviderOptions = {
|
|
582
|
+
/**
|
|
583
|
+
* The profile transformation function used to verify and convert the auth response
|
|
584
|
+
* into the profile that will be presented to the user.
|
|
585
|
+
*/
|
|
586
|
+
authHandler?: AuthHandler<AwsAlbResult>;
|
|
587
|
+
/**
|
|
588
|
+
* Configure sign-in for this provider, without it the provider can not be used to sign users in.
|
|
589
|
+
*/
|
|
590
|
+
signIn: {
|
|
591
|
+
/**
|
|
592
|
+
* Maps an auth result to a Backstage identity for the user.
|
|
593
|
+
*/
|
|
594
|
+
resolver: SignInResolver<AwsAlbResult>;
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
declare const createAwsAlbProvider: (options?: AwsAlbProviderOptions | undefined) => AuthProviderFactory;
|
|
598
|
+
|
|
599
|
+
declare type BitbucketOAuthResult = {
|
|
600
|
+
fullProfile: BitbucketPassportProfile;
|
|
601
|
+
params: {
|
|
602
|
+
id_token?: string;
|
|
603
|
+
scope: string;
|
|
604
|
+
expires_in: number;
|
|
605
|
+
};
|
|
606
|
+
accessToken: string;
|
|
607
|
+
refreshToken?: string;
|
|
608
|
+
};
|
|
609
|
+
declare type BitbucketPassportProfile = Profile & {
|
|
610
|
+
id?: string;
|
|
611
|
+
displayName?: string;
|
|
612
|
+
username?: string;
|
|
613
|
+
avatarUrl?: string;
|
|
614
|
+
_json?: {
|
|
615
|
+
links?: {
|
|
616
|
+
avatar?: {
|
|
617
|
+
href?: string;
|
|
618
|
+
};
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
};
|
|
622
|
+
declare const bitbucketUsernameSignInResolver: SignInResolver<BitbucketOAuthResult>;
|
|
623
|
+
declare const bitbucketUserIdSignInResolver: SignInResolver<BitbucketOAuthResult>;
|
|
624
|
+
declare type BitbucketProviderOptions = {
|
|
625
|
+
/**
|
|
626
|
+
* The profile transformation function used to verify and convert the auth response
|
|
627
|
+
* into the profile that will be presented to the user.
|
|
628
|
+
*/
|
|
629
|
+
authHandler?: AuthHandler<OAuthResult>;
|
|
630
|
+
/**
|
|
631
|
+
* Configure sign-in for this provider, without it the provider can not be used to sign users in.
|
|
632
|
+
*/
|
|
633
|
+
signIn?: {
|
|
634
|
+
/**
|
|
635
|
+
* Maps an auth result to a Backstage identity for the user.
|
|
636
|
+
*/
|
|
637
|
+
resolver: SignInResolver<OAuthResult>;
|
|
638
|
+
};
|
|
639
|
+
};
|
|
640
|
+
declare const createBitbucketProvider: (options?: BitbucketProviderOptions | undefined) => AuthProviderFactory;
|
|
641
|
+
|
|
516
642
|
declare type GithubOAuthResult = {
|
|
517
643
|
fullProfile: Profile;
|
|
518
644
|
params: {
|
|
@@ -547,7 +673,7 @@ declare type GithubProviderOptions = {
|
|
|
547
673
|
* Providing your own stateEncoder will allow you to add addition parameters to the state field.
|
|
548
674
|
*
|
|
549
675
|
* It is typed as follows:
|
|
550
|
-
* export type StateEncoder = (input: OAuthState) => Promise<{encodedState: string}
|
|
676
|
+
* `export type StateEncoder = (input: OAuthState) => Promise<{encodedState: string}>;`
|
|
551
677
|
*
|
|
552
678
|
* Note: the stateEncoder must encode a 'nonce' value and an 'env' value. Without this, the OAuth flow will fail
|
|
553
679
|
* (These two values will be set by the req.state by default)
|
|
@@ -672,32 +798,8 @@ declare type OktaProviderOptions = {
|
|
|
672
798
|
};
|
|
673
799
|
declare const createOktaProvider: (_options?: OktaProviderOptions | undefined) => AuthProviderFactory;
|
|
674
800
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
params: {
|
|
678
|
-
id_token?: string;
|
|
679
|
-
scope: string;
|
|
680
|
-
expires_in: number;
|
|
681
|
-
};
|
|
682
|
-
accessToken: string;
|
|
683
|
-
refreshToken?: string;
|
|
684
|
-
};
|
|
685
|
-
declare type BitbucketPassportProfile = Profile & {
|
|
686
|
-
id?: string;
|
|
687
|
-
displayName?: string;
|
|
688
|
-
username?: string;
|
|
689
|
-
avatarUrl?: string;
|
|
690
|
-
_json?: {
|
|
691
|
-
links?: {
|
|
692
|
-
avatar?: {
|
|
693
|
-
href?: string;
|
|
694
|
-
};
|
|
695
|
-
};
|
|
696
|
-
};
|
|
697
|
-
};
|
|
698
|
-
declare const bitbucketUsernameSignInResolver: SignInResolver<BitbucketOAuthResult>;
|
|
699
|
-
declare const bitbucketUserIdSignInResolver: SignInResolver<BitbucketOAuthResult>;
|
|
700
|
-
declare type BitbucketProviderOptions = {
|
|
801
|
+
/** @public */
|
|
802
|
+
declare type OneLoginProviderOptions = {
|
|
701
803
|
/**
|
|
702
804
|
* The profile transformation function used to verify and convert the auth response
|
|
703
805
|
* into the profile that will be presented to the user.
|
|
@@ -713,100 +815,103 @@ declare type BitbucketProviderOptions = {
|
|
|
713
815
|
resolver: SignInResolver<OAuthResult>;
|
|
714
816
|
};
|
|
715
817
|
};
|
|
716
|
-
|
|
818
|
+
/** @public */
|
|
819
|
+
declare const createOneLoginProvider: (options?: OneLoginProviderOptions | undefined) => AuthProviderFactory;
|
|
717
820
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
authHandler: AuthHandler<OAuthResult>;
|
|
722
|
-
tokenIssuer: TokenIssuer;
|
|
723
|
-
catalogIdentityClient: CatalogIdentityClient;
|
|
724
|
-
logger: Logger;
|
|
821
|
+
/** @public */
|
|
822
|
+
declare type SamlAuthResult = {
|
|
823
|
+
fullProfile: any;
|
|
725
824
|
};
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
private readonly signInResolver?;
|
|
729
|
-
private readonly authHandler;
|
|
730
|
-
private readonly tokenIssuer;
|
|
731
|
-
private readonly catalogIdentityClient;
|
|
732
|
-
private readonly logger;
|
|
733
|
-
constructor(options: AtlassianAuthProviderOptions);
|
|
734
|
-
start(req: OAuthStartRequest): Promise<RedirectInfo>;
|
|
735
|
-
handler(req: express.Request): Promise<{
|
|
736
|
-
response: OAuthResponse;
|
|
737
|
-
refreshToken: string;
|
|
738
|
-
}>;
|
|
739
|
-
private handleResult;
|
|
740
|
-
refresh(req: OAuthRefreshRequest): Promise<OAuthResponse>;
|
|
741
|
-
}
|
|
742
|
-
declare type AtlassianProviderOptions = {
|
|
825
|
+
/** @public */
|
|
826
|
+
declare type SamlProviderOptions = {
|
|
743
827
|
/**
|
|
744
828
|
* The profile transformation function used to verify and convert the auth response
|
|
745
829
|
* into the profile that will be presented to the user.
|
|
746
830
|
*/
|
|
747
|
-
authHandler?: AuthHandler<
|
|
831
|
+
authHandler?: AuthHandler<SamlAuthResult>;
|
|
748
832
|
/**
|
|
749
833
|
* Configure sign-in for this provider, without it the provider can not be used to sign users in.
|
|
750
834
|
*/
|
|
751
835
|
signIn?: {
|
|
752
|
-
|
|
836
|
+
/**
|
|
837
|
+
* Maps an auth result to a Backstage identity for the user.
|
|
838
|
+
*/
|
|
839
|
+
resolver?: SignInResolver<SamlAuthResult>;
|
|
753
840
|
};
|
|
754
841
|
};
|
|
755
|
-
|
|
842
|
+
/** @public */
|
|
843
|
+
declare const createSamlProvider: (options?: SamlProviderOptions | undefined) => AuthProviderFactory;
|
|
756
844
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
declare type
|
|
845
|
+
/**
|
|
846
|
+
* The data extracted from an IAP token.
|
|
847
|
+
*
|
|
848
|
+
* @public
|
|
849
|
+
*/
|
|
850
|
+
declare type GcpIapTokenInfo = {
|
|
763
851
|
/**
|
|
764
|
-
* The
|
|
765
|
-
* into the profile that will be presented to the user.
|
|
852
|
+
* The unique, stable identifier for the user.
|
|
766
853
|
*/
|
|
767
|
-
|
|
854
|
+
sub: string;
|
|
768
855
|
/**
|
|
769
|
-
*
|
|
856
|
+
* User email address.
|
|
770
857
|
*/
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
};
|
|
858
|
+
email: string;
|
|
859
|
+
/**
|
|
860
|
+
* Other fields.
|
|
861
|
+
*/
|
|
862
|
+
[key: string]: JsonValue;
|
|
777
863
|
};
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
864
|
+
/**
|
|
865
|
+
* The result of the initial auth challenge. This is the input to the auth
|
|
866
|
+
* callbacks.
|
|
867
|
+
*
|
|
868
|
+
* @public
|
|
869
|
+
*/
|
|
870
|
+
declare type GcpIapResult = {
|
|
871
|
+
/**
|
|
872
|
+
* The data extracted from the IAP token header.
|
|
873
|
+
*/
|
|
874
|
+
iapToken: GcpIapTokenInfo;
|
|
783
875
|
};
|
|
784
|
-
/**
|
|
785
|
-
|
|
876
|
+
/**
|
|
877
|
+
* Options for {@link createGcpIapProvider}.
|
|
878
|
+
*
|
|
879
|
+
* @public
|
|
880
|
+
*/
|
|
881
|
+
declare type GcpIapProviderOptions = {
|
|
786
882
|
/**
|
|
787
|
-
* The profile transformation function used to verify and convert the auth
|
|
788
|
-
* into the profile that will be presented to the user.
|
|
883
|
+
* The profile transformation function used to verify and convert the auth
|
|
884
|
+
* response into the profile that will be presented to the user. The default
|
|
885
|
+
* implementation just provides the authenticated email that the IAP
|
|
886
|
+
* presented.
|
|
789
887
|
*/
|
|
790
|
-
authHandler?: AuthHandler<
|
|
888
|
+
authHandler?: AuthHandler<GcpIapResult>;
|
|
791
889
|
/**
|
|
792
|
-
*
|
|
890
|
+
* Configures sign-in for this provider.
|
|
793
891
|
*/
|
|
794
|
-
signIn
|
|
892
|
+
signIn: {
|
|
795
893
|
/**
|
|
796
894
|
* Maps an auth result to a Backstage identity for the user.
|
|
797
895
|
*/
|
|
798
|
-
resolver
|
|
896
|
+
resolver: SignInResolver<GcpIapResult>;
|
|
799
897
|
};
|
|
800
898
|
};
|
|
801
|
-
|
|
802
|
-
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* Creates an auth provider for Google Identity-Aware Proxy.
|
|
902
|
+
*
|
|
903
|
+
* @public
|
|
904
|
+
*/
|
|
905
|
+
declare function createGcpIapProvider(options: GcpIapProviderOptions): AuthProviderFactory;
|
|
803
906
|
|
|
804
907
|
declare const factories: {
|
|
805
908
|
[providerId: string]: AuthProviderFactory;
|
|
806
909
|
};
|
|
807
910
|
|
|
808
911
|
/**
|
|
809
|
-
* Parses token and decorates the
|
|
912
|
+
* Parses a Backstage-issued token and decorates the
|
|
913
|
+
* {@link BackstageIdentityResponse} with identity information sourced from the
|
|
914
|
+
* token.
|
|
810
915
|
*
|
|
811
916
|
* @public
|
|
812
917
|
*/
|
|
@@ -840,4 +945,4 @@ declare type WebMessageResponse = {
|
|
|
840
945
|
declare const postMessageResponse: (res: express.Response, appOrigin: string, response: WebMessageResponse) => void;
|
|
841
946
|
declare const ensuresXRequestedWith: (req: express.Request) => boolean;
|
|
842
947
|
|
|
843
|
-
export { AtlassianAuthProvider, AtlassianProviderOptions, AuthHandler, AuthHandlerResult, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResponse, AwsAlbProviderOptions, BackstageIdentity, BackstageIdentityResponse, BackstageSignInResult, BackstageUserIdentity, BitbucketOAuthResult, BitbucketPassportProfile, BitbucketProviderOptions, CatalogIdentityClient, GithubOAuthResult, GithubProviderOptions, GitlabProviderOptions, GoogleProviderOptions, IdentityClient, MicrosoftProviderOptions, OAuth2ProviderOptions, OAuthAdapter, OAuthEnvironmentHandler, OAuthHandlers, OAuthProviderInfo, OAuthProviderOptions, OAuthRefreshRequest, OAuthResponse, OAuthResult, OAuthStartRequest, OAuthState, OidcAuthResult, OidcProviderOptions, OktaProviderOptions, ProfileInfo, RouterOptions, SamlAuthResult, SamlProviderOptions, SignInInfo, SignInResolver, TokenIssuer, WebMessageResponse, bitbucketUserIdSignInResolver, bitbucketUsernameSignInResolver, createAtlassianProvider, createAwsAlbProvider, createBitbucketProvider, createGithubProvider, createGitlabProvider, createGoogleProvider, createMicrosoftProvider, createOAuth2Provider, createOidcProvider, createOktaProvider, createOriginFilter, createRouter, createSamlProvider, factories as defaultAuthProviderFactories, encodeState, ensuresXRequestedWith, getEntityClaims, googleEmailSignInResolver, microsoftEmailSignInResolver, oktaEmailSignInResolver, postMessageResponse, prepareBackstageIdentityResponse, readState, verifyNonce };
|
|
948
|
+
export { AtlassianAuthProvider, AtlassianProviderOptions, Auth0ProviderOptions, AuthHandler, AuthHandlerResult, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResponse, AwsAlbProviderOptions, BackstageIdentity, BackstageIdentityResponse, BackstageSignInResult, BackstageUserIdentity, BitbucketOAuthResult, BitbucketPassportProfile, BitbucketProviderOptions, CatalogIdentityClient, GcpIapProviderOptions, GcpIapResult, GcpIapTokenInfo, GithubOAuthResult, GithubProviderOptions, GitlabProviderOptions, GoogleProviderOptions, IdentityClient, MicrosoftProviderOptions, OAuth2ProviderOptions, OAuthAdapter, OAuthEnvironmentHandler, OAuthHandlers, OAuthProviderInfo, OAuthProviderOptions, OAuthRefreshRequest, OAuthResponse, OAuthResult, OAuthStartRequest, OAuthState, OidcAuthResult, OidcProviderOptions, OktaProviderOptions, OneLoginProviderOptions, ProfileInfo, RouterOptions, SamlAuthResult, SamlProviderOptions, SignInInfo, SignInResolver, TokenIssuer, WebMessageResponse, bitbucketUserIdSignInResolver, bitbucketUsernameSignInResolver, createAtlassianProvider, createAuth0Provider, createAwsAlbProvider, createBitbucketProvider, createGcpIapProvider, createGithubProvider, createGitlabProvider, createGoogleProvider, createMicrosoftProvider, createOAuth2Provider, createOidcProvider, createOktaProvider, createOneLoginProvider, createOriginFilter, createRouter, createSamlProvider, factories as defaultAuthProviderFactories, encodeState, ensuresXRequestedWith, getEntityClaims, googleEmailSignInResolver, microsoftEmailSignInResolver, oktaEmailSignInResolver, postMessageResponse, prepareBackstageIdentityResponse, readState, verifyNonce };
|
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.6.2",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"clean": "backstage-cli clean"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@backstage/backend-common": "^0.
|
|
34
|
-
"@backstage/catalog-client": "^0.5.
|
|
35
|
-
"@backstage/catalog-model": "^0.9.
|
|
36
|
-
"@backstage/config": "^0.1.
|
|
37
|
-
"@backstage/errors": "^0.
|
|
38
|
-
"@backstage/
|
|
33
|
+
"@backstage/backend-common": "^0.10.3",
|
|
34
|
+
"@backstage/catalog-client": "^0.5.4",
|
|
35
|
+
"@backstage/catalog-model": "^0.9.9",
|
|
36
|
+
"@backstage/config": "^0.1.12",
|
|
37
|
+
"@backstage/errors": "^0.2.0",
|
|
38
|
+
"@backstage/types": "^0.1.1",
|
|
39
39
|
"@google-cloud/firestore": "^4.15.1",
|
|
40
40
|
"@types/express": "^4.17.6",
|
|
41
41
|
"@types/passport": "^1.0.3",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"express-promise-router": "^4.1.0",
|
|
47
47
|
"express-session": "^1.17.1",
|
|
48
48
|
"fs-extra": "9.1.0",
|
|
49
|
-
"
|
|
49
|
+
"google-auth-library": "^7.6.1",
|
|
50
50
|
"helmet": "^4.0.0",
|
|
51
51
|
"jose": "^1.27.1",
|
|
52
52
|
"jwt-decode": "^3.1.0",
|
|
@@ -73,7 +73,8 @@
|
|
|
73
73
|
"yn": "^4.0.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@backstage/cli": "^0.
|
|
76
|
+
"@backstage/cli": "^0.11.0",
|
|
77
|
+
"@backstage/test-utils": "^0.2.2",
|
|
77
78
|
"@types/body-parser": "^1.19.0",
|
|
78
79
|
"@types/cookie-parser": "^1.4.2",
|
|
79
80
|
"@types/express-session": "^1.17.2",
|
|
@@ -84,7 +85,8 @@
|
|
|
84
85
|
"@types/passport-saml": "^1.1.3",
|
|
85
86
|
"@types/passport-strategy": "^0.2.35",
|
|
86
87
|
"@types/xml2js": "^0.4.7",
|
|
87
|
-
"msw": "^0.35.0"
|
|
88
|
+
"msw": "^0.35.0",
|
|
89
|
+
"supertest": "^6.1.3"
|
|
88
90
|
},
|
|
89
91
|
"files": [
|
|
90
92
|
"dist",
|
|
@@ -92,5 +94,5 @@
|
|
|
92
94
|
"config.d.ts"
|
|
93
95
|
],
|
|
94
96
|
"configSchema": "config.d.ts",
|
|
95
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "da66c61bdd63cdb3f0f0cd2e26dc9e6454d93c7b"
|
|
96
98
|
}
|