@backstage/plugin-auth-backend 0.13.0-next.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
  }>;
@@ -432,17 +512,13 @@ declare type AtlassianAuthProviderOptions = OAuthProviderOptions & {
432
512
  scopes: string;
433
513
  signInResolver?: SignInResolver<OAuthResult>;
434
514
  authHandler: AuthHandler<OAuthResult>;
435
- tokenIssuer: TokenIssuer;
436
- catalogIdentityClient: CatalogIdentityClient;
437
- logger: Logger;
515
+ resolverContext: AuthResolverContext;
438
516
  };
439
517
  declare class AtlassianAuthProvider implements OAuthHandlers {
440
518
  private readonly _strategy;
441
519
  private readonly signInResolver?;
442
520
  private readonly authHandler;
443
- private readonly tokenIssuer;
444
- private readonly catalogIdentityClient;
445
- private readonly logger;
521
+ private readonly resolverContext;
446
522
  constructor(options: AtlassianAuthProviderOptions);
447
523
  start(req: OAuthStartRequest): Promise<RedirectInfo>;
448
524
  handler(req: express.Request): Promise<{
@@ -455,6 +531,10 @@ declare class AtlassianAuthProvider implements OAuthHandlers {
455
531
  refreshToken: string | undefined;
456
532
  }>;
457
533
  }
534
+ /**
535
+ * @public
536
+ * @deprecated This type has been inlined into the create method and will be removed.
537
+ */
458
538
  declare type AtlassianProviderOptions = {
459
539
  /**
460
540
  * The profile transformation function used to verify and convert the auth response
@@ -468,9 +548,28 @@ declare type AtlassianProviderOptions = {
468
548
  resolver: SignInResolver<OAuthResult>;
469
549
  };
470
550
  };
471
- 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;
472
568
 
473
- /** @public */
569
+ /**
570
+ * @public
571
+ * @deprecated This type has been inlined into the create method and will be removed.
572
+ */
474
573
  declare type Auth0ProviderOptions = {
475
574
  /**
476
575
  * The profile transformation function used to verify and convert the auth response
@@ -487,14 +586,37 @@ declare type Auth0ProviderOptions = {
487
586
  resolver: SignInResolver<OAuthResult>;
488
587
  };
489
588
  };
490
- /** @public */
491
- 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;
492
609
 
610
+ /** @public */
493
611
  declare type AwsAlbResult = {
494
612
  fullProfile: Profile;
495
613
  expiresInSeconds?: number;
496
614
  accessToken: string;
497
615
  };
616
+ /**
617
+ * @public
618
+ * @deprecated This type has been inlined into the create method and will be removed.
619
+ */
498
620
  declare type AwsAlbProviderOptions = {
499
621
  /**
500
622
  * The profile transformation function used to verify and convert the auth response
@@ -511,7 +633,26 @@ declare type AwsAlbProviderOptions = {
511
633
  resolver: SignInResolver<AwsAlbResult>;
512
634
  };
513
635
  };
514
- 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;
515
656
 
516
657
  declare type BitbucketOAuthResult = {
517
658
  fullProfile: BitbucketPassportProfile;
@@ -536,8 +677,10 @@ declare type BitbucketPassportProfile = Profile & {
536
677
  };
537
678
  };
538
679
  };
539
- declare const bitbucketUsernameSignInResolver: SignInResolver<BitbucketOAuthResult>;
540
- declare const bitbucketUserIdSignInResolver: SignInResolver<BitbucketOAuthResult>;
680
+ /**
681
+ * @public
682
+ * @deprecated This type has been inlined into the create method and will be removed.
683
+ */
541
684
  declare type BitbucketProviderOptions = {
542
685
  /**
543
686
  * The profile transformation function used to verify and convert the auth response
@@ -554,7 +697,36 @@ declare type BitbucketProviderOptions = {
554
697
  resolver: SignInResolver<OAuthResult>;
555
698
  };
556
699
  };
557
- 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>;
558
730
 
559
731
  declare type GithubOAuthResult = {
560
732
  fullProfile: Profile;
@@ -566,6 +738,10 @@ declare type GithubOAuthResult = {
566
738
  accessToken: string;
567
739
  refreshToken?: string;
568
740
  };
741
+ /**
742
+ * @public
743
+ * @deprecated This type has been inlined into the create method and will be removed.
744
+ */
569
745
  declare type GithubProviderOptions = {
570
746
  /**
571
747
  * The profile transformation function used to verify and convert the auth response
@@ -579,7 +755,7 @@ declare type GithubProviderOptions = {
579
755
  /**
580
756
  * Maps an auth result to a Backstage identity for the user.
581
757
  */
582
- resolver?: SignInResolver<GithubOAuthResult>;
758
+ resolver: SignInResolver<GithubOAuthResult>;
583
759
  };
584
760
  /**
585
761
  * The state encoder used to encode the 'state' parameter on the OAuth request.
@@ -599,8 +775,48 @@ declare type GithubProviderOptions = {
599
775
  */
600
776
  stateEncoder?: StateEncoder;
601
777
  };
602
- 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;
603
815
 
816
+ /**
817
+ * @public
818
+ * @deprecated This type has been inlined into the create method and will be removed.
819
+ */
604
820
  declare type GitlabProviderOptions = {
605
821
  /**
606
822
  * The profile transformation function used to verify and convert the auth response
@@ -617,12 +833,31 @@ declare type GitlabProviderOptions = {
617
833
  * the catalog for a single user entity that has a matching `microsoft.com/email` annotation.
618
834
  */
619
835
  signIn?: {
620
- resolver?: SignInResolver<OAuthResult>;
836
+ resolver: SignInResolver<OAuthResult>;
621
837
  };
622
838
  };
623
- 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;
624
856
 
625
- declare const googleEmailSignInResolver: SignInResolver<OAuthResult>;
857
+ /**
858
+ * @public
859
+ * @deprecated This type has been inlined into the create method and will be removed.
860
+ */
626
861
  declare type GoogleProviderOptions = {
627
862
  /**
628
863
  * The profile transformation function used to verify and convert the auth response
@@ -636,12 +871,39 @@ declare type GoogleProviderOptions = {
636
871
  /**
637
872
  * Maps an auth result to a Backstage identity for the user.
638
873
  */
639
- resolver?: SignInResolver<OAuthResult>;
874
+ resolver: SignInResolver<OAuthResult>;
640
875
  };
641
876
  };
642
- 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>;
643
902
 
644
- declare const microsoftEmailSignInResolver: SignInResolver<OAuthResult>;
903
+ /**
904
+ * @public
905
+ * @deprecated This type has been inlined into the create method and will be removed.
906
+ */
645
907
  declare type MicrosoftProviderOptions = {
646
908
  /**
647
909
  * The profile transformation function used to verify and convert the auth response
@@ -655,18 +917,55 @@ declare type MicrosoftProviderOptions = {
655
917
  /**
656
918
  * Maps an auth result to a Backstage identity for the user.
657
919
  */
658
- resolver?: SignInResolver<OAuthResult>;
920
+ resolver: SignInResolver<OAuthResult>;
659
921
  };
660
922
  };
661
- 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>;
662
948
 
949
+ /**
950
+ * @public
951
+ * @deprecated This type has been inlined into the create method and will be removed.
952
+ */
663
953
  declare type OAuth2ProviderOptions = {
664
954
  authHandler?: AuthHandler<OAuthResult>;
665
955
  signIn?: {
666
- resolver?: SignInResolver<OAuthResult>;
956
+ resolver: SignInResolver<OAuthResult>;
667
957
  };
668
958
  };
669
- 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;
670
969
 
671
970
  /**
672
971
  * JWT header extraction result, containing the raw value and the parsed JWT
@@ -685,9 +984,8 @@ declare type OAuth2ProxyResult<JWTPayload> = {
685
984
  accessToken: string;
686
985
  };
687
986
  /**
688
- * Options for the oauth2-proxy provider factory
689
- *
690
987
  * @public
988
+ * @deprecated This type has been inlined into the create method and will be removed.
691
989
  */
692
990
  declare type Oauth2ProxyProviderOptions<JWTPayload> = {
693
991
  /**
@@ -705,11 +1003,24 @@ declare type Oauth2ProxyProviderOptions<JWTPayload> = {
705
1003
  };
706
1004
  };
707
1005
  /**
708
- * Factory function for oauth2-proxy auth provider
709
- *
710
1006
  * @public
1007
+ * @deprecated Use `providers.oauth2Proxy.create` instead
711
1008
  */
712
- 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;
713
1024
 
714
1025
  /**
715
1026
  * authentication result for the OIDC which includes the token set and user information (a profile response sent by OIDC server)
@@ -720,26 +1031,30 @@ declare type OidcAuthResult = {
720
1031
  userinfo: UserinfoResponse;
721
1032
  };
722
1033
  /**
723
- * OIDC provider callback options. An auth handler and a sign in resolver
724
- * can be passed while creating a OIDC provider.
725
- *
726
- * authHandler : called after sign in was successful, a new object must be returned which includes a profile
727
- * signInResolver: called after sign in was successful, expects to return a new {@link @backstage/plugin-auth-node#BackstageSignInResult}
728
- *
729
- * Both options are optional. There is fallback for authHandler where the default handler expect an e-mail explicitly
730
- * otherwise it throws an error
731
- *
732
1034
  * @public
1035
+ * @deprecated This type has been inlined into the create method and will be removed.
733
1036
  */
734
1037
  declare type OidcProviderOptions = {
735
1038
  authHandler?: AuthHandler<OidcAuthResult>;
736
1039
  signIn?: {
737
- resolver?: SignInResolver<OidcAuthResult>;
1040
+ resolver: SignInResolver<OidcAuthResult>;
738
1041
  };
739
1042
  };
740
- 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;
741
1053
 
742
- declare const oktaEmailSignInResolver: SignInResolver<OAuthResult>;
1054
+ /**
1055
+ * @public
1056
+ * @deprecated This type has been inlined into the create method and will be removed.
1057
+ */
743
1058
  declare type OktaProviderOptions = {
744
1059
  /**
745
1060
  * The profile transformation function used to verify and convert the auth response
@@ -753,12 +1068,39 @@ declare type OktaProviderOptions = {
753
1068
  /**
754
1069
  * Maps an auth result to a Backstage identity for the user.
755
1070
  */
756
- resolver?: SignInResolver<OAuthResult>;
1071
+ resolver: SignInResolver<OAuthResult>;
757
1072
  };
758
1073
  };
759
- 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>;
760
1099
 
761
- /** @public */
1100
+ /**
1101
+ * @public
1102
+ * @deprecated This type has been inlined into the create method and will be removed.
1103
+ */
762
1104
  declare type OneLoginProviderOptions = {
763
1105
  /**
764
1106
  * The profile transformation function used to verify and convert the auth response
@@ -775,14 +1117,35 @@ declare type OneLoginProviderOptions = {
775
1117
  resolver: SignInResolver<OAuthResult>;
776
1118
  };
777
1119
  };
778
- /** @public */
779
- 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;
780
1140
 
781
1141
  /** @public */
782
1142
  declare type SamlAuthResult = {
783
1143
  fullProfile: any;
784
1144
  };
785
- /** @public */
1145
+ /**
1146
+ * @public
1147
+ * @deprecated This type has been inlined into the create method and will be removed.
1148
+ */
786
1149
  declare type SamlProviderOptions = {
787
1150
  /**
788
1151
  * The profile transformation function used to verify and convert the auth response
@@ -796,11 +1159,34 @@ declare type SamlProviderOptions = {
796
1159
  /**
797
1160
  * Maps an auth result to a Backstage identity for the user.
798
1161
  */
799
- resolver?: SignInResolver<SamlAuthResult>;
1162
+ resolver: SignInResolver<SamlAuthResult>;
800
1163
  };
801
1164
  };
802
- /** @public */
803
- 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>;
804
1190
 
805
1191
  /**
806
1192
  * The data extracted from an IAP token.
@@ -834,9 +1220,8 @@ declare type GcpIapResult = {
834
1220
  iapToken: GcpIapTokenInfo;
835
1221
  };
836
1222
  /**
837
- * Options for {@link createGcpIapProvider}.
838
- *
839
1223
  * @public
1224
+ * @deprecated This type has been inlined into the create method and will be removed.
840
1225
  */
841
1226
  declare type GcpIapProviderOptions = {
842
1227
  /**
@@ -858,11 +1243,185 @@ declare type GcpIapProviderOptions = {
858
1243
  };
859
1244
 
860
1245
  /**
861
- * 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.
862
1270
  *
863
1271
  * @public
864
1272
  */
865
- 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
+ }>;
866
1425
 
867
1426
  declare const factories: {
868
1427
  [providerId: string]: AuthProviderFactory;
@@ -906,4 +1465,14 @@ declare type WebMessageResponse = {
906
1465
  declare const postMessageResponse: (res: express.Response, appOrigin: string, response: WebMessageResponse) => void;
907
1466
  declare const ensuresXRequestedWith: (req: express.Request) => boolean;
908
1467
 
909
- 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 };