@backstage/plugin-auth-backend 0.6.2 → 0.9.0-next.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
@@ -2,7 +2,7 @@
2
2
  import express from 'express';
3
3
  import { Logger } from 'winston';
4
4
  import { Config } from '@backstage/config';
5
- import { PluginEndpointDiscovery, PluginDatabaseManager } from '@backstage/backend-common';
5
+ import { TokenManager, PluginEndpointDiscovery, PluginDatabaseManager } from '@backstage/backend-common';
6
6
  import { CatalogApi } from '@backstage/catalog-client';
7
7
  import { UserEntity, Entity } from '@backstage/catalog-model';
8
8
  import { Profile } from 'passport';
@@ -144,6 +144,39 @@ interface OAuthHandlers {
144
144
  logout?(): Promise<void>;
145
145
  }
146
146
 
147
+ declare type UserQuery = {
148
+ annotations: Record<string, string>;
149
+ };
150
+ declare type MemberClaimQuery = {
151
+ entityRefs: string[];
152
+ logger?: Logger;
153
+ };
154
+ /**
155
+ * A catalog client tailored for reading out identity data from the catalog.
156
+ */
157
+ declare class CatalogIdentityClient {
158
+ private readonly catalogApi;
159
+ private readonly tokenManager;
160
+ constructor(options: {
161
+ catalogApi: CatalogApi;
162
+ tokenManager: TokenManager;
163
+ });
164
+ /**
165
+ * Looks up a single user using a query.
166
+ *
167
+ * Throws a NotFoundError or ConflictError if 0 or multiple users are found.
168
+ */
169
+ findUser(query: UserQuery): Promise<UserEntity>;
170
+ /**
171
+ * Resolve additional entity claims from the catalog, using the passed-in entity names. Designed
172
+ * to be used within a `signInResolver` where additional entity claims might be provided, but
173
+ * group membership and transient group membership lean on imported catalog relations.
174
+ *
175
+ * Returns a superset of the entity names that can be passed directly to `issueToken` as `ent`.
176
+ */
177
+ resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]>;
178
+ }
179
+
147
180
  /**
148
181
  * A identity client to interact with auth-backend
149
182
  * and authenticate backstage identity tokens
@@ -187,41 +220,18 @@ declare class IdentityClient {
187
220
  private refreshKeyStore;
188
221
  }
189
222
 
190
- declare type UserQuery = {
191
- annotations: Record<string, string>;
192
- };
193
- declare type MemberClaimQuery = {
194
- entityRefs: string[];
195
- logger?: Logger;
196
- };
197
- /**
198
- * A catalog client tailored for reading out identity data from the catalog.
199
- */
200
- declare class CatalogIdentityClient {
201
- private readonly catalogApi;
202
- private readonly tokenIssuer;
203
- constructor(options: {
204
- catalogApi: CatalogApi;
205
- tokenIssuer: TokenIssuer;
206
- });
207
- /**
208
- * Looks up a single user using a query.
209
- *
210
- * Throws a NotFoundError or ConflictError if 0 or multiple users are found.
211
- */
212
- findUser(query: UserQuery): Promise<UserEntity>;
213
- /**
214
- * Resolve additional entity claims from the catalog, using the passed-in entity names. Designed
215
- * to be used within a `signInResolver` where additional entity claims might be provided, but
216
- * group membership and transient group membership lean on imported catalog relations.
217
- *
218
- * Returns a superset of the entity names that can be passed directly to `issueToken` as `ent`.
219
- */
220
- resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]>;
221
- }
222
-
223
223
  declare function getEntityClaims(entity: UserEntity): TokenParams['claims'];
224
224
 
