@backstage/plugin-auth-backend 0.0.0-nightly-2021102922210 → 0.0.0-nightly-202111922557
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/CHANGELOG.md +26 -2
- package/dist/index.cjs.js +438 -327
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +119 -20
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { UserEntity, Entity } from '@backstage/catalog-model';
|
|
|
7
7
|
import { Config } from '@backstage/config';
|
|
8
8
|
import { Profile } from 'passport';
|
|
9
9
|
import { JSONWebKey } from 'jose';
|
|
10
|
+
import { TokenSet, UserinfoResponse } from 'openid-client';
|
|
10
11
|
|
|
11
12
|
/** Represents any form of serializable JWK */
|
|
12
13
|
interface AnyJWK extends Record<string, string> {
|
|
@@ -69,7 +70,16 @@ declare type OAuthResult = {
|
|
|
69
70
|
accessToken: string;
|
|
70
71
|
refreshToken?: string;
|
|
71
72
|
};
|
|
72
|
-
|
|
73
|
+
/**
|
|
74
|
+
* The expected response from an OAuth flow.
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
declare type OAuthResponse = {
|
|
79
|
+
profile: ProfileInfo;
|
|
80
|
+
providerInfo: OAuthProviderInfo;
|
|
81
|
+
backstageIdentity?: BackstageSignInResult;
|
|
82
|
+
};
|
|
73
83
|
declare type OAuthProviderInfo = {
|
|
74
84
|
/**
|
|
75
85
|
* An access token issued for the signed in user.
|
|
@@ -122,7 +132,7 @@ interface OAuthHandlers {
|
|
|
122
132
|
* @param {express.Request} req
|
|
123
133
|
*/
|
|
124
134
|
handler(req: express.Request): Promise<{
|
|
125
|
-
response:
|
|
135
|
+
response: OAuthResponse;
|
|
126
136
|
refreshToken?: string;
|
|
127
137
|
}>;
|
|
128
138
|
/**
|
|
@@ -130,7 +140,7 @@ interface OAuthHandlers {
|
|
|
130
140
|
* @param {string} refreshToken
|
|
131
141
|
* @param {string} scope
|
|
132
142
|
*/
|
|
133
|
-
refresh?(req: OAuthRefreshRequest): Promise<
|
|
143
|
+
refresh?(req: OAuthRefreshRequest): Promise<OAuthResponse>;
|
|
134
144
|
/**
|
|
135
145
|
* (Optional) Sign out of the auth provider.
|
|
136
146
|
*/
|
|
@@ -157,7 +167,7 @@ declare class IdentityClient {
|
|
|
157
167
|
* Returns a BackstageIdentity (user) matching the token.
|
|
158
168
|
* The method throws an error if verification fails.
|
|
159
169
|
*/
|
|
160
|
-
authenticate(token: string | undefined): Promise<
|
|
170
|
+
authenticate(token: string | undefined): Promise<BackstageIdentityResponse>;
|
|
161
171
|
/**
|
|
162
172
|
* Parses the given authorization header and returns
|
|
163
173
|
* the bearer token, or null if no bearer token is given
|
|
@@ -210,7 +220,7 @@ declare class CatalogIdentityClient {
|
|
|
210
220
|
*
|
|
211
221
|
* Returns a superset of the entity names that can be passed directly to `issueToken` as `ent`.
|
|
212
222
|
*/
|
|
213
|
-
resolveCatalogMembership(
|
|
223
|
+
resolveCatalogMembership(query: MemberClaimQuery): Promise<string[]>;
|
|
214
224
|
}
|
|
215
225
|
|
|
216
226
|
declare function getEntityClaims(entity: UserEntity): TokenParams['claims'];
|
|
@@ -316,37 +326,83 @@ declare type AuthProviderFactory = (options: AuthProviderFactoryOptions) => Auth
|
|
|
316
326
|
declare type AuthResponse<ProviderInfo> = {
|
|
317
327
|
providerInfo: ProviderInfo;
|
|
318
328
|
profile: ProfileInfo;
|
|
319
|
-
backstageIdentity?:
|
|
329
|
+
backstageIdentity?: BackstageIdentityResponse;
|
|
320
330
|
};
|
|
321
|
-
|
|
331
|
+
/**
|
|
332
|
+
* User identity information within Backstage.
|
|
333
|
+
*
|
|
334
|
+
* @public
|
|
335
|
+
*/
|
|
336
|
+
declare type BackstageUserIdentity = {
|
|
322
337
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* This is typically the same as the user entity `metadata.name`.
|
|
338
|
+
* The type of identity that this structure represents. In the frontend app
|
|
339
|
+
* this will currently always be 'user'.
|
|
326
340
|
*/
|
|
327
|
-
|
|
341
|
+
type: 'user';
|
|
328
342
|
/**
|
|
329
|
-
*
|
|
330
|
-
*
|
|
343
|
+
* The entityRef of the user in the catalog.
|
|
344
|
+
* For example User:default/sandra
|
|
331
345
|
*/
|
|
332
|
-
|
|
346
|
+
userEntityRef: string;
|
|
333
347
|
/**
|
|
334
|
-
* The
|
|
348
|
+
* The user and group entities that the user claims ownership through
|
|
335
349
|
*/
|
|
336
|
-
|
|
350
|
+
ownershipEntityRefs: string[];
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* A representation of a successful Backstage sign-in.
|
|
354
|
+
*
|
|
355
|
+
* Compared to the {@link BackstageIdentityResponse} this type omits
|
|
356
|
+
* the decoded identity information embedded in the token.
|
|
357
|
+
*
|
|
358
|
+
* @public
|
|
359
|
+
*/
|
|
360
|
+
interface BackstageSignInResult {
|
|
361
|
+
/**
|
|
362
|
+
* An opaque ID that uniquely identifies the user within Backstage.
|
|
363
|
+
*
|
|
364
|
+
* This is typically the same as the user entity `metadata.name`.
|
|
365
|
+
*
|
|
366
|
+
* @deprecated Use the `identity` field instead
|
|
367
|
+
*/
|
|
368
|
+
id: string;
|
|
337
369
|
/**
|
|
338
370
|
* The entity that the user is represented by within Backstage.
|
|
339
371
|
*
|
|
340
372
|
* This entity may or may not exist within the Catalog, and it can be used
|
|
341
373
|
* to read and store additional metadata about the user.
|
|
374
|
+
*
|
|
375
|
+
* @deprecated Use the `identity` field instead.
|
|
342
376
|
*/
|
|
343
377
|
entity?: Entity;
|
|
344
|
-
|
|
378
|
+
/**
|
|
379
|
+
* The token used to authenticate the user within Backstage.
|
|
380
|
+
*/
|
|
381
|
+
token: string;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* The old exported symbol for {@link BackstageSignInResult}.
|
|
385
|
+
* @public
|
|
386
|
+
* @deprecated Use the `BackstageSignInResult` type instead.
|
|
387
|
+
*/
|
|
388
|
+
declare type BackstageIdentity = BackstageSignInResult;
|
|
389
|
+
/**
|
|
390
|
+
* Response object containing the {@link BackstageUserIdentity} and the token from the authentication provider.
|
|
391
|
+
* @public
|
|
392
|
+
*/
|
|
393
|
+
interface BackstageIdentityResponse extends BackstageSignInResult {
|
|
394
|
+
/**
|
|
395
|
+
* A plaintext description of the identity that is encapsulated within the token.
|
|
396
|
+
*/
|
|
397
|
+
identity: BackstageUserIdentity;
|
|
398
|
+
}
|
|
345
399
|
/**
|
|
346
400
|
* Used to display login information to user, i.e. sidebar popup.
|
|
347
401
|
*
|
|
348
402
|
* It is also temporarily used as the profile of the signed-in user's Backstage
|
|
349
403
|
* identity, but we want to replace that with data from identity and/org catalog service
|
|
404
|
+
*
|
|
405
|
+
* @public
|
|
350
406
|
*/
|
|
351
407
|
declare type ProfileInfo = {
|
|
352
408
|
/**
|
|
@@ -377,7 +433,7 @@ declare type SignInResolver<AuthResult> = (info: SignInInfo<AuthResult>, context
|
|
|
377
433
|
tokenIssuer: TokenIssuer;
|
|
378
434
|
catalogIdentityClient: CatalogIdentityClient;
|
|
379
435
|
logger: Logger;
|
|
380
|
-
}) => Promise<
|
|
436
|
+
}) => Promise<BackstageSignInResult>;
|
|
381
437
|
declare type AuthHandlerResult = {
|
|
382
438
|
profile: ProfileInfo;
|
|
383
439
|
};
|
|
@@ -554,6 +610,18 @@ declare type OAuth2ProviderOptions = {
|
|
|
554
610
|
};
|
|
555
611
|
declare const createOAuth2Provider: (options?: OAuth2ProviderOptions | undefined) => AuthProviderFactory;
|
|
556
612
|
|
|
613
|
+
declare type AuthResult = {
|
|
614
|
+
tokenset: TokenSet;
|
|
615
|
+
userinfo: UserinfoResponse;
|
|
616
|
+
};
|
|
617
|
+
declare type OidcProviderOptions = {
|
|
618
|
+
authHandler?: AuthHandler<AuthResult>;
|
|
619
|
+
signIn?: {
|
|
620
|
+
resolver?: SignInResolver<AuthResult>;
|
|
621
|
+
};
|
|
622
|
+
};
|
|
623
|
+
declare const createOidcProvider: (options?: OidcProviderOptions | undefined) => AuthProviderFactory;
|
|
624
|
+
|
|
557
625
|
declare const oktaEmailSignInResolver: SignInResolver<OAuthResult>;
|
|
558
626
|
declare type OktaProviderOptions = {
|
|
559
627
|
/**
|
|
@@ -678,10 +746,41 @@ declare type AwsAlbProviderOptions = {
|
|
|
678
746
|
};
|
|
679
747
|
declare const createAwsAlbProvider: (options?: AwsAlbProviderOptions | undefined) => AuthProviderFactory;
|
|
680
748
|
|
|
749
|
+
/** @public */
|
|
750
|
+
declare type SamlAuthResult = {
|
|
751
|
+
fullProfile: any;
|
|
752
|
+
};
|
|
753
|
+
/** @public */
|
|
754
|
+
declare type SamlProviderOptions = {
|
|
755
|
+
/**
|
|
756
|
+
* The profile transformation function used to verify and convert the auth response
|
|
757
|
+
* into the profile that will be presented to the user.
|
|
758
|
+
*/
|
|
759
|
+
authHandler?: AuthHandler<SamlAuthResult>;
|
|
760
|
+
/**
|
|
761
|
+
* Configure sign-in for this provider, without it the provider can not be used to sign users in.
|
|
762
|
+
*/
|
|
763
|
+
signIn?: {
|
|
764
|
+
/**
|
|
765
|
+
* Maps an auth result to a Backstage identity for the user.
|
|
766
|
+
*/
|
|
767
|
+
resolver?: SignInResolver<SamlAuthResult>;
|
|
768
|
+
};
|
|
769
|
+
};
|
|
770
|
+
/** @public */
|
|
771
|
+
declare const createSamlProvider: (options?: SamlProviderOptions | undefined) => AuthProviderFactory;
|
|
772
|
+
|
|
681
773
|
declare const factories: {
|
|
682
774
|
[providerId: string]: AuthProviderFactory;
|
|
683
775
|
};
|
|
684
776
|
|
|
777
|
+
/**
|
|
778
|
+
* Parses token and decorates the BackstageIdentityResponse with identity information sourced from the token
|
|
779
|
+
*
|
|
780
|
+
* @public
|
|
781
|
+
*/
|
|
782
|
+
declare function prepareBackstageIdentityResponse(result: BackstageSignInResult): BackstageIdentityResponse;
|
|
783
|
+
|
|
685
784
|
declare type ProviderFactories = {
|
|
686
785
|
[s: string]: AuthProviderFactory;
|
|
687
786
|
};
|
|
@@ -692,7 +791,7 @@ interface RouterOptions {
|
|
|
692
791
|
discovery: PluginEndpointDiscovery;
|
|
693
792
|
providerFactories?: ProviderFactories;
|
|
694
793
|
}
|
|
695
|
-
declare function createRouter(
|
|
794
|
+
declare function createRouter(options: RouterOptions): Promise<express.Router>;
|
|
696
795
|
declare function createOriginFilter(config: Config): (origin: string) => boolean;
|
|
697
796
|
|
|
698
797
|
/**
|
|
@@ -710,4 +809,4 @@ declare type WebMessageResponse = {
|
|
|
710
809
|
declare const postMessageResponse: (res: express.Response, appOrigin: string, response: WebMessageResponse) => void;
|
|
711
810
|
declare const ensuresXRequestedWith: (req: express.Request) => boolean;
|
|
712
811
|
|
|
713
|
-
export { AtlassianAuthProvider, AtlassianProviderOptions, AuthProviderFactory, AuthProviderFactoryOptions, AuthProviderRouteHandlers, AuthResponse, AwsAlbProviderOptions, BackstageIdentity, BitbucketOAuthResult, BitbucketPassportProfile, BitbucketProviderOptions, CatalogIdentityClient, GithubOAuthResult, GithubProviderOptions, GitlabProviderOptions, GoogleProviderOptions, IdentityClient, MicrosoftProviderOptions, OAuth2ProviderOptions, OAuthAdapter, OAuthEnvironmentHandler, OAuthHandlers, OAuthProviderInfo, OAuthProviderOptions, OAuthRefreshRequest, OAuthResponse, OAuthResult, OAuthStartRequest, OAuthState, OktaProviderOptions, ProfileInfo, RouterOptions, TokenIssuer, WebMessageResponse, bitbucketUserIdSignInResolver, bitbucketUsernameSignInResolver, createAtlassianProvider, createAwsAlbProvider, createBitbucketProvider, createGithubProvider, createGitlabProvider, createGoogleProvider, createMicrosoftProvider, createOAuth2Provider, createOktaProvider, createOriginFilter, createRouter, factories as defaultAuthProviderFactories, encodeState, ensuresXRequestedWith, getEntityClaims, googleEmailSignInResolver, microsoftEmailSignInResolver, oktaEmailSignInResolver, postMessageResponse, readState, verifyNonce };
|
|
812
|
+
export { AtlassianAuthProvider, AtlassianProviderOptions, 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, OktaProviderOptions, ProfileInfo, RouterOptions, SamlAuthResult, SamlProviderOptions, TokenIssuer, WebMessageResponse, bitbucketUserIdSignInResolver, bitbucketUsernameSignInResolver, createAtlassianProvider, createAwsAlbProvider, createBitbucketProvider, createGithubProvider, createGitlabProvider, createGoogleProvider, createMicrosoftProvider, createOAuth2Provider, createOidcProvider, createOktaProvider, 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.0.0-nightly-
|
|
4
|
+
"version": "0.0.0-nightly-202111922557",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"clean": "backstage-cli clean"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@backstage/backend-common": "^0.0.0-nightly-
|
|
33
|
+
"@backstage/backend-common": "^0.0.0-nightly-202111922557",
|
|
34
34
|
"@backstage/catalog-client": "^0.5.2",
|
|
35
35
|
"@backstage/catalog-model": "^0.9.7",
|
|
36
36
|
"@backstage/config": "^0.1.11",
|
|
37
37
|
"@backstage/errors": "^0.1.5",
|
|
38
|
-
"@backstage/test-utils": "^0.
|
|
38
|
+
"@backstage/test-utils": "^0.0.0-nightly-202111922557",
|
|
39
39
|
"@google-cloud/firestore": "^4.15.1",
|
|
40
40
|
"@types/express": "^4.17.6",
|
|
41
41
|
"@types/passport": "^1.0.3",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"yn": "^4.0.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@backstage/cli": "^0.0.0-nightly-
|
|
76
|
+
"@backstage/cli": "^0.0.0-nightly-202111922557",
|
|
77
77
|
"@types/body-parser": "^1.19.0",
|
|
78
78
|
"@types/cookie-parser": "^1.4.2",
|
|
79
79
|
"@types/express-session": "^1.17.2",
|