@backstage/plugin-auth-backend 0.6.0 → 0.6.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 CHANGED
@@ -8,6 +8,7 @@ import { UserEntity, Entity } from '@backstage/catalog-model';
8
8
  import { Profile } from 'passport';
9
9
  import { JSONWebKey } from 'jose';
10
10
  import { TokenSet, UserinfoResponse } from 'openid-client';
11
+ import { JsonValue } from '@backstage/types';
11
12
 
12
13
  /** Represents any form of serializable JWK */
13
14
  interface AnyJWK extends Record<string, string> {
@@ -381,12 +382,15 @@ interface BackstageSignInResult {
381
382
  }
382
383
  /**
383
384
  * The old exported symbol for {@link BackstageSignInResult}.
385
+ *
384
386
  * @public
385
- * @deprecated Use the `BackstageSignInResult` type instead.
387
+ * @deprecated Use the {@link BackstageSignInResult} instead.
386
388
  */
387
389
  declare type BackstageIdentity = BackstageSignInResult;
388
390
  /**
389
- * Response object containing the {@link BackstageUserIdentity} and the token from the authentication provider.
391
+ * Response object containing the {@link BackstageUserIdentity} and the token
392
+ * from the authentication provider.
393
+ *
390
394
  * @public
391
395
  */
392
396
  interface BackstageIdentityResponse extends BackstageSignInResult {
@@ -399,7 +403,8 @@ interface BackstageIdentityResponse extends BackstageSignInResult {
399
403
  * Used to display login information to user, i.e. sidebar popup.
400
404
  *
401
405
  * It is also temporarily used as the profile of the signed-in user's Backstage
402
- * identity, but we want to replace that with data from identity and/org catalog service
406
+ * identity, but we want to replace that with data from identity and/org catalog
407
+ * service
403
408
  *
404
409
  * @public
405
410
  */
@@ -419,47 +424,56 @@ declare type ProfileInfo = {
419
424
  picture?: string;
420
425
  };
421
426
  /**
422
- * type of sign in information context, includes the profile information and authentication result which contains auth. related information
427
+ * Type of sign in information context. Includes the profile information and
428
+ * authentication result which contains auth related information.
429
+ *
423
430
  * @public
424
431
  */
425
- declare type SignInInfo<AuthResult> = {
432
+ declare type SignInInfo<TAuthResult> = {
426
433
  /**
427
434
  * The simple profile passed down for use in the frontend.
428
435
  */
429
436
  profile: ProfileInfo;
430
437
  /**
431
- * The authentication result that was received from the authentication provider.
438
+ * The authentication result that was received from the authentication
439
+ * provider.
432
440
  */
433
- result: AuthResult;
441
+ result: TAuthResult;
434
442
  };
435
443
  /**
436
- * Sign in resolver type describes the function which handles the result of a successful authentication
437
- * and it must return a valid {@link BackstageSignInResult}
444
+ * Describes the function which handles the result of a successful
445
+ * authentication. Must return a valid {@link BackstageSignInResult}.
446
+ *
438
447
  * @public
439
448
  */
440
- declare type SignInResolver<AuthResult> = (info: SignInInfo<AuthResult>, context: {
449
+ declare type SignInResolver<TAuthResult> = (info: SignInInfo<TAuthResult>, context: {
441
450
  tokenIssuer: TokenIssuer;
442
451
  catalogIdentityClient: CatalogIdentityClient;
443
452
  logger: Logger;
444
453
  }) => Promise<BackstageSignInResult>;
445
454
  /**
446
- * The return type of authentication handler which must contain a valid profile information
455
+ * The return type of an authentication handler. Must contain valid profile
456
+ * information.
457
+ *
447
458
  * @public
448
459
  */
449
460
  declare type AuthHandlerResult = {
450
461
  profile: ProfileInfo;
451
462
  };
452
463
  /**
453
- * The AuthHandler function is called every time the user authenticates using the provider.
464
+ * The AuthHandler function is called every time the user authenticates using
465
+ * the provider.
454
466
  *
455
- * The handler should return a profile that represents the session for the user in the frontend.
467
+ * The handler should return a profile that represents the session for the user
468
+ * in the frontend.
456
469
  *
457
- * Throwing an error in the function will cause the authentication to fail, making it
458
- * possible to use this function as a way to limit access to a certain group of users.
470
+ * Throwing an error in the function will cause the authentication to fail,
471
+ * making it possible to use this function as a way to limit access to a certain
472
+ * group of users.
459
473
  *
460
474
  * @public
461
475
  */
462
- declare type AuthHandler<AuthResult> = (input: AuthResult) => Promise<AuthHandlerResult>;
476
+ declare type AuthHandler<TAuthResult> = (input: TAuthResult) => Promise<AuthHandlerResult>;
463
477
  declare type StateEncoder = (req: OAuthStartRequest) => Promise<{
464
478
  encodedState: string;
465
479
  }>;
@@ -843,12 +857,76 @@ declare type SamlProviderOptions = {
843
857
  /** @public */
844
858
  declare const createSamlProvider: (options?: SamlProviderOptions | undefined) => AuthProviderFactory;
845
859
 
860
+ /**
861
+ * The data extracted from an IAP token.
862
+ *
863
+ * @public
864
+ */
865
+ declare type GcpIapTokenInfo = {
866
+ /**
867
+ * The unique, stable identifier for the user.
868
+ */
869
+ sub: string;
870
+ /**
871
+ * User email address.
872
+ */
873
+ email: string;
874
+ /**
875
+ * Other fields.
876
+ */
877
+ [key: string]: JsonValue;
878
+ };
879
+ /**
880
+ * The result of the initial auth challenge. This is the input to the auth
881
+ * callbacks.
882
+ *
883
+ * @public
884
+ */
885
+ declare type GcpIapResult = {
886
+ /**
887
+ * The data extracted from the IAP token header.
888
+ */
889
+ iapToken: GcpIapTokenInfo;
890
+ };
891
+ /**
892
+ * Options for {@link createGcpIapProvider}.
893
+ *
894
+ * @public
895
+ */
896
+ declare type GcpIapProviderOptions = {
897
+ /**
898
+ * The profile transformation function used to verify and convert the auth
899
+ * response into the profile that will be presented to the user. The default
900
+ * implementation just provides the authenticated email that the IAP
901
+ * presented.
902
+ */
903
+ authHandler?: AuthHandler<GcpIapResult>;
904
+ /**
905
+ * Configures sign-in for this provider.
906
+ */
907
+ signIn: {
908
+ /**
909
+ * Maps an auth result to a Backstage identity for the user.
910
+ */
911
+ resolver: SignInResolver<GcpIapResult>;
912
+ };
913
+ };
914
+
915
+ /**
916
+ * Creates an auth provider for Google Identity-Aware Proxy.
917
+ *
918
+ * @public
919
+ */
920
+ declare function createGcpIapProvider(options: GcpIapProviderOptions): AuthProviderFactory;
921
+
846
922
  declare const factories: {
847
923
  [providerId: string]: AuthProviderFactory;
848
924
  };
849
925
 
850
926
  /**
851
- * Parses token and decorates the BackstageIdentityResponse with identity information sourced from the token
927
+ * Parses a Backstage-issued token and decorates the
928
+ * {@link BackstageIdentityResponse} with identity information sourced from the
929
+ * token.
852
930
  *
853
931
  * @public
854
932
  */
@@ -882,4 +960,4 @@ declare type WebMessageResponse = {
882
960
  declare const postMessageResponse: (res: express.Response, appOrigin: string, response: WebMessageResponse) => void;
883
961
  declare const ensuresXRequestedWith: (req: express.Request) => boolean;
884
962
 
885
- export { AtlassianAuthProvider, AtlassianProviderOptions, Auth0ProviderOptions, AuthHandler, AuthHandlerResult, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResponse, AwsAlbProviderOptions, BackstageIdentity, BackstageIdentityResponse, BackstageSignInResult, BackstageUserIdentity, BitbucketOAuthResult, BitbucketPassportProfile, BitbucketProviderOptions, CatalogIdentityClient, GithubOAuthResult, GithubProviderOptions, GitlabProviderOptions, GoogleProviderOptions, IdentityClient, MicrosoftProviderOptions, OAuth2ProviderOptions, OAuthAdapter, OAuthEnvironmentHandler, OAuthHandlers, OAuthProviderInfo, OAuthProviderOptions, OAuthRefreshRequest, OAuthResponse, OAuthResult, OAuthStartRequest, OAuthState, OidcAuthResult, OidcProviderOptions, OktaProviderOptions, OneLoginProviderOptions, ProfileInfo, RouterOptions, SamlAuthResult, SamlProviderOptions, SignInInfo, SignInResolver, TokenIssuer, WebMessageResponse, bitbucketUserIdSignInResolver, bitbucketUsernameSignInResolver, createAtlassianProvider, createAuth0Provider, createAwsAlbProvider, createBitbucketProvider, createGithubProvider, createGitlabProvider, createGoogleProvider, createMicrosoftProvider, createOAuth2Provider, createOidcProvider, createOktaProvider, createOneLoginProvider, createOriginFilter, createRouter, createSamlProvider, factories as defaultAuthProviderFactories, encodeState, ensuresXRequestedWith, getEntityClaims, googleEmailSignInResolver, microsoftEmailSignInResolver, oktaEmailSignInResolver, postMessageResponse, prepareBackstageIdentityResponse, readState, verifyNonce };
963
+ export { AtlassianAuthProvider, AtlassianProviderOptions, Auth0ProviderOptions, AuthHandler, AuthHandlerResult, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResponse, AwsAlbProviderOptions, BackstageIdentity, BackstageIdentityResponse, BackstageSignInResult, BackstageUserIdentity, BitbucketOAuthResult, BitbucketPassportProfile, BitbucketProviderOptions, CatalogIdentityClient, GcpIapProviderOptions, GcpIapResult, GcpIapTokenInfo, GithubOAuthResult, GithubProviderOptions, GitlabProviderOptions, GoogleProviderOptions, IdentityClient, MicrosoftProviderOptions, OAuth2ProviderOptions, OAuthAdapter, OAuthEnvironmentHandler, OAuthHandlers, OAuthProviderInfo, OAuthProviderOptions, OAuthRefreshRequest, OAuthResponse, OAuthResult, OAuthStartRequest, OAuthState, OidcAuthResult, OidcProviderOptions, OktaProviderOptions, OneLoginProviderOptions, ProfileInfo, RouterOptions, SamlAuthResult, SamlProviderOptions, SignInInfo, SignInResolver, TokenIssuer, WebMessageResponse, bitbucketUserIdSignInResolver, bitbucketUsernameSignInResolver, createAtlassianProvider, createAuth0Provider, createAwsAlbProvider, createBitbucketProvider, createGcpIapProvider, createGithubProvider, createGitlabProvider, createGoogleProvider, createMicrosoftProvider, createOAuth2Provider, createOidcProvider, createOktaProvider, createOneLoginProvider, createOriginFilter, createRouter, createSamlProvider, factories as defaultAuthProviderFactories, encodeState, ensuresXRequestedWith, getEntityClaims, googleEmailSignInResolver, microsoftEmailSignInResolver, oktaEmailSignInResolver, postMessageResponse, prepareBackstageIdentityResponse, readState, verifyNonce };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-auth-backend",
3
3
  "description": "A Backstage backend plugin that handles authentication",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -30,12 +30,13 @@
30
30
  "clean": "backstage-cli clean"
31
31
  },
32
32
  "dependencies": {
33
- "@backstage/backend-common": "^0.10.1",
33
+ "@backstage/backend-common": "^0.10.2",
34
34
  "@backstage/catalog-client": "^0.5.3",
35
35
  "@backstage/catalog-model": "^0.9.8",
36
36
  "@backstage/config": "^0.1.11",
37
37
  "@backstage/errors": "^0.1.5",
38
38
  "@backstage/test-utils": "^0.2.1",
39
+ "@backstage/types": "^0.1.1",
39
40
  "@google-cloud/firestore": "^4.15.1",
40
41
  "@types/express": "^4.17.6",
41
42
  "@types/passport": "^1.0.3",
@@ -46,6 +47,7 @@
46
47
  "express-promise-router": "^4.1.0",
47
48
  "express-session": "^1.17.1",
48
49
  "fs-extra": "9.1.0",
50
+ "google-auth-library": "^7.6.1",
49
51
  "helmet": "^4.0.0",
50
52
  "jose": "^1.27.1",
51
53
  "jwt-decode": "^3.1.0",
@@ -72,7 +74,7 @@
72
74
  "yn": "^4.0.0"
73
75
  },
74
76
  "devDependencies": {
75
- "@backstage/cli": "^0.10.4",
77
+ "@backstage/cli": "^0.10.5",
76
78
  "@types/body-parser": "^1.19.0",
77
79
  "@types/cookie-parser": "^1.4.2",
78
80
  "@types/express-session": "^1.17.2",
@@ -83,7 +85,8 @@
83
85
  "@types/passport-saml": "^1.1.3",
84
86
  "@types/passport-strategy": "^0.2.35",
85
87
  "@types/xml2js": "^0.4.7",
86
- "msw": "^0.35.0"
88
+ "msw": "^0.35.0",
89
+ "supertest": "^6.1.3"
87
90
  },
88
91
  "files": [
89
92
  "dist",
@@ -91,5 +94,5 @@
91
94
  "config.d.ts"
92
95
  ],
93
96
  "configSchema": "config.d.ts",
94
- "gitHead": "4b2a8ed96ff427735c872a72c1864321ef698436"
97
+ "gitHead": "ffdb98aa2973366d48ff1774a7f892bc0c926e7e"
95
98
  }