225
+ /**
226
+ * The context that is used for auth processing.
227
+ *
228
+ * @public
229
+ */
230
+ declare type AuthResolverContext = {
231
+ tokenIssuer: TokenIssuer;
232
+ catalogIdentityClient: CatalogIdentityClient;
233
+ logger: Logger;
234
+ };
225
235
  declare type AuthProviderConfig = {
226
236
  /**
227
237
  * The protocol://domain[:port] where the app is hosted. This is used to construct the
@@ -303,6 +313,7 @@ declare type AuthProviderFactoryOptions = {
303
313
  globalConfig: AuthProviderConfig;
304
314
  config: Config;
305
315
  logger: Logger;
316
+ tokenManager: TokenManager;
306
317
  tokenIssuer: TokenIssuer;
307
318
  discovery: PluginEndpointDiscovery;
308
319
  catalogApi: CatalogApi;
@@ -431,11 +442,7 @@ declare type SignInInfo<TAuthResult> = {
431
442
  *
432
443
  * @public
433
444
  */
434
- declare type SignInResolver<TAuthResult> = (info: SignInInfo<TAuthResult>, context: {
435
- tokenIssuer: TokenIssuer;
436
- catalogIdentityClient: CatalogIdentityClient;
437
- logger: Logger;
438
- }) => Promise<BackstageSignInResult>;
445
+ declare type SignInResolver<TAuthResult> = (info: SignInInfo<TAuthResult>, context: AuthResolverContext) => Promise<BackstageSignInResult>;
439
446
  /**
440
447
  * The return type of an authentication handler. Must contain valid profile
441
448
  * information.
@@ -458,7 +465,7 @@ declare type AuthHandlerResult = {
458
465
  *
459
466
  * @public
460
467
  */
461
- declare type AuthHandler<TAuthResult> = (input: TAuthResult) => Promise<AuthHandlerResult>;
468
+ declare type AuthHandler<TAuthResult> = (input: TAuthResult, context: AuthResolverContext) => Promise<AuthHandlerResult>;
462
469
  declare type StateEncoder = (req: OAuthStartRequest) => Promise<{
463
470
  encodedState: string;
464
471
  }>;
@@ -485,11 +492,12 @@ declare type Options = {
485
492
  appOrigin: string;
486
493
  tokenIssuer: TokenIssuer;
487
494
  isOriginAllowed: (origin: string) => boolean;
495
+ callbackUrl?: string;
488
496
  };
489
497
  declare class OAuthAdapter implements AuthProviderRouteHandlers {
490
498
  private readonly handlers;
491
499
  private readonly options;
492
- static fromConfig(config: AuthProviderConfig, handlers: OAuthHandlers, options: Pick<Options, 'providerId' | 'persistScopes' | 'disableRefresh' | 'tokenIssuer'>): OAuthAdapter;
500
+ static fromConfig(config: AuthProviderConfig, handlers: OAuthHandlers, options: Pick<Options, 'providerId' | 'persistScopes' | 'disableRefresh' | 'tokenIssuer' | 'callbackUrl'>): OAuthAdapter;
493
501
  constructor(handlers: OAuthHandlers, options: Options);
494
502
  start(req: express.Request, res: express.Response): Promise<void>;
495
503
  frameHandler(req: express.Request, res: express.Response): Promise<void>;
@@ -751,6 +759,49 @@ declare type OAuth2ProviderOptions = {
751
759
  };
752
760
  declare const createOAuth2Provider: (options?: OAuth2ProviderOptions | undefined) => AuthProviderFactory;
753
761
 
762
+ /**
763
+ * JWT header extraction result, containing the raw value and the parsed JWT
764
+ * payload.
765
+ *
766
+ * @public
767
+ */
768
+ declare type OAuth2ProxyResult<JWTPayload> = {
769
+ /**
770
+ * Parsed and decoded JWT payload.
771
+ */
772
+ fullProfile: JWTPayload;
773
+ /**
774
+ * Raw JWT token
775
+ */
776
+ accessToken: string;
777
+ };
778
+ /**
779
+ * Options for the oauth2-proxy provider factory
780
+ *
781
+ * @public
782
+ */
783
+ declare type Oauth2ProxyProviderOptions<JWTPayload> = {
784
+ /**
785
+ * Configure an auth handler to generate a profile for the user.
786
+ */
787
+ authHandler: AuthHandler<OAuth2ProxyResult<JWTPayload>>;
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<OAuth2ProxyResult<JWTPayload>>;
796
+ };
797
+ };
798
+ /**
799
+ * Factory function for oauth2-proxy auth provider
800
+ *
801
+ * @public
802
+ */
803
+ declare const createOauth2ProxyProvider: <JWTPayload>(options: Oauth2ProxyProviderOptions<JWTPayload>) => AuthProviderFactory;
804
+
754
805
  /**
755
806
  * authentication result for the OIDC which includes the token set and user information (a profile response sent by OIDC server)
756
807
  * @public
@@ -925,6 +976,7 @@ interface RouterOptions {
925
976
  database: PluginDatabaseManager;
926
977
  config: Config;
927
978
  discovery: PluginEndpointDiscovery;
979
+ tokenManager: TokenManager;
928
980
  providerFactories?: ProviderFactories;
929
981
  }
930
982
  declare function createRouter(options: RouterOptions): Promise<express.Router>;
@@ -945,4 +997,4 @@ declare type WebMessageResponse = {
945
997
  declare const postMessageResponse: (res: express.Response, appOrigin: string, response: WebMessageResponse) => void;
946
998
  declare const ensuresXRequestedWith: (req: express.Request) => boolean;
947
999
 
948
- export { AtlassianAuthProvider, AtlassianProviderOptions, Auth0ProviderOptions, AuthHandler, AuthHandlerResult, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResponse, AwsAlbProviderOptions, BackstageIdentity, BackstageIdentityResponse, BackstageSignInResult, BackstageUserIdentity, BitbucketOAuthResult, BitbucketPassportProfile, BitbucketProviderOptions, CatalogIdentityClient, GcpIapProviderOptions, GcpIapResult, GcpIapTokenInfo, GithubOAuthResult, GithubProviderOptions, GitlabProviderOptions, GoogleProviderOptions, IdentityClient, MicrosoftProviderOptions, OAuth2ProviderOptions, OAuthAdapter, OAuthEnvironmentHandler, OAuthHandlers, OAuthProviderInfo, OAuthProviderOptions, OAuthRefreshRequest, OAuthResponse, OAuthResult, OAuthStartRequest, OAuthState, OidcAuthResult, OidcProviderOptions, OktaProviderOptions, OneLoginProviderOptions, ProfileInfo, RouterOptions, SamlAuthResult, SamlProviderOptions, SignInInfo, SignInResolver, TokenIssuer, WebMessageResponse, bitbucketUserIdSignInResolver, bitbucketUsernameSignInResolver, createAtlassianProvider, createAuth0Provider, createAwsAlbProvider, createBitbucketProvider, createGcpIapProvider, createGithubProvider, createGitlabProvider, createGoogleProvider, createMicrosoftProvider, createOAuth2Provider, createOidcProvider, createOktaProvider, createOneLoginProvider, createOriginFilter, createRouter, createSamlProvider, factories as defaultAuthProviderFactories, encodeState, ensuresXRequestedWith, getEntityClaims, googleEmailSignInResolver, microsoftEmailSignInResolver, oktaEmailSignInResolver, postMessageResponse, prepareBackstageIdentityResponse, readState, verifyNonce };
1000
+ export { AtlassianAuthProvider, AtlassianProviderOptions, Auth0ProviderOptions, AuthHandler, AuthHandlerResult, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResolverContext, AuthResponse, AwsAlbProviderOptions, BackstageIdentity, BackstageIdentityResponse, BackstageSignInResult, BackstageUserIdentity, BitbucketOAuthResult, BitbucketPassportProfile, BitbucketProviderOptions, CatalogIdentityClient, GcpIapProviderOptions, GcpIapResult, GcpIapTokenInfo, GithubOAuthResult, GithubProviderOptions, GitlabProviderOptions, GoogleProviderOptions, IdentityClient, MicrosoftProviderOptions, OAuth2ProviderOptions, OAuth2ProxyResult, OAuthAdapter, OAuthEnvironmentHandler, OAuthHandlers, OAuthProviderInfo, OAuthProviderOptions, OAuthRefreshRequest, OAuthResponse, OAuthResult, OAuthStartRequest, OAuthState, Oauth2ProxyProviderOptions, OidcAuthResult, OidcProviderOptions, OktaProviderOptions, OneLoginProviderOptions, ProfileInfo, RouterOptions, SamlAuthResult, SamlProviderOptions, SignInInfo, SignInResolver, TokenIssuer, WebMessageResponse, bitbucketUserIdSignInResolver, bitbucketUsernameSignInResolver, createAtlassianProvider, createAuth0Provider, createAwsAlbProvider, createBitbucketProvider, createGcpIapProvider, createGithubProvider, createGitlabProvider, createGoogleProvider, createMicrosoftProvider, createOAuth2Provider, createOauth2ProxyProvider, createOidcProvider, createOktaProvider, createOneLoginProvider, createOriginFilter, createRouter, createSamlProvider, factories as defaultAuthProviderFactories, encodeState, ensuresXRequestedWith, getEntityClaims, googleEmailSignInResolver, microsoftEmailSignInResolver, oktaEmailSignInResolver, postMessageResponse, prepareBackstageIdentityResponse, readState, verifyNonce };
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.2",
4
+ "version": "0.9.0-next.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -30,13 +30,13 @@
30
30
  "clean": "backstage-cli clean"
31
31
  },
32
32
  "dependencies": {
33
- "@backstage/backend-common": "^0.10.3",
34
- "@backstage/catalog-client": "^0.5.4",
35
- "@backstage/catalog-model": "^0.9.9",
36
- "@backstage/config": "^0.1.12",
33
+ "@backstage/backend-common": "^0.10.5",
34
+ "@backstage/catalog-client": "^0.5.5",
35
+ "@backstage/catalog-model": "^0.9.10",
36
+ "@backstage/config": "^0.1.13",
37
37
  "@backstage/errors": "^0.2.0",
38
38
  "@backstage/types": "^0.1.1",
39
- "@google-cloud/firestore": "^4.15.1",
39
+ "@google-cloud/firestore": "^5.0.2",
40
40
  "@types/express": "^4.17.6",
41
41
  "@types/passport": "^1.0.3",
42
42
  "compression": "^1.7.4",
@@ -58,7 +58,7 @@
58
58
  "node-cache": "^5.1.2",
59
59
  "node-fetch": "^2.6.1",
60
60
  "openid-client": "^4.2.1",
61
- "passport": "^0.4.1",
61
+ "passport": "^0.5.2",
62
62
  "passport-bitbucket-oauth2": "^0.1.2",
63
63
  "passport-github2": "^0.1.12",
64
64
  "passport-gitlab2": "^5.0.0",
@@ -73,8 +73,8 @@
73
73
  "yn": "^4.0.0"
74
74
  },
75
75
  "devDependencies": {
76
- "@backstage/cli": "^0.11.0",
77
- "@backstage/test-utils": "^0.2.2",
76
+ "@backstage/cli": "^0.13.1-next.0",
77
+ "@backstage/test-utils": "^0.2.3",
78
78
  "@types/body-parser": "^1.19.0",
79
79
  "@types/cookie-parser": "^1.4.2",
80
80
  "@types/express-session": "^1.17.2",
@@ -94,5 +94,5 @@
94
94
  "config.d.ts"
95
95
  ],
96
96
  "configSchema": "config.d.ts",
97
- "gitHead": "da66c61bdd63cdb3f0f0cd2e26dc9e6454d93c7b"
97
+ "gitHead": "a28838ac5c80c7332caa6ca0569d2ec85151784f"
98
98
  }