@backstage/plugin-auth-backend 0.9.0-next.1 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts DELETED
@@ -1,1002 +0,0 @@
1
- /// <reference types="node" />
2
- import express from 'express';
3
- import { Logger } from 'winston';
4
- import { Config } from '@backstage/config';
5
- import { TokenManager, PluginEndpointDiscovery, PluginDatabaseManager } from '@backstage/backend-common';
6
- import { CatalogApi } from '@backstage/catalog-client';
7
- import { UserEntity, Entity } from '@backstage/catalog-model';
8
- import { Profile } from 'passport';
9
- import { JSONWebKey } from 'jose';
10
- import { TokenSet, UserinfoResponse } from 'openid-client';
11
- import { JsonValue } from '@backstage/types';
12
-
13
- /** Represents any form of serializable JWK */
14
- interface AnyJWK extends Record<string, string> {
15
- use: 'sig';
16
- alg: string;
17
- kid: string;
18
- kty: string;
19
- }
20
- /** Parameters used to issue new ID Tokens */
21
- declare type TokenParams = {
22
- /** The claims that will be embedded within the token */
23
- claims: {
24
- /** The token subject, i.e. User ID */
25
- sub: string;
26
- /** A list of entity references that the user claims ownership through */
27
- ent?: string[];
28
- };
29
- };
30
- /**
31
- * A TokenIssuer is able to issue verifiable ID Tokens on demand.
32
- */
33
- declare type TokenIssuer = {
34
- /**
35
- * Issues a new ID Token
36
- */
37
- issueToken(params: TokenParams): Promise<string>;
38
- /**
39
- * List all public keys that are currently being used to sign tokens, or have been used
40
- * in the past within the token expiration time, including a grace period.
41
- */
42
- listPublicKeys(): Promise<{
43
- keys: AnyJWK[];
44
- }>;
45
- };
46
-
47
- /**
48
- * Common options for passport.js-based OAuth providers
49
- */
50
- declare type OAuthProviderOptions = {
51
- /**
52
- * Client ID of the auth provider.
53
- */
54
- clientId: string;
55
- /**
56
- * Client Secret of the auth provider.
57
- */
58
- clientSecret: string;
59
- /**
60
- * Callback URL to be passed to the auth provider to redirect to after the user signs in.
61
- */
62
- callbackUrl: string;
63
- };
64
- declare type OAuthResult = {
65
- fullProfile: Profile;
66
- params: {
67
- id_token?: string;
68
- scope: string;
69
- expires_in: number;
70
- };
71
- accessToken: string;
72
- refreshToken?: string;
73
- };
74
- /**
75
- * The expected response from an OAuth flow.
76
- *
77
- * @public
78
- */
79
- declare type OAuthResponse = {
80
- profile: ProfileInfo;
81
- providerInfo: OAuthProviderInfo;
82
- backstageIdentity?: BackstageSignInResult;
83
- };
84
- declare type OAuthProviderInfo = {
85
- /**
86
- * An access token issued for the signed in user.
87
- */
88
- accessToken: string;
89
- /**
90
- * (Optional) Id token issued for the signed in user.
91
- */
92
- idToken?: string;
93
- /**
94
- * Expiry of the access token in seconds.
95
- */
96
- expiresInSeconds?: number;
97
- /**
98
- * Scopes granted for the access token.
99
- */
100
- scope: string;
101
- };
102
- declare type OAuthState = {
103
- nonce: string;
104
- env: string;
105
- origin?: string;
106
- scope?: string;
107
- };
108
- declare type OAuthStartRequest = express.Request<{}> & {
109
- scope: string;
110
- state: OAuthState;
111
- };
112
- declare type OAuthRefreshRequest = express.Request<{}> & {
113
- scope: string;
114
- refreshToken: string;
115
- };
116
- /**
117
- * Any OAuth provider needs to implement this interface which has provider specific
118
- * handlers for different methods to perform authentication, get access tokens,
119
- * refresh tokens and perform sign out.
120
- *
121
- * @public
122
- */
123
- interface OAuthHandlers {
124
- /**
125
- * Initiate a sign in request with an auth provider.
126
- */
127
- start(req: OAuthStartRequest): Promise<RedirectInfo>;
128
- /**
129
- * Handle the redirect from the auth provider when the user has signed in.
130
- */
131
- handler(req: express.Request): Promise<{
132
- response: OAuthResponse;
133
- refreshToken?: string;
134
- }>;
135
- /**
136
- * (Optional) Given a refresh token and scope fetches a new access token from the auth provider.
137
- */
138
- refresh?(req: OAuthRefreshRequest): Promise<{
139
- response: OAuthResponse;
140
- refreshToken?: string;
141
- }>;
142
- /**
143
- * (Optional) Sign out of the auth provider.
144
- */
145
- logout?(): Promise<void>;
146
- }
147
-
148
- declare type UserQuery = {
149
- annotations: Record<string, string>;
150
- };
151
- declare type MemberClaimQuery = {
152
- entityRefs: string[];
153
- logger?: Logger;
154
- };
155
- /**
156
- * A catalog client tailored for reading out identity data from the catalog.
157
- */
158
- declare class CatalogIdentityClient {
159
- private readonly catalogApi;
160
- private readonly tokenManager;
161
- constructor(options: {
162
- catalogApi: CatalogApi;
163
- tokenManager: TokenManager;
164
- });
165
- /**
166
- * Looks up a single user using a query.
167
- *
168
- * Throws a NotFoundError or ConflictError if 0 or multiple users are found.
169
- */
170
- findUser(query: UserQuery): Promise<UserEntity>;
171
- /**
172
- * Resolve additional entity claims from the catalog, using the passed-in entity names. Designed
173
- * to be used within a `signInResolver` where additional entity claims might be provided, but
174
- * group membership and transient group membership lean on imported catalog relations.
175
- *
176
- * Returns a superset of the entity names that can be passed directly to `issueToken` as `ent`.
177
- */
178
- resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]>;
179
- }
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
- declare function getEntityClaims(entity: UserEntity): TokenParams['claims'];
225
-
226
- /**
227
- * The context that is used for auth processing.
228
- *
229
- * @public
230
- */
231
- declare type AuthResolverContext = {
232
- tokenIssuer: TokenIssuer;
233
- catalogIdentityClient: CatalogIdentityClient;
234
- logger: Logger;
235
- };
236
- declare type AuthProviderConfig = {
237
- /**
238
- * The protocol://domain[:port] where the app is hosted. This is used to construct the
239
- * callbackURL to redirect to once the user signs in to the auth provider.
240
- */
241
- baseUrl: string;
242
- /**
243
- * The base URL of the app as provided by app.baseUrl
244
- */
245
- appUrl: string;
246
- /**
247
- * A function that is called to check whether an origin is allowed to receive the authentication result.
248
- */
249
- isOriginAllowed: (origin: string) => boolean;
250
- };
251
- declare type RedirectInfo = {
252
- /**
253
- * URL to redirect to
254
- */
255
- url: string;
256
- /**
257
- * Status code to use for the redirect
258
- */
259
- status?: number;
260
- };
261
- /**
262
- * Any Auth provider needs to implement this interface which handles the routes in the
263
- * auth backend. Any auth API requests from the frontend reaches these methods.
264
- *
265
- * The routes in the auth backend API are tied to these methods like below
266
- *
267
- * `/auth/[provider]/start -> start`
268
- * `/auth/[provider]/handler/frame -> frameHandler`
269
- * `/auth/[provider]/refresh -> refresh`
270
- * `/auth/[provider]/logout -> logout`
271
- */
272
- interface AuthProviderRouteHandlers {
273
- /**
274
- * Handles the start route of the API. This initiates a sign in request with an auth provider.
275
- *
276
- * Request
277
- * - scopes for the auth request (Optional)
278
- * Response
279
- * - redirect to the auth provider for the user to sign in or consent.
280
- * - sets a nonce cookie and also pass the nonce as 'state' query parameter in the redirect request
281
- */
282
- start(req: express.Request, res: express.Response): Promise<void>;
283
- /**
284
- * Once the user signs in or consents in the OAuth screen, the auth provider redirects to the
285
- * callbackURL which is handled by this method.
286
- *
287
- * Request
288
- * - to contain a nonce cookie and a 'state' query parameter
289
- * Response
290
- * - postMessage to the window with a payload that contains accessToken, expiryInSeconds?, idToken? and scope.
291
- * - sets a refresh token cookie if the auth provider supports refresh tokens
292
- */
293
- frameHandler(req: express.Request, res: express.Response): Promise<void>;
294
- /**
295
- * (Optional) If the auth provider supports refresh tokens then this method handles
296
- * requests to get a new access token.
297
- *
298
- * Request
299
- * - to contain a refresh token cookie and scope (Optional) query parameter.
300
- * Response
301
- * - payload with accessToken, expiryInSeconds?, idToken?, scope and user profile information.
302
- */
303
- refresh?(req: express.Request, res: express.Response): Promise<void>;
304
- /**
305
- * (Optional) Handles sign out requests
306
- *
307
- * Response
308
- * - removes the refresh token cookie
309
- */
310
- logout?(req: express.Request, res: express.Response): Promise<void>;
311
- }
312
- declare type AuthProviderFactoryOptions = {
313
- providerId: string;
314
- globalConfig: AuthProviderConfig;
315
- config: Config;
316
- logger: Logger;
317
- tokenManager: TokenManager;
318
- tokenIssuer: TokenIssuer;
319
- discovery: PluginEndpointDiscovery;
320
- catalogApi: CatalogApi;
321
- };
322
- declare type AuthProviderFactory = (options: AuthProviderFactoryOptions) => AuthProviderRouteHandlers;
323
- declare type AuthResponse<ProviderInfo> = {
324
- providerInfo: ProviderInfo;
325
- profile: ProfileInfo;
326
- backstageIdentity?: BackstageIdentityResponse;
327
- };
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
- /**
400
- * Used to display login information to user, i.e. sidebar popup.
401
- *
402
- * 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
404
- * service
405
- *
406
- * @public
407
- */
408
- declare type ProfileInfo = {
409
- /**
410
- * Email ID of the signed in user.
411
- */
412
- email?: string;
413
- /**
414
- * Display name that can be presented to the signed in user.
415
- */
416
- displayName?: string;
417
- /**
418
- * URL to an image that can be used as the display image or avatar of the
419
- * signed in user.
420
- */
421
- picture?: string;
422
- };
423
- /**
424
- * Type of sign in information context. Includes the profile information and
425
- * authentication result which contains auth related information.
426
- *
427
- * @public
428
- */
429
- declare type SignInInfo<TAuthResult> = {
430
- /**
431
- * The simple profile passed down for use in the frontend.
432
- */
433
- profile: ProfileInfo;
434
- /**
435
- * The authentication result that was received from the authentication
436
- * provider.
437
- */
438
- result: TAuthResult;
439
- };
440
- /**
441
- * Describes the function which handles the result of a successful
442
- * authentication. Must return a valid {@link BackstageSignInResult}.
443
- *
444
- * @public
445
- */
446
- declare type SignInResolver<TAuthResult> = (info: SignInInfo<TAuthResult>, context: AuthResolverContext) => Promise<BackstageSignInResult>;
447
- /**
448
- * The return type of an authentication handler. Must contain valid profile
449
- * information.
450
- *
451
- * @public
452
- */
453
- declare type AuthHandlerResult = {
454
- profile: ProfileInfo;
455
- };
456
- /**
457
- * The AuthHandler function is called every time the user authenticates using
458
- * the provider.
459
- *
460
- * The handler should return a profile that represents the session for the user
461
- * in the frontend.
462
- *
463
- * Throwing an error in the function will cause the authentication to fail,
464
- * making it possible to use this function as a way to limit access to a certain
465
- * group of users.
466
- *
467
- * @public
468
- */
469
- declare type AuthHandler<TAuthResult> = (input: TAuthResult, context: AuthResolverContext) => Promise<AuthHandlerResult>;
470
- declare type StateEncoder = (req: OAuthStartRequest) => Promise<{
471
- encodedState: string;
472
- }>;
473
-
474
- declare class OAuthEnvironmentHandler implements AuthProviderRouteHandlers {
475
- private readonly handlers;
476
- static mapConfig(config: Config, factoryFunc: (envConfig: Config) => AuthProviderRouteHandlers): OAuthEnvironmentHandler;
477
- constructor(handlers: Map<string, AuthProviderRouteHandlers>);
478
- start(req: express.Request, res: express.Response): Promise<void>;
479
- frameHandler(req: express.Request, res: express.Response): Promise<void>;
480
- refresh(req: express.Request, res: express.Response): Promise<void>;
481
- logout(req: express.Request, res: express.Response): Promise<void>;
482
- private getRequestFromEnv;
483
- private getProviderForEnv;
484
- }
485
-
486
- declare type Options = {
487
- providerId: string;
488
- secure: boolean;
489
- disableRefresh?: boolean;
490
- persistScopes?: boolean;
491
- cookieDomain: string;
492
- cookiePath: string;
493
- appOrigin: string;
494
- tokenIssuer: TokenIssuer;
495
- isOriginAllowed: (origin: string) => boolean;
496
- callbackUrl?: string;
497
- };
498
- declare class OAuthAdapter implements AuthProviderRouteHandlers {
499
- private readonly handlers;
500
- private readonly options;
501
- static fromConfig(config: AuthProviderConfig, handlers: OAuthHandlers, options: Pick<Options, 'providerId' | 'persistScopes' | 'disableRefresh' | 'tokenIssuer' | 'callbackUrl'>): OAuthAdapter;
502
- private readonly baseCookieOptions;
503
- constructor(handlers: OAuthHandlers, options: Options);
504
- start(req: express.Request, res: express.Response): Promise<void>;
505
- frameHandler(req: express.Request, res: express.Response): Promise<void>;
506
- logout(req: express.Request, res: express.Response): Promise<void>;
507
- refresh(req: express.Request, res: express.Response): Promise<void>;
508
- /**
509
- * If the response from the OAuth provider includes a Backstage identity, we
510
- * make sure it's populated with all the information we can derive from the user ID.
511
- */
512
- private populateIdentity;
513
- private setNonceCookie;
514
- private setGrantedScopeCookie;
515
- private getGrantedScopeFromCookie;
516
- private setRefreshTokenCookie;
517
- private removeRefreshTokenCookie;
518
- }
519
-
520
- declare const readState: (stateString: string) => OAuthState;
521
- declare const encodeState: (state: OAuthState) => string;
522
- declare const verifyNonce: (req: express.Request, providerId: string) => void;
523
-
524
- declare type AtlassianAuthProviderOptions = OAuthProviderOptions & {
525
- scopes: string;
526
- signInResolver?: SignInResolver<OAuthResult>;
527
- authHandler: AuthHandler<OAuthResult>;
528
- tokenIssuer: TokenIssuer;
529
- catalogIdentityClient: CatalogIdentityClient;
530
- logger: Logger;
531
- };
532
- declare class AtlassianAuthProvider implements OAuthHandlers {
533
- private readonly _strategy;
534
- private readonly signInResolver?;
535
- private readonly authHandler;
536
- private readonly tokenIssuer;
537
- private readonly catalogIdentityClient;
538
- private readonly logger;
539
- constructor(options: AtlassianAuthProviderOptions);
540
- start(req: OAuthStartRequest): Promise<RedirectInfo>;
541
- handler(req: express.Request): Promise<{
542
- response: OAuthResponse;
543
- refreshToken: string | undefined;
544
- }>;
545
- private handleResult;
546
- refresh(req: OAuthRefreshRequest): Promise<{
547
- response: OAuthResponse;
548
- refreshToken: string | undefined;
549
- }>;
550
- }
551
- declare type AtlassianProviderOptions = {
552
- /**
553
- * The profile transformation function used to verify and convert the auth response
554
- * into the profile that will be presented to the user.
555
- */
556
- authHandler?: AuthHandler<OAuthResult>;
557
- /**
558
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
559
- */
560
- signIn?: {
561
- resolver: SignInResolver<OAuthResult>;
562
- };
563
- };
564
- declare const createAtlassianProvider: (options?: AtlassianProviderOptions | undefined) => AuthProviderFactory;
565
-
566
- /** @public */
567
- declare type Auth0ProviderOptions = {
568
- /**
569
- * The profile transformation function used to verify and convert the auth response
570
- * into the profile that will be presented to the user.
571
- */
572
- authHandler?: AuthHandler<OAuthResult>;
573
- /**
574
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
575
- */
576
- signIn?: {
577
- /**
578
- * Maps an auth result to a Backstage identity for the user.
579
- */
580
- resolver: SignInResolver<OAuthResult>;
581
- };
582
- };
583
- /** @public */
584
- declare const createAuth0Provider: (options?: Auth0ProviderOptions | undefined) => AuthProviderFactory;
585
-
586
- declare type AwsAlbResult = {
587
- fullProfile: Profile;
588
- expiresInSeconds?: number;
589
- accessToken: string;
590
- };
591
- declare type AwsAlbProviderOptions = {
592
- /**
593
- * The profile transformation function used to verify and convert the auth response
594
- * into the profile that will be presented to the user.
595
- */
596
- authHandler?: AuthHandler<AwsAlbResult>;
597
- /**
598
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
599
- */
600
- signIn: {
601
- /**
602
- * Maps an auth result to a Backstage identity for the user.
603
- */
604
- resolver: SignInResolver<AwsAlbResult>;
605
- };
606
- };
607
- declare const createAwsAlbProvider: (options?: AwsAlbProviderOptions | undefined) => AuthProviderFactory;
608
-
609
- declare type BitbucketOAuthResult = {
610
- fullProfile: BitbucketPassportProfile;
611
- params: {
612
- id_token?: string;
613
- scope: string;
614
- expires_in: number;
615
- };
616
- accessToken: string;
617
- refreshToken?: string;
618
- };
619
- declare type BitbucketPassportProfile = Profile & {
620
- id?: string;
621
- displayName?: string;
622
- username?: string;
623
- avatarUrl?: string;
624
- _json?: {
625
- links?: {
626
- avatar?: {
627
- href?: string;
628
- };
629
- };
630
- };
631
- };
632
- declare const bitbucketUsernameSignInResolver: SignInResolver<BitbucketOAuthResult>;
633
- declare const bitbucketUserIdSignInResolver: SignInResolver<BitbucketOAuthResult>;
634
- declare type BitbucketProviderOptions = {
635
- /**
636
- * The profile transformation function used to verify and convert the auth response
637
- * into the profile that will be presented to the user.
638
- */
639
- authHandler?: AuthHandler<OAuthResult>;
640
- /**
641
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
642
- */
643
- signIn?: {
644
- /**
645
- * Maps an auth result to a Backstage identity for the user.
646
- */
647
- resolver: SignInResolver<OAuthResult>;
648
- };
649
- };
650
- declare const createBitbucketProvider: (options?: BitbucketProviderOptions | undefined) => AuthProviderFactory;
651
-
652
- declare type GithubOAuthResult = {
653
- fullProfile: Profile;
654
- params: {
655
- scope: string;
656
- expires_in?: string;
657
- refresh_token_expires_in?: string;
658
- };
659
- accessToken: string;
660
- refreshToken?: string;
661
- };
662
- declare type GithubProviderOptions = {
663
- /**
664
- * The profile transformation function used to verify and convert the auth response
665
- * into the profile that will be presented to the user.
666
- */
667
- authHandler?: AuthHandler<GithubOAuthResult>;
668
- /**
669
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
670
- */
671
- signIn?: {
672
- /**
673
- * Maps an auth result to a Backstage identity for the user.
674
- */
675
- resolver?: SignInResolver<GithubOAuthResult>;
676
- };
677
- /**
678
- * The state encoder used to encode the 'state' parameter on the OAuth request.
679
- *
680
- * It should return a string that takes the state params (from the request), url encodes the params
681
- * and finally base64 encodes them.
682
- *
683
- * Providing your own stateEncoder will allow you to add addition parameters to the state field.
684
- *
685
- * It is typed as follows:
686
- * `export type StateEncoder = (input: OAuthState) => Promise<{encodedState: string}>;`
687
- *
688
- * Note: the stateEncoder must encode a 'nonce' value and an 'env' value. Without this, the OAuth flow will fail
689
- * (These two values will be set by the req.state by default)
690
- *
691
- * For more information, please see the helper module in ../../oauth/helpers #readState
692
- */
693
- stateEncoder?: StateEncoder;
694
- };
695
- declare const createGithubProvider: (options?: GithubProviderOptions | undefined) => AuthProviderFactory;
696
-
697
- declare type GitlabProviderOptions = {
698
- /**
699
- * The profile transformation function used to verify and convert the auth response
700
- * into the profile that will be presented to the user.
701
- */
702
- authHandler?: AuthHandler<OAuthResult>;
703
- /**
704
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
705
- */
706
- /**
707
- * Maps an auth result to a Backstage identity for the user.
708
- *
709
- * Set to `'email'` to use the default email-based sign in resolver, which will search
710
- * the catalog for a single user entity that has a matching `microsoft.com/email` annotation.
711
- */
712
- signIn?: {
713
- resolver?: SignInResolver<OAuthResult>;
714
- };
715
- };
716
- declare const createGitlabProvider: (options?: GitlabProviderOptions | undefined) => AuthProviderFactory;
717
-
718
- declare const googleEmailSignInResolver: SignInResolver<OAuthResult>;
719
- declare type GoogleProviderOptions = {
720
- /**
721
- * The profile transformation function used to verify and convert the auth response
722
- * into the profile that will be presented to the user.
723
- */
724
- authHandler?: AuthHandler<OAuthResult>;
725
- /**
726
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
727
- */
728
- signIn?: {
729
- /**
730
- * Maps an auth result to a Backstage identity for the user.
731
- */
732
- resolver?: SignInResolver<OAuthResult>;
733
- };
734
- };
735
- declare const createGoogleProvider: (options?: GoogleProviderOptions | undefined) => AuthProviderFactory;
736
-
737
- declare const microsoftEmailSignInResolver: SignInResolver<OAuthResult>;
738
- declare type MicrosoftProviderOptions = {
739
- /**
740
- * The profile transformation function used to verify and convert the auth response
741
- * into the profile that will be presented to the user.
742
- */
743
- authHandler?: AuthHandler<OAuthResult>;
744
- /**
745
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
746
- */
747
- signIn?: {
748
- /**
749
- * Maps an auth result to a Backstage identity for the user.
750
- */
751
- resolver?: SignInResolver<OAuthResult>;
752
- };
753
- };
754
- declare const createMicrosoftProvider: (options?: MicrosoftProviderOptions | undefined) => AuthProviderFactory;
755
-
756
- declare type OAuth2ProviderOptions = {
757
- authHandler?: AuthHandler<OAuthResult>;
758
- signIn?: {
759
- resolver?: SignInResolver<OAuthResult>;
760
- };
761
- };
762
- declare const createOAuth2Provider: (options?: OAuth2ProviderOptions | undefined) => AuthProviderFactory;
763
-
764
- /**
765
- * JWT header extraction result, containing the raw value and the parsed JWT
766
- * payload.
767
- *
768
- * @public
769
- */
770
- declare type OAuth2ProxyResult<JWTPayload> = {
771
- /**
772
- * Parsed and decoded JWT payload.
773
- */
774
- fullProfile: JWTPayload;
775
- /**
776
- * Raw JWT token
777
- */
778
- accessToken: string;
779
- };
780
- /**
781
- * Options for the oauth2-proxy provider factory
782
- *
783
- * @public
784
- */
785
- declare type Oauth2ProxyProviderOptions<JWTPayload> = {
786
- /**
787
- * Configure an auth handler to generate a profile for the user.
788
- */
789
- authHandler: AuthHandler<OAuth2ProxyResult<JWTPayload>>;
790
- /**
791
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
792
- */
793
- signIn: {
794
- /**
795
- * Maps an auth result to a Backstage identity for the user.
796
- */
797
- resolver: SignInResolver<OAuth2ProxyResult<JWTPayload>>;
798
- };
799
- };
800
- /**
801
- * Factory function for oauth2-proxy auth provider
802
- *
803
- * @public
804
- */
805
- declare const createOauth2ProxyProvider: <JWTPayload>(options: Oauth2ProxyProviderOptions<JWTPayload>) => AuthProviderFactory;
806
-
807
- /**
808
- * authentication result for the OIDC which includes the token set and user information (a profile response sent by OIDC server)
809
- * @public
810
- */
811
- declare type OidcAuthResult = {
812
- tokenset: TokenSet;
813
- userinfo: UserinfoResponse;
814
- };
815
- /**
816
- * OIDC provider callback options. An auth handler and a sign in resolver
817
- * can be passed while creating a OIDC provider.
818
- *
819
- * 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}
821
- *
822
- * Both options are optional. There is fallback for authHandler where the default handler expect an e-mail explicitly
823
- * otherwise it throws an error
824
- *
825
- * @public
826
- */
827
- declare type OidcProviderOptions = {
828
- authHandler?: AuthHandler<OidcAuthResult>;
829
- signIn?: {
830
- resolver?: SignInResolver<OidcAuthResult>;
831
- };
832
- };
833
- declare const createOidcProvider: (options?: OidcProviderOptions | undefined) => AuthProviderFactory;
834
-
835
- declare const oktaEmailSignInResolver: SignInResolver<OAuthResult>;
836
- declare type OktaProviderOptions = {
837
- /**
838
- * The profile transformation function used to verify and convert the auth response
839
- * into the profile that will be presented to the user.
840
- */
841
- authHandler?: AuthHandler<OAuthResult>;
842
- /**
843
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
844
- */
845
- signIn?: {
846
- /**
847
- * Maps an auth result to a Backstage identity for the user.
848
- */
849
- resolver?: SignInResolver<OAuthResult>;
850
- };
851
- };
852
- declare const createOktaProvider: (_options?: OktaProviderOptions | undefined) => AuthProviderFactory;
853
-
854
- /** @public */
855
- declare type OneLoginProviderOptions = {
856
- /**
857
- * The profile transformation function used to verify and convert the auth response
858
- * into the profile that will be presented to the user.
859
- */
860
- authHandler?: AuthHandler<OAuthResult>;
861
- /**
862
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
863
- */
864
- signIn?: {
865
- /**
866
- * Maps an auth result to a Backstage identity for the user.
867
- */
868
- resolver: SignInResolver<OAuthResult>;
869
- };
870
- };
871
- /** @public */
872
- declare const createOneLoginProvider: (options?: OneLoginProviderOptions | undefined) => AuthProviderFactory;
873
-
874
- /** @public */
875
- declare type SamlAuthResult = {
876
- fullProfile: any;
877
- };
878
- /** @public */
879
- declare type SamlProviderOptions = {
880
- /**
881
- * The profile transformation function used to verify and convert the auth response
882
- * into the profile that will be presented to the user.
883
- */
884
- authHandler?: AuthHandler<SamlAuthResult>;
885
- /**
886
- * Configure sign-in for this provider, without it the provider can not be used to sign users in.
887
- */
888
- signIn?: {
889
- /**
890
- * Maps an auth result to a Backstage identity for the user.
891
- */
892
- resolver?: SignInResolver<SamlAuthResult>;
893
- };
894
- };
895
- /** @public */
896
- declare const createSamlProvider: (options?: SamlProviderOptions | undefined) => AuthProviderFactory;
897
-
898
- /**
899
- * The data extracted from an IAP token.
900
- *
901
- * @public
902
- */
903
- declare type GcpIapTokenInfo = {
904
- /**
905
- * The unique, stable identifier for the user.
906
- */
907
- sub: string;
908
- /**
909
- * User email address.
910
- */
911
- email: string;
912
- /**
913
- * Other fields.
914
- */
915
- [key: string]: JsonValue;
916
- };
917
- /**
918
- * The result of the initial auth challenge. This is the input to the auth
919
- * callbacks.
920
- *
921
- * @public
922
- */
923
- declare type GcpIapResult = {
924
- /**
925
- * The data extracted from the IAP token header.
926
- */
927
- iapToken: GcpIapTokenInfo;
928
- };
929
- /**
930
- * Options for {@link createGcpIapProvider}.
931
- *
932
- * @public
933
- */
934
- declare type GcpIapProviderOptions = {
935
- /**
936
- * The profile transformation function used to verify and convert the auth
937
- * response into the profile that will be presented to the user. The default
938
- * implementation just provides the authenticated email that the IAP
939
- * presented.
940
- */
941
- authHandler?: AuthHandler<GcpIapResult>;
942
- /**
943
- * Configures sign-in for this provider.
944
- */
945
- signIn: {
946
- /**
947
- * Maps an auth result to a Backstage identity for the user.
948
- */
949
- resolver: SignInResolver<GcpIapResult>;
950
- };
951
- };
952
-
953
- /**
954
- * Creates an auth provider for Google Identity-Aware Proxy.
955
- *
956
- * @public
957
- */
958
- declare function createGcpIapProvider(options: GcpIapProviderOptions): AuthProviderFactory;
959
-
960
- declare const factories: {
961
- [providerId: string]: AuthProviderFactory;
962
- };
963
-
964
- /**
965
- * Parses a Backstage-issued token and decorates the
966
- * {@link BackstageIdentityResponse} with identity information sourced from the
967
- * token.
968
- *
969
- * @public
970
- */
971
- declare function prepareBackstageIdentityResponse(result: BackstageSignInResult): BackstageIdentityResponse;
972
-
973
- declare type ProviderFactories = {
974
- [s: string]: AuthProviderFactory;
975
- };
976
- interface RouterOptions {
977
- logger: Logger;
978
- database: PluginDatabaseManager;
979
- config: Config;
980
- discovery: PluginEndpointDiscovery;
981
- tokenManager: TokenManager;
982
- providerFactories?: ProviderFactories;
983
- }
984
- declare function createRouter(options: RouterOptions): Promise<express.Router>;
985
- declare function createOriginFilter(config: Config): (origin: string) => boolean;
986
-
987
- /**
988
- * Payload sent as a post message after the auth request is complete.
989
- * If successful then has a valid payload with Auth information else contains an error.
990
- */
991
- declare type WebMessageResponse = {
992
- type: 'authorization_response';
993
- response: AuthResponse<unknown>;
994
- } | {
995
- type: 'authorization_response';
996
- error: Error;
997
- };
998
-
999
- declare const postMessageResponse: (res: express.Response, appOrigin: string, response: WebMessageResponse) => void;
1000
- declare const ensuresXRequestedWith: (req: express.Request) => boolean;
1001
-
1002
- export { AtlassianAuthProvider, AtlassianProviderOptions, Auth0ProviderOptions, AuthHandler, AuthHandlerResult, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResolverContext, AuthResponse, AwsAlbProviderOptions, BackstageIdentity, BackstageIdentityResponse, BackstageSignInResult, BackstageUserIdentity, BitbucketOAuthResult, BitbucketPassportProfile, BitbucketProviderOptions, CatalogIdentityClient, GcpIapProviderOptions, GcpIapResult, GcpIapTokenInfo, GithubOAuthResult, GithubProviderOptions, GitlabProviderOptions, GoogleProviderOptions, IdentityClient, 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 };