@backstage/plugin-auth-backend 0.12.3 → 0.13.0-next.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/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /// <reference types="node" />
2
2
  import express from 'express';
3
3
  import { Logger } from 'winston';
4
- import { Config } from '@backstage/config';
5
4
  import { TokenManager, PluginEndpointDiscovery, PluginDatabaseManager } from '@backstage/backend-common';
6
- import { CatalogApi } from '@backstage/catalog-client';
5
+ import { CatalogApi, GetEntitiesRequest } from '@backstage/catalog-client';
6
+ import { Config } from '@backstage/config';
7
7
  import { BackstageSignInResult, BackstageIdentityResponse } from '@backstage/plugin-auth-node';
8
8
  import { Profile } from 'passport';
9
- import { UserEntity } from '@backstage/catalog-model';
9
+ import { UserEntity, Entity } from '@backstage/catalog-model';
10
10
  import { TokenSet, UserinfoResponse } from 'openid-client';
11
11
  import { JsonValue } from '@backstage/types';
12
12
 
@@ -17,7 +17,11 @@ interface AnyJWK extends Record<string, string> {
17
17
  kid: string;
18
18
  kty: string;
19
19
  }
20
- /** Parameters used to issue new ID Tokens */
20
+ /**
21
+ * Parameters used to issue new ID Tokens
22
+ *
23
+ * @public
24
+ */
21
25
  declare type TokenParams = {
22
26
  /** The claims that will be embedded within the token */
23
27
  claims: {
@@ -29,6 +33,9 @@ declare type TokenParams = {
29
33
  };
30
34
  /**
31
35
  * A TokenIssuer is able to issue verifiable ID Tokens on demand.
36
+ *
37
+ * @public
38
+ * @deprecated This interface is deprecated and will be removed in a future release.
32
39
  */
33
40
  declare type TokenIssuer = {
34
41
  /**
@@ -178,17 +185,70 @@ declare class CatalogIdentityClient {
178
185
  resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]>;
179
186
  }
180
187
 
188
+ /**
189
+ * @deprecated use {@link getDefaultOwnershipEntityRefs} instead
190
+ */
181
191
  declare function getEntityClaims(entity: UserEntity): TokenParams['claims'];
182
192
 
193
+ /**
194
+ * A query for a single user in the catalog.
195
+ *
196
+ * If `entityRef` is used, the default kind is `'User'`.
197
+ *
198
+ * If `annotations` are used, all annotations must be present and
199
+ * match the provided value exactly. Only entities of kind `'User'` will be considered.
200
+ *
201
+ * If `filter` are used they are passed on as they are to the `CatalogApi`.
202
+ *
203
+ * Regardless of the query method, the query must match exactly one entity
204
+ * in the catalog, or an error will be thrown.
205
+ *
206
+ * @public
207
+ */
208
+ declare type AuthResolverCatalogUserQuery = {
209
+ entityRef: string | {
210
+ kind?: string;
211
+ namespace?: string;
212
+ name: string;
213
+ };
214
+ } | {
215
+ annotations: Record<string, string>;
216
+ } | {
217
+ filter: Exclude<GetEntitiesRequest['filter'], undefined>;
218
+ };
183
219
  /**
184
220
  * The context that is used for auth processing.
185
221
  *
186
222
  * @public
187
223
  */
188
224
  declare type AuthResolverContext = {
225
+ /** @deprecated Will be removed from the context, access it via a closure instead if needed */
226
+ logger: Logger;
227
+ /** @deprecated Use the `issueToken` method instead */
189
228
  tokenIssuer: TokenIssuer;
229
+ /** @deprecated Use the `findCatalogUser` and `signInWithCatalogUser` methods instead, and the `getDefaultOwnershipEntityRefs` helper */
190
230
  catalogIdentityClient: CatalogIdentityClient;
191
- logger: Logger;
231
+ /**
232
+ * Issues a Backstage token using the provided parameters.
233
+ */
234
+ issueToken(params: TokenParams): Promise<{
235
+ token: string;
236
+ }>;
237
+ /**
238
+ * Finds a single user in the catalog using the provided query.
239
+ *
240
+ * See {@link AuthResolverCatalogUserQuery} for details.
241
+ */
242
+ findCatalogUser(query: AuthResolverCatalogUserQuery): Promise<{
243
+ entity: Entity;
244
+ }>;
245
+ /**
246
+ * Finds a single user in the catalog using the provided query, and then
247
+ * issues an identity for that user using default ownership resolution.
248
+ *
249
+ * See {@link AuthResolverCatalogUserQuery} for details.
250
+ */
251
+ signInWithCatalogUser(query: AuthResolverCatalogUserQuery): Promise<BackstageSignInResult>;
192
252
  };
193
253
  /**
194
254
  * The callback used to resolve the cookie configuration for auth providers that use cookies.
@@ -206,6 +266,7 @@ declare type CookieConfigurer = (ctx: {
206
266
  path: string;
207
267
  secure: boolean;
208
268
  };
269
+ /** @public */
209
270
  declare type AuthProviderConfig = {
210
271
  /**
211
272
  * The protocol://domain[:port] where the app is hosted. This is used to construct the
@@ -286,6 +347,9 @@ interface AuthProviderRouteHandlers {
286
347
  */
287
348
  logout?(req: express.Request, res: express.Response): Promise<void>;
288
349
  }
350
+ /**
351
+ * @deprecated This type is deprecated and will be removed in a future release.
352
+ */
289
353
  declare type AuthProviderFactoryOptions = {
290
354
  providerId: string;
291
355
  globalConfig: AuthProviderConfig;
@@ -296,7 +360,22 @@ declare type AuthProviderFactoryOptions = {
296
360
  discovery: PluginEndpointDiscovery;
297
361
  catalogApi: CatalogApi;
298
362
  };
299
- declare type AuthProviderFactory = (options: AuthProviderFactoryOptions) => AuthProviderRouteHandlers;
363
+ declare type AuthProviderFactory = (options: {
364
+ providerId: string;
365
+ globalConfig: AuthProviderConfig;
366
+ config: Config;
367
+ logger: Logger;
368
+ resolverContext: AuthResolverContext;
369
+ /** @deprecated This field has been deprecated and needs to be passed directly to the auth provider instead */
370
+ tokenManager: TokenManager;
371
+ /** @deprecated This field has been deprecated and needs to be passed directly to the auth provider instead */
372
+ tokenIssuer: TokenIssuer;
373
+ /** @deprecated This field has been deprecated and needs to be passed directly to the auth provider instead */
374
+ discovery: PluginEndpointDiscovery;
375
+ /** @deprecated This field has been deprecated and needs to be passed directly to the auth provider instead */
376
+ catalogApi: CatalogApi;
377
+ }) => AuthProviderRouteHandlers;
378
+ /** @public */
300
379
  declare type AuthResponse<ProviderInfo> = {
301
380
  providerInfo: ProviderInfo;
302
381
  profile: ProfileInfo;
@@ -373,6 +452,7 @@ declare type AuthHandlerResult = {
373
452
  * @public
374
453
  */
375
454
  declare type AuthHandler<TAuthResult> = (input: TAuthResult, context: AuthResolverContext) => Promise<AuthHandlerResult>;
455
+ /** @public */
376
456
  declare type StateEncoder = (req: OAuthStartRequest) => Promise<{
377
457
  encodedState: string;
378
458
  }>;
@@ -397,7 +477,8 @@ declare type Options = {
397
477
  cookieDomain: string;
398
478
  cookiePath: string;
399
479
  appOrigin: string;
400
- tokenIssuer: TokenIssuer;
480
+ /** @deprecated This option is no longer needed */
481
+ tokenIssuer?: TokenIssuer;
401
482
  isOriginAllowed: (origin: string) => boolean;
402
483
  callbackUrl: string;
403
484
  };
@@ -431,17 +512,13 @@ declare type AtlassianAuthProviderOptions = OAuthProviderOptions & {
431
512
  scopes: string;
432
513
  signInResolver?: SignInResolver<OAuthResult>;
433
514
  authHandler: AuthHandler<OAuthResult>;
434
- tokenIssuer: TokenIssuer;
435
- catalogIdentityClient: CatalogIdentityClient;
436
- logger: Logger;
515
+ resolverContext: AuthResolverContext;
437
516
  };
438
517
  declare class AtlassianAuthProvider implements OAuthHandlers {
439
518
  private readonly _strategy;
440
519
  private readonly signInResolver?;
441
520
  private readonly authHandler;
442
- private readonly tokenIssuer;
443
- private readonly catalogIdentityClient;
444
- private readonly logger;
521
+ private readonly resolverContext;
445
522
  constructor(options: AtlassianAuthProviderOptions);
446
523
  start(req: OAuthStartRequest): Promise<RedirectInfo>;
447
524
  handler(req: express.Request): Promise<{
@@ -454,6 +531,10 @@ declare class AtlassianAuthProvider implements OAuthHandlers {
454
531
  refreshToken: string | undefined;
455
532
  }>;
456
533
  }
534
+ /**
535
+ * @public
536
+ * @deprecated This type has been inlined into the create method and will be removed.
537
+ */
457
538
  declare type AtlassianProviderOptions = {
458
539
  /**
459
540
  * The profile transformation function used to verify and convert the auth response
@@ -467,9 +548,28 @@ declare type AtlassianProviderOptions = {
467
548
  resolver: SignInResolver<OAuthResult>;
468
549
  };
469
550
  };
470
- declare const createAtlassianProvider: (options?: AtlassianProviderOptions | undefined) => AuthProviderFactory;
551
+ /**
552
+ * @public
553
+ * @deprecated Use `providers.atlassian.create` instead
554
+ */
555
+ declare const createAtlassianProvider: (options?: {
556
+ /**
557
+ * The profile transformation function used to verify and convert the auth response
558
+ * into the profile that will be presented to the user.
559
+ */
560
+ authHandler?: AuthHandler<OAuthResult> | undefined;
561
+ /**
562
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
563
+ */
564
+ signIn?: {
565
+ resolver: SignInResolver<OAuthResult>;
566
+ } | undefined;
567
+ } | undefined) => AuthProviderFactory;
471
568
 
472
- /** @public */
569
+ /**
570
+ * @public
571
+ * @deprecated This type has been inlined into the create method and will be removed.
572
+ */
473
573
  declare type Auth0ProviderOptions = {
474
574
  /**
475
575
  * The profile transformation function used to verify and convert the auth response
@@ -486,14 +586,37 @@ declare type Auth0ProviderOptions = {
486
586
  resolver: SignInResolver<OAuthResult>;
487
587
  };
488
588
  };
489
- /** @public */
490
- declare const createAuth0Provider: (options?: Auth0ProviderOptions | undefined) => AuthProviderFactory;
589
+ /**
590
+ * @public
591
+ * @deprecated Use `providers.auth0.create` instead.
592
+ */
593
+ declare const createAuth0Provider: (options?: {
594
+ /**
595
+ * The profile transformation function used to verify and convert the auth response
596
+ * into the profile that will be presented to the user.
597
+ */
598
+ authHandler?: AuthHandler<OAuthResult> | undefined;
599
+ /**
600
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
601
+ */
602
+ signIn?: {
603
+ /**
604
+ * Maps an auth result to a Backstage identity for the user.
605
+ */
606
+ resolver: SignInResolver<OAuthResult>;
607
+ } | undefined;
608
+ } | undefined) => AuthProviderFactory;
491
609
 
610
+ /** @public */
492
611
  declare type AwsAlbResult = {
493
612
  fullProfile: Profile;
494
613
  expiresInSeconds?: number;
495
614
  accessToken: string;
496
615
  };
616
+ /**
617
+ * @public
618
+ * @deprecated This type has been inlined into the create method and will be removed.
619
+ */
497
620
  declare type AwsAlbProviderOptions = {
498
621
  /**
499
622
  * The profile transformation function used to verify and convert the auth response
@@ -510,7 +633,26 @@ declare type AwsAlbProviderOptions = {
510
633
  resolver: SignInResolver<AwsAlbResult>;
511
634
  };
512
635
  };
513
- declare const createAwsAlbProvider: (options?: AwsAlbProviderOptions | undefined) => AuthProviderFactory;
636
+ /**
637
+ * @public
638
+ * @deprecated Use `providers.awsAlb.create` instead
639
+ */
640
+ declare const createAwsAlbProvider: (options?: {
641
+ /**
642
+ * The profile transformation function used to verify and convert the auth response
643
+ * into the profile that will be presented to the user.
644
+ */
645
+ authHandler?: AuthHandler<AwsAlbResult> | undefined;
646
+ /**
647
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
648
+ */
649
+ signIn: {
650
+ /**
651
+ * Maps an auth result to a Backstage identity for the user.
652
+ */
653
+ resolver: SignInResolver<AwsAlbResult>;
654
+ };
655
+ } | undefined) => AuthProviderFactory;
514
656
 
515
657
  declare type BitbucketOAuthResult = {
516
658
  fullProfile: BitbucketPassportProfile;
@@ -535,8 +677,10 @@ declare type BitbucketPassportProfile = Profile & {
535
677
  };
536
678
  };
537
679
  };
538
- declare const bitbucketUsernameSignInResolver: SignInResolver<BitbucketOAuthResult>;
539
- declare const bitbucketUserIdSignInResolver: SignInResolver<BitbucketOAuthResult>;
680
+ /**
681
+ * @public
682
+ * @deprecated This type has been inlined into the create method and will be removed.
683
+ */
540
684
  declare type BitbucketProviderOptions = {
541
685
  /**
542
686
  * The profile transformation function used to verify and convert the auth response
@@ -553,7 +697,36 @@ declare type BitbucketProviderOptions = {
553
697
  resolver: SignInResolver<OAuthResult>;
554
698
  };
555
699
  };
556
- declare const createBitbucketProvider: (options?: BitbucketProviderOptions | undefined) => AuthProviderFactory;
700
+ /**
701
+ * @public
702
+ * @deprecated Use `providers.bitbucket.create` instead
703
+ */
704
+ declare const createBitbucketProvider: (options?: {
705
+ /**
706
+ * The profile transformation function used to verify and convert the auth response
707
+ * into the profile that will be presented to the user.
708
+ */
709
+ authHandler?: AuthHandler<OAuthResult> | undefined;
710
+ /**
711
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
712
+ */
713
+ signIn?: {
714
+ /**
715
+ * Maps an auth result to a Backstage identity for the user.
716
+ */
717
+ resolver: SignInResolver<OAuthResult>;
718
+ } | undefined;
719
+ } | undefined) => AuthProviderFactory;
720
+ /**
721
+ * @public
722
+ * @deprecated Use `providers.bitbucket.resolvers.usernameMatchingUserEntityAnnotation()` instead.
723
+ */
724
+ declare const bitbucketUsernameSignInResolver: SignInResolver<OAuthResult>;
725
+ /**
726
+ * @public
727
+ * @deprecated Use `providers.bitbucket.resolvers.userIdMatchingUserEntityAnnotation()` instead.
728
+ */
729
+ declare const bitbucketUserIdSignInResolver: SignInResolver<OAuthResult>;
557
730
 
558
731
  declare type GithubOAuthResult = {
559
732
  fullProfile: Profile;
@@ -565,6 +738,10 @@ declare type GithubOAuthResult = {
565
738
  accessToken: string;
566
739
  refreshToken?: string;
567
740
  };
741
+ /**
742
+ * @public
743
+ * @deprecated This type has been inlined into the create method and will be removed.
744
+ */
568
745
  declare type GithubProviderOptions = {
569
746
  /**
570
747
  * The profile transformation function used to verify and convert the auth response
@@ -578,7 +755,7 @@ declare type GithubProviderOptions = {
578
755
  /**
579
756
  * Maps an auth result to a Backstage identity for the user.
580
757
  */
581
- resolver?: SignInResolver<GithubOAuthResult>;
758
+ resolver: SignInResolver<GithubOAuthResult>;
582
759
  };
583
760
  /**
584
761
  * The state encoder used to encode the 'state' parameter on the OAuth request.
@@ -598,8 +775,48 @@ declare type GithubProviderOptions = {
598
775
  */
599
776
  stateEncoder?: StateEncoder;
600
777
  };
601
- declare const createGithubProvider: (options?: GithubProviderOptions | undefined) => AuthProviderFactory;
778
+ /**
779
+ * @public
780
+ * @deprecated Use `providers.github.create` instead
781
+ */
782
+ declare const createGithubProvider: (options?: {
783
+ /**
784
+ * The profile transformation function used to verify and convert the auth response
785
+ * into the profile that will be presented to the user.
786
+ */
787
+ authHandler?: AuthHandler<GithubOAuthResult> | undefined;
788
+ /**
789
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
790
+ */
791
+ signIn?: {
792
+ /**
793
+ * Maps an auth result to a Backstage identity for the user.
794
+ */
795
+ resolver: SignInResolver<GithubOAuthResult>;
796
+ } | undefined;
797
+ /**
798
+ * The state encoder used to encode the 'state' parameter on the OAuth request.
799
+ *
800
+ * It should return a string that takes the state params (from the request), url encodes the params
801
+ * and finally base64 encodes them.
802
+ *
803
+ * Providing your own stateEncoder will allow you to add addition parameters to the state field.
804
+ *
805
+ * It is typed as follows:
806
+ * `export type StateEncoder = (input: OAuthState) => Promise<{encodedState: string}>;`
807
+ *
808
+ * Note: the stateEncoder must encode a 'nonce' value and an 'env' value. Without this, the OAuth flow will fail
809
+ * (These two values will be set by the req.state by default)
810
+ *
811
+ * For more information, please see the helper module in ../../oauth/helpers #readState
812
+ */
813
+ stateEncoder?: StateEncoder | undefined;
814
+ } | undefined) => AuthProviderFactory;
602
815
 
816
+ /**
817
+ * @public
818
+ * @deprecated This type has been inlined into the create method and will be removed.
819
+ */
603
820
  declare type GitlabProviderOptions = {
604
821
  /**
605
822
  * The profile transformation function used to verify and convert the auth response
@@ -616,12 +833,31 @@ declare type GitlabProviderOptions = {
616
833
  * the catalog for a single user entity that has a matching `microsoft.com/email` annotation.
617
834
  */
618
835
  signIn?: {
619
- resolver?: SignInResolver<OAuthResult>;
836
+ resolver: SignInResolver<OAuthResult>;
620
837
  };
621
838
  };
622
- declare const createGitlabProvider: (options?: GitlabProviderOptions | undefined) => AuthProviderFactory;
839
+ /**
840
+ * @public
841
+ * @deprecated Use `providers.gitlab.create` instead
842
+ */
843
+ declare const createGitlabProvider: (options?: {
844
+ /**
845
+ * The profile transformation function used to verify and convert the auth response
846
+ * into the profile that will be presented to the user.
847
+ */
848
+ authHandler?: AuthHandler<OAuthResult> | undefined;
849
+ /**
850
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
851
+ */
852
+ signIn?: {
853
+ resolver: SignInResolver<OAuthResult>;
854
+ } | undefined;
855
+ } | undefined) => AuthProviderFactory;
623
856
 
624
- declare const googleEmailSignInResolver: SignInResolver<OAuthResult>;
857
+ /**
858
+ * @public
859
+ * @deprecated This type has been inlined into the create method and will be removed.
860
+ */
625
861
  declare type GoogleProviderOptions = {
626
862
  /**
627
863
  * The profile transformation function used to verify and convert the auth response
@@ -635,12 +871,39 @@ declare type GoogleProviderOptions = {
635
871
  /**
636
872
  * Maps an auth result to a Backstage identity for the user.
637
873
  */
638
- resolver?: SignInResolver<OAuthResult>;
874
+ resolver: SignInResolver<OAuthResult>;
639
875
  };
640
876
  };
641
- declare const createGoogleProvider: (options?: GoogleProviderOptions | undefined) => AuthProviderFactory;
877
+ /**
878
+ * @public
879
+ * @deprecated Use `providers.google.create` instead.
880
+ */
881
+ declare const createGoogleProvider: (options?: {
882
+ /**
883
+ * The profile transformation function used to verify and convert the auth response
884
+ * into the profile that will be presented to the user.
885
+ */
886
+ authHandler?: AuthHandler<OAuthResult> | undefined;
887
+ /**
888
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
889
+ */
890
+ signIn?: {
891
+ /**
892
+ * Maps an auth result to a Backstage identity for the user.
893
+ */
894
+ resolver: SignInResolver<OAuthResult>;
895
+ } | undefined;
896
+ } | undefined) => AuthProviderFactory;
897
+ /**
898
+ * @public
899
+ * @deprecated Use `providers.google.resolvers.emailMatchingUserEntityAnnotation()` instead.
900
+ */
901
+ declare const googleEmailSignInResolver: SignInResolver<OAuthResult>;
642
902
 
643
- declare const microsoftEmailSignInResolver: SignInResolver<OAuthResult>;
903
+ /**
904
+ * @public
905
+ * @deprecated This type has been inlined into the create method and will be removed.
906
+ */
644
907
  declare type MicrosoftProviderOptions = {
645
908
  /**
646
909
  * The profile transformation function used to verify and convert the auth response
@@ -654,18 +917,55 @@ declare type MicrosoftProviderOptions = {
654
917
  /**
655
918
  * Maps an auth result to a Backstage identity for the user.
656
919
  */
657
- resolver?: SignInResolver<OAuthResult>;
920
+ resolver: SignInResolver<OAuthResult>;
658
921
  };
659
922
  };
660
- declare const createMicrosoftProvider: (options?: MicrosoftProviderOptions | undefined) => AuthProviderFactory;
923
+ /**
924
+ * @public
925
+ * @deprecated Use `providers.microsoft.create` instead
926
+ */
927
+ declare const createMicrosoftProvider: (options?: {
928
+ /**
929
+ * The profile transformation function used to verify and convert the auth response
930
+ * into the profile that will be presented to the user.
931
+ */
932
+ authHandler?: AuthHandler<OAuthResult> | undefined;
933
+ /**
934
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
935
+ */
936
+ signIn?: {
937
+ /**
938
+ * Maps an auth result to a Backstage identity for the user.
939
+ */
940
+ resolver: SignInResolver<OAuthResult>;
941
+ } | undefined;
942
+ } | undefined) => AuthProviderFactory;
943
+ /**
944
+ * @public
945
+ * @deprecated Use `providers.microsoft.resolvers.emailMatchingUserEntityAnnotation()` instead.
946
+ */
947
+ declare const microsoftEmailSignInResolver: SignInResolver<OAuthResult>;
661
948
 
949
+ /**
950
+ * @public
951
+ * @deprecated This type has been inlined into the create method and will be removed.
952
+ */
662
953
  declare type OAuth2ProviderOptions = {
663
954
  authHandler?: AuthHandler<OAuthResult>;
664
955
  signIn?: {
665
- resolver?: SignInResolver<OAuthResult>;
956
+ resolver: SignInResolver<OAuthResult>;
666
957
  };
667
958
  };
668
- declare const createOAuth2Provider: (options?: OAuth2ProviderOptions | undefined) => AuthProviderFactory;
959
+ /**
960
+ * @public
961
+ * @deprecated Use `providers.oauth2.create` instead
962
+ */
963
+ declare const createOAuth2Provider: (options?: {
964
+ authHandler?: AuthHandler<OAuthResult> | undefined;
965
+ signIn?: {
966
+ resolver: SignInResolver<OAuthResult>;
967
+ } | undefined;
968
+ } | undefined) => AuthProviderFactory;
669
969
 
670
970
  /**
671
971
  * JWT header extraction result, containing the raw value and the parsed JWT
@@ -684,9 +984,8 @@ declare type OAuth2ProxyResult<JWTPayload> = {
684
984
  accessToken: string;
685
985
  };
686
986
  /**
687
- * Options for the oauth2-proxy provider factory
688
- *
689
987
  * @public
988
+ * @deprecated This type has been inlined into the create method and will be removed.
690
989
  */
691
990
  declare type Oauth2ProxyProviderOptions<JWTPayload> = {
692
991
  /**
@@ -704,11 +1003,24 @@ declare type Oauth2ProxyProviderOptions<JWTPayload> = {
704
1003
  };
705
1004
  };
706
1005
  /**
707
- * Factory function for oauth2-proxy auth provider
708
- *
709
1006
  * @public
1007
+ * @deprecated Use `providers.oauth2Proxy.create` instead
710
1008
  */
711
- declare const createOauth2ProxyProvider: <JWTPayload>(options: Oauth2ProxyProviderOptions<JWTPayload>) => AuthProviderFactory;
1009
+ declare const createOauth2ProxyProvider: (options: {
1010
+ /**
1011
+ * Configure an auth handler to generate a profile for the user.
1012
+ */
1013
+ authHandler: AuthHandler<OAuth2ProxyResult<unknown>>;
1014
+ /**
1015
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
1016
+ */
1017
+ signIn: {
1018
+ /**
1019
+ * Maps an auth result to a Backstage identity for the user.
1020
+ */
1021
+ resolver: SignInResolver<OAuth2ProxyResult<unknown>>;
1022
+ };
1023
+ }) => AuthProviderFactory;
712
1024
 
713
1025
  /**
714
1026
  * authentication result for the OIDC which includes the token set and user information (a profile response sent by OIDC server)
@@ -719,26 +1031,30 @@ declare type OidcAuthResult = {
719
1031
  userinfo: UserinfoResponse;
720
1032
  };
721
1033
  /**
722
- * OIDC provider callback options. An auth handler and a sign in resolver
723
- * can be passed while creating a OIDC provider.
724
- *
725
- * authHandler : called after sign in was successful, a new object must be returned which includes a profile
726
- * signInResolver: called after sign in was successful, expects to return a new {@link @backstage/plugin-auth-node#BackstageSignInResult}
727
- *
728
- * Both options are optional. There is fallback for authHandler where the default handler expect an e-mail explicitly
729
- * otherwise it throws an error
730
- *
731
1034
  * @public
1035
+ * @deprecated This type has been inlined into the create method and will be removed.
732
1036
  */
733
1037
  declare type OidcProviderOptions = {
734
1038
  authHandler?: AuthHandler<OidcAuthResult>;
735
1039
  signIn?: {
736
- resolver?: SignInResolver<OidcAuthResult>;
1040
+ resolver: SignInResolver<OidcAuthResult>;
737
1041
  };
738
1042
  };
739
- declare const createOidcProvider: (options?: OidcProviderOptions | undefined) => AuthProviderFactory;
1043
+ /**
1044
+ * @public
1045
+ * @deprecated Use `providers.oidc.create` instead
1046
+ */
1047
+ declare const createOidcProvider: (options?: {
1048
+ authHandler?: AuthHandler<OidcAuthResult> | undefined;
1049
+ signIn?: {
1050
+ resolver: SignInResolver<OidcAuthResult>;
1051
+ } | undefined;
1052
+ } | undefined) => AuthProviderFactory;
740
1053
 
741
- declare const oktaEmailSignInResolver: SignInResolver<OAuthResult>;
1054
+ /**
1055
+ * @public
1056
+ * @deprecated This type has been inlined into the create method and will be removed.
1057
+ */
742
1058
  declare type OktaProviderOptions = {
743
1059
  /**
744
1060
  * The profile transformation function used to verify and convert the auth response
@@ -752,12 +1068,39 @@ declare type OktaProviderOptions = {
752
1068
  /**
753
1069
  * Maps an auth result to a Backstage identity for the user.
754
1070
  */
755
- resolver?: SignInResolver<OAuthResult>;
1071
+ resolver: SignInResolver<OAuthResult>;
756
1072
  };
757
1073
  };
758
- declare const createOktaProvider: (_options?: OktaProviderOptions | undefined) => AuthProviderFactory;
1074
+ /**
1075
+ * @public
1076
+ * @deprecated Use `providers.okta.create` instead
1077
+ */
1078
+ declare const createOktaProvider: (options?: {
1079
+ /**
1080
+ * The profile transformation function used to verify and convert the auth response
1081
+ * into the profile that will be presented to the user.
1082
+ */
1083
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1084
+ /**
1085
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
1086
+ */
1087
+ signIn?: {
1088
+ /**
1089
+ * Maps an auth result to a Backstage identity for the user.
1090
+ */
1091
+ resolver: SignInResolver<OAuthResult>;
1092
+ } | undefined;
1093
+ } | undefined) => AuthProviderFactory;
1094
+ /**
1095
+ * @public
1096
+ * @deprecated Use `providers.okta.resolvers.emailMatchingUserEntityAnnotation()` instead.
1097
+ */
1098
+ declare const oktaEmailSignInResolver: SignInResolver<OAuthResult>;
759
1099
 
760
- /** @public */
1100
+ /**
1101
+ * @public
1102
+ * @deprecated This type has been inlined into the create method and will be removed.
1103
+ */
761
1104
  declare type OneLoginProviderOptions = {
762
1105
  /**
763
1106
  * The profile transformation function used to verify and convert the auth response
@@ -774,14 +1117,35 @@ declare type OneLoginProviderOptions = {
774
1117
  resolver: SignInResolver<OAuthResult>;
775
1118
  };
776
1119
  };
777
- /** @public */
778
- declare const createOneLoginProvider: (options?: OneLoginProviderOptions | undefined) => AuthProviderFactory;
1120
+ /**
1121
+ * @public
1122
+ * @deprecated Use `providers.onelogin.create` instead
1123
+ */
1124
+ declare const createOneLoginProvider: (options?: {
1125
+ /**
1126
+ * The profile transformation function used to verify and convert the auth response
1127
+ * into the profile that will be presented to the user.
1128
+ */
1129
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1130
+ /**
1131
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
1132
+ */
1133
+ signIn?: {
1134
+ /**
1135
+ * Maps an auth result to a Backstage identity for the user.
1136
+ */
1137
+ resolver: SignInResolver<OAuthResult>;
1138
+ } | undefined;
1139
+ } | undefined) => AuthProviderFactory;
779
1140
 
780
1141
  /** @public */
781
1142
  declare type SamlAuthResult = {
782
1143
  fullProfile: any;
783
1144
  };
784
- /** @public */
1145
+ /**
1146
+ * @public
1147
+ * @deprecated This type has been inlined into the create method and will be removed.
1148
+ */
785
1149
  declare type SamlProviderOptions = {
786
1150
  /**
787
1151
  * The profile transformation function used to verify and convert the auth response
@@ -795,11 +1159,34 @@ declare type SamlProviderOptions = {
795
1159
  /**
796
1160
  * Maps an auth result to a Backstage identity for the user.
797
1161
  */
798
- resolver?: SignInResolver<SamlAuthResult>;
1162
+ resolver: SignInResolver<SamlAuthResult>;
799
1163
  };
800
1164
  };
801
- /** @public */
802
- declare const createSamlProvider: (options?: SamlProviderOptions | undefined) => AuthProviderFactory;
1165
+ /**
1166
+ * @public
1167
+ * @deprecated Use `providers.saml.create` instead
1168
+ */
1169
+ declare const createSamlProvider: (options?: {
1170
+ /**
1171
+ * The profile transformation function used to verify and convert the auth response
1172
+ * into the profile that will be presented to the user.
1173
+ */
1174
+ authHandler?: AuthHandler<SamlAuthResult> | undefined;
1175
+ /**
1176
+ * Configure sign-in for this provider, without it the provider can not be used to sign users in.
1177
+ */
1178
+ signIn?: {
1179
+ /**
1180
+ * Maps an auth result to a Backstage identity for the user.
1181
+ */
1182
+ resolver: SignInResolver<SamlAuthResult>;
1183
+ } | undefined;
1184
+ } | undefined) => AuthProviderFactory;
1185
+ /**
1186
+ * @public
1187
+ * @deprecated Use `providers.saml.resolvers.nameIdMatchingUserEntityName()` instead.
1188
+ */
1189
+ declare const samlNameIdEntityNameSignInResolver: SignInResolver<SamlAuthResult>;
803
1190
 
804
1191
  /**
805
1192
  * The data extracted from an IAP token.
@@ -833,9 +1220,8 @@ declare type GcpIapResult = {
833
1220
  iapToken: GcpIapTokenInfo;
834
1221
  };
835
1222
  /**
836
- * Options for {@link createGcpIapProvider}.
837
- *
838
1223
  * @public
1224
+ * @deprecated This type has been inlined into the create method and will be removed.
839
1225
  */
840
1226
  declare type GcpIapProviderOptions = {
841
1227
  /**
@@ -857,11 +1243,185 @@ declare type GcpIapProviderOptions = {
857
1243
  };
858
1244
 
859
1245
  /**
860
- * Creates an auth provider for Google Identity-Aware Proxy.
1246
+ * @public
1247
+ * @deprecated Use `providers.gcpIap.create` instead
1248
+ */
1249
+ declare const createGcpIapProvider: (options: {
1250
+ /**
1251
+ * The profile transformation function used to verify and convert the auth
1252
+ * response into the profile that will be presented to the user. The default
1253
+ * implementation just provides the authenticated email that the IAP
1254
+ * presented.
1255
+ */
1256
+ authHandler?: AuthHandler<GcpIapResult> | undefined;
1257
+ /**
1258
+ * Configures sign-in for this provider.
1259
+ */
1260
+ signIn: {
1261
+ /**
1262
+ * Maps an auth result to a Backstage identity for the user.
1263
+ */
1264
+ resolver: SignInResolver<GcpIapResult>;
1265
+ };
1266
+ }) => AuthProviderFactory;
1267
+
1268
+ /**
1269
+ * All built-in auth provider integrations.
861
1270
  *
862
1271
  * @public
863
1272
  */
864
- declare function createGcpIapProvider(options: GcpIapProviderOptions): AuthProviderFactory;
1273
+ declare const providers: Readonly<{
1274
+ atlassian: Readonly<{
1275
+ create: (options?: {
1276
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1277
+ signIn?: {
1278
+ resolver: SignInResolver<OAuthResult>;
1279
+ } | undefined;
1280
+ } | undefined) => AuthProviderFactory;
1281
+ resolvers: never;
1282
+ }>;
1283
+ auth0: Readonly<{
1284
+ create: (options?: {
1285
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1286
+ signIn?: {
1287
+ resolver: SignInResolver<OAuthResult>;
1288
+ } | undefined;
1289
+ } | undefined) => AuthProviderFactory;
1290
+ resolvers: never;
1291
+ }>;
1292
+ awsAlb: Readonly<{
1293
+ create: (options?: {
1294
+ authHandler?: AuthHandler<AwsAlbResult> | undefined;
1295
+ signIn: {
1296
+ resolver: SignInResolver<AwsAlbResult>;
1297
+ };
1298
+ } | undefined) => AuthProviderFactory;
1299
+ resolvers: never;
1300
+ }>;
1301
+ bitbucket: Readonly<{
1302
+ create: (options?: {
1303
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1304
+ signIn?: {
1305
+ resolver: SignInResolver<OAuthResult>;
1306
+ } | undefined;
1307
+ } | undefined) => AuthProviderFactory;
1308
+ resolvers: Readonly<{
1309
+ usernameMatchingUserEntityAnnotation(): SignInResolver<OAuthResult>;
1310
+ userIdMatchingUserEntityAnnotation(): SignInResolver<OAuthResult>;
1311
+ }>;
1312
+ }>;
1313
+ gcpIap: Readonly<{
1314
+ create: (options: {
1315
+ authHandler?: AuthHandler<GcpIapResult> | undefined;
1316
+ signIn: {
1317
+ resolver: SignInResolver<GcpIapResult>;
1318
+ };
1319
+ }) => AuthProviderFactory;
1320
+ resolvers: never;
1321
+ }>;
1322
+ github: Readonly<{
1323
+ create: (options?: {
1324
+ authHandler?: AuthHandler<GithubOAuthResult> | undefined;
1325
+ signIn?: {
1326
+ resolver: SignInResolver<GithubOAuthResult>;
1327
+ } | undefined;
1328
+ stateEncoder?: StateEncoder | undefined;
1329
+ } | undefined) => AuthProviderFactory;
1330
+ resolvers: Readonly<{
1331
+ usernameMatchingUserEntityName: () => SignInResolver<GithubOAuthResult>;
1332
+ }>;
1333
+ }>;
1334
+ gitlab: Readonly<{
1335
+ create: (options?: {
1336
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1337
+ signIn?: {
1338
+ resolver: SignInResolver<OAuthResult>;
1339
+ } | undefined;
1340
+ } | undefined) => AuthProviderFactory;
1341
+ resolvers: never;
1342
+ }>;
1343
+ google: Readonly<{
1344
+ create: (options?: {
1345
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1346
+ signIn?: {
1347
+ resolver: SignInResolver<OAuthResult>;
1348
+ } | undefined;
1349
+ } | undefined) => AuthProviderFactory;
1350
+ resolvers: Readonly<{
1351
+ emailLocalPartMatchingUserEntityName: () => SignInResolver<unknown>;
1352
+ emailMatchingUserEntityAnnotation(): SignInResolver<OAuthResult>;
1353
+ }>;
1354
+ }>;
1355
+ microsoft: Readonly<{
1356
+ create: (options?: {
1357
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1358
+ signIn?: {
1359
+ resolver: SignInResolver<OAuthResult>;
1360
+ } | undefined;
1361
+ } | undefined) => AuthProviderFactory;
1362
+ resolvers: Readonly<{
1363
+ emailMatchingUserEntityAnnotation(): SignInResolver<OAuthResult>;
1364
+ }>;
1365
+ }>;
1366
+ oauth2: Readonly<{
1367
+ create: (options?: {
1368
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1369
+ signIn?: {
1370
+ resolver: SignInResolver<OAuthResult>;
1371
+ } | undefined;
1372
+ } | undefined) => AuthProviderFactory;
1373
+ resolvers: never;
1374
+ }>;
1375
+ oauth2Proxy: Readonly<{
1376
+ create: (options: {
1377
+ authHandler: AuthHandler<OAuth2ProxyResult<unknown>>;
1378
+ signIn: {
1379
+ resolver: SignInResolver<OAuth2ProxyResult<unknown>>;
1380
+ };
1381
+ }) => AuthProviderFactory;
1382
+ resolvers: never;
1383
+ }>;
1384
+ oidc: Readonly<{
1385
+ create: (options?: {
1386
+ authHandler?: AuthHandler<OidcAuthResult> | undefined;
1387
+ signIn?: {
1388
+ resolver: SignInResolver<OidcAuthResult>;
1389
+ } | undefined;
1390
+ } | undefined) => AuthProviderFactory;
1391
+ resolvers: never;
1392
+ }>;
1393
+ okta: Readonly<{
1394
+ create: (options?: {
1395
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1396
+ signIn?: {
1397
+ resolver: SignInResolver<OAuthResult>;
1398
+ } | undefined;
1399
+ } | undefined) => AuthProviderFactory;
1400
+ resolvers: Readonly<{
1401
+ emailMatchingUserEntityAnnotation(): SignInResolver<OAuthResult>;
1402
+ }>;
1403
+ }>;
1404
+ onelogin: Readonly<{
1405
+ create: (options?: {
1406
+ authHandler?: AuthHandler<OAuthResult> | undefined;
1407
+ signIn?: {
1408
+ resolver: SignInResolver<OAuthResult>;
1409
+ } | undefined;
1410
+ } | undefined) => AuthProviderFactory;
1411
+ resolvers: never;
1412
+ }>;
1413
+ saml: Readonly<{
1414
+ create: (options?: {
1415
+ authHandler?: AuthHandler<SamlAuthResult> | undefined;
1416
+ signIn?: {
1417
+ resolver: SignInResolver<SamlAuthResult>;
1418
+ } | undefined;
1419
+ } | undefined) => AuthProviderFactory;
1420
+ resolvers: Readonly<{
1421
+ nameIdMatchingUserEntityName(): SignInResolver<SamlAuthResult>;
1422
+ }>;
1423
+ }>;
1424
+ }>;
865
1425
 
866
1426
  declare const factories: {
867
1427
  [providerId: string]: AuthProviderFactory;
@@ -905,4 +1465,14 @@ declare type WebMessageResponse = {
905
1465
  declare const postMessageResponse: (res: express.Response, appOrigin: string, response: WebMessageResponse) => void;
906
1466
  declare const ensuresXRequestedWith: (req: express.Request) => boolean;
907
1467
 
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 };
1468
+ /**
1469
+ * Uses the default ownership resolution logic to return an array
1470
+ * of entity refs that the provided entity claims ownership through.
1471
+ *
1472
+ * A reference to the entity itself will also be included in the returned array.
1473
+ *
1474
+ * @public
1475
+ */
1476
+ declare function getDefaultOwnershipEntityRefs(entity: Entity): string[];
1477
+
1478
+ export { AtlassianAuthProvider, AtlassianProviderOptions, Auth0ProviderOptions, AuthHandler, AuthHandlerResult, AuthProviderConfig, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResolverCatalogUserQuery, AuthResolverContext, AuthResponse, AwsAlbProviderOptions, AwsAlbResult, 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, StateEncoder, TokenIssuer, TokenParams, 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, getDefaultOwnershipEntityRefs, getEntityClaims, googleEmailSignInResolver, microsoftEmailSignInResolver, oktaEmailSignInResolver, postMessageResponse, prepareBackstageIdentityResponse, providers, readState, samlNameIdEntityNameSignInResolver, verifyNonce };