@backstage/plugin-auth-backend 0.0.0-nightly-202201921950 → 0.0.0-nightly-202203121954
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 +53 -5
- package/dist/index.cjs.js +80 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +38 -35
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-202203121954
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- cef64b1561: **BREAKING** Added `tokenManager` as a required property for the auth-backend `createRouter` function. This dependency is used to issue server tokens that are used by the `CatalogIdentityClient` when looking up users and their group membership during authentication.
|
|
8
|
+
|
|
9
|
+
These changes are **required** to `packages/backend/src/plugins/auth.ts`:
|
|
10
|
+
|
|
11
|
+
```diff
|
|
12
|
+
export default async function createPlugin({
|
|
13
|
+
logger,
|
|
14
|
+
database,
|
|
15
|
+
config,
|
|
16
|
+
discovery,
|
|
17
|
+
+ tokenManager,
|
|
18
|
+
}: PluginEnvironment): Promise<Router> {
|
|
19
|
+
return await createRouter({
|
|
20
|
+
logger,
|
|
21
|
+
config,
|
|
22
|
+
database,
|
|
23
|
+
discovery,
|
|
24
|
+
+ tokenManager,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**BREAKING** The `CatalogIdentityClient` constructor now expects a `TokenManager` instead of a `TokenIssuer`. The `TokenManager` interface is used to generate a server token when [resolving a user's identity and membership through the catalog](https://backstage.io/docs/auth/identity-resolver). Using server tokens for these requests allows the auth-backend to bypass authorization checks when permissions are enabled for Backstage. This change will break apps that rely on the user tokens that were previously used by the client. Refer to the ["Backend-to-backend Authentication" tutorial](https://backstage.io/docs/tutorials/backend-to-backend-auth) for more information on server token usage.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 28a5f9d0b1: chore(deps): bump `passport` from 0.4.1 to 0.5.2
|
|
34
|
+
|
|
35
|
+
## 0.8.0
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- 67349916ac: The `sub` claim in Backstage tokens generated by the default Google and OIDC sign-in resolvers are now full entity references of the format `<kind>:<namespace>/<name>`.
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- 033493a8af: Running the `auth-backend` on multiple domains, perhaps different domains depending on the `auth.environment`, was previously not possible as the `domain` name of the cookie was taken from `backend.baseUrl`. This prevented any cookies to be set in the start of the auth flow as the domain of the cookie would not match the domain of the callbackUrl configured in the OAuth app. This change checks if a provider supports custom `callbackUrl`'s to be configured in the application configuration and uses the domain from that, allowing the `domain`'s to match and the cookie to be set.
|
|
44
|
+
- Updated dependencies
|
|
45
|
+
- @backstage/backend-common@0.10.5
|
|
46
|
+
|
|
47
|
+
## 0.7.0
|
|
4
48
|
|
|
5
49
|
### Minor Changes
|
|
6
50
|
|
|
@@ -9,13 +53,17 @@
|
|
|
9
53
|
**BREAKING** The `AuthHandler` requires now an `AuthResolverContext` parameter. This aligns with the
|
|
10
54
|
behavior of the `SignInResolver`.
|
|
11
55
|
|
|
56
|
+
- f8496730ab: Switched the handling of the `BackstageIdentityResponse` so that the returned `identity.userEntityRef` is always a full entity reference. If `userEntityRef` was previously set to `jane`, it will now be `user:default/jane`. The `userEntityRef` in the response is parsed from the `sub` claim in the payload of the Backstage token.
|
|
57
|
+
- a53d7d8143: Update provider subs to return full entity ref.
|
|
58
|
+
|
|
12
59
|
### Patch Changes
|
|
13
60
|
|
|
61
|
+
- f815b7e4a4: build(deps): bump `@google-cloud/firestore` from 4.15.1 to 5.0.2
|
|
14
62
|
- Updated dependencies
|
|
15
|
-
- @backstage/backend-common@0.
|
|
16
|
-
- @backstage/config@0.
|
|
17
|
-
- @backstage/catalog-model@0.
|
|
18
|
-
- @backstage/catalog-client@0.
|
|
63
|
+
- @backstage/backend-common@0.10.4
|
|
64
|
+
- @backstage/config@0.1.13
|
|
65
|
+
- @backstage/catalog-model@0.9.10
|
|
66
|
+
- @backstage/catalog-client@0.5.5
|
|
19
67
|
|
|
20
68
|
## 0.7.0-next.0
|
|
21
69
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -149,6 +149,16 @@ const verifyNonce = (req, providerId) => {
|
|
|
149
149
|
throw new Error("Invalid nonce");
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
|
+
const getCookieConfig = (authUrl, providerId) => {
|
|
153
|
+
const { hostname: cookieDomain, pathname, protocol } = authUrl;
|
|
154
|
+
const secure = protocol === "https:";
|
|
155
|
+
const cookiePath = pathname.endsWith(`${providerId}/handler/frame`) ? pathname.slice(0, -"/handler/frame".length) : `${pathname}/${providerId}`;
|
|
156
|
+
return {
|
|
157
|
+
cookieDomain,
|
|
158
|
+
cookiePath,
|
|
159
|
+
secure
|
|
160
|
+
};
|
|
161
|
+
};
|
|
152
162
|
|
|
153
163
|
class OAuthEnvironmentHandler {
|
|
154
164
|
constructor(handlers) {
|
|
@@ -245,6 +255,10 @@ function parseJwtPayload(token) {
|
|
|
245
255
|
}
|
|
246
256
|
function prepareBackstageIdentityResponse(result) {
|
|
247
257
|
const { sub, ent } = parseJwtPayload(result.token);
|
|
258
|
+
const userEntityRef = catalogModel.stringifyEntityRef(catalogModel.parseEntityRef(sub, {
|
|
259
|
+
defaultKind: "user",
|
|
260
|
+
defaultNamespace: catalogModel.ENTITY_DEFAULT_NAMESPACE
|
|
261
|
+
}));
|
|
248
262
|
return {
|
|
249
263
|
...{
|
|
250
264
|
idToken: result.token,
|
|
@@ -252,7 +266,7 @@ function prepareBackstageIdentityResponse(result) {
|
|
|
252
266
|
},
|
|
253
267
|
identity: {
|
|
254
268
|
type: "user",
|
|
255
|
-
userEntityRef
|
|
269
|
+
userEntityRef,
|
|
256
270
|
ownershipEntityRefs: ent != null ? ent : []
|
|
257
271
|
}
|
|
258
272
|
};
|
|
@@ -309,14 +323,14 @@ class OAuthAdapter {
|
|
|
309
323
|
};
|
|
310
324
|
}
|
|
311
325
|
static fromConfig(config, handlers, options) {
|
|
326
|
+
var _a;
|
|
312
327
|
const { origin: appOrigin } = new url.URL(config.appUrl);
|
|
313
|
-
const
|
|
314
|
-
const
|
|
315
|
-
const cookiePath = `${url$1.pathname}/${options.providerId}`;
|
|
328
|
+
const authUrl = new url.URL((_a = options.callbackUrl) != null ? _a : config.baseUrl);
|
|
329
|
+
const { cookieDomain, cookiePath, secure } = getCookieConfig(authUrl, options.providerId);
|
|
316
330
|
return new OAuthAdapter(handlers, {
|
|
317
331
|
...options,
|
|
318
332
|
appOrigin,
|
|
319
|
-
cookieDomain
|
|
333
|
+
cookieDomain,
|
|
320
334
|
cookiePath,
|
|
321
335
|
secure,
|
|
322
336
|
isOriginAllowed: config.isOriginAllowed
|
|
@@ -546,7 +560,7 @@ const executeFetchUserProfileStrategy = async (providerStrategy, accessToken) =>
|
|
|
546
560
|
class CatalogIdentityClient {
|
|
547
561
|
constructor(options) {
|
|
548
562
|
this.catalogApi = options.catalogApi;
|
|
549
|
-
this.
|
|
563
|
+
this.tokenManager = options.tokenManager;
|
|
550
564
|
}
|
|
551
565
|
async findUser(query) {
|
|
552
566
|
const filter = {
|
|
@@ -555,9 +569,7 @@ class CatalogIdentityClient {
|
|
|
555
569
|
for (const [key, value] of Object.entries(query.annotations)) {
|
|
556
570
|
filter[`metadata.annotations.${key}`] = value;
|
|
557
571
|
}
|
|
558
|
-
const token = await this.
|
|
559
|
-
claims: { sub: "backstage.io/auth-backend" }
|
|
560
|
-
});
|
|
572
|
+
const { token } = await this.tokenManager.getToken();
|
|
561
573
|
const { items } = await this.catalogApi.getEntities({ filter }, { token });
|
|
562
574
|
if (items.length !== 1) {
|
|
563
575
|
if (items.length > 1) {
|
|
@@ -587,7 +599,8 @@ class CatalogIdentityClient {
|
|
|
587
599
|
"metadata.namespace": ref.namespace,
|
|
588
600
|
"metadata.name": ref.name
|
|
589
601
|
}));
|
|
590
|
-
const
|
|
602
|
+
const { token } = await this.tokenManager.getToken();
|
|
603
|
+
const entities = await this.catalogApi.getEntities({ filter }, { token }).then((r) => r.items);
|
|
591
604
|
if (entityRefs.length !== entities.length) {
|
|
592
605
|
const foundEntityNames = entities.map(catalogModel.stringifyEntityRef);
|
|
593
606
|
const missingEntityNames = resolvedEntityRefs.map(catalogModel.stringifyEntityRef).filter((s) => !foundEntityNames.includes(s));
|
|
@@ -697,6 +710,7 @@ const createAtlassianProvider = (options) => {
|
|
|
697
710
|
globalConfig,
|
|
698
711
|
config,
|
|
699
712
|
tokenIssuer,
|
|
713
|
+
tokenManager,
|
|
700
714
|
catalogApi,
|
|
701
715
|
logger
|
|
702
716
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -707,7 +721,7 @@ const createAtlassianProvider = (options) => {
|
|
|
707
721
|
const callbackUrl = `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
708
722
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
709
723
|
catalogApi,
|
|
710
|
-
|
|
724
|
+
tokenManager
|
|
711
725
|
});
|
|
712
726
|
const authHandler = (_a = options == null ? void 0 : options.authHandler) != null ? _a : atlassianDefaultAuthHandler;
|
|
713
727
|
const provider = new AtlassianAuthProvider({
|
|
@@ -832,6 +846,7 @@ const createAuth0Provider = (options) => {
|
|
|
832
846
|
globalConfig,
|
|
833
847
|
config,
|
|
834
848
|
tokenIssuer,
|
|
849
|
+
tokenManager,
|
|
835
850
|
catalogApi,
|
|
836
851
|
logger
|
|
837
852
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -842,7 +857,7 @@ const createAuth0Provider = (options) => {
|
|
|
842
857
|
const callbackUrl = `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
843
858
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
844
859
|
catalogApi,
|
|
845
|
-
|
|
860
|
+
tokenManager
|
|
846
861
|
});
|
|
847
862
|
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile, params }) => ({
|
|
848
863
|
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
@@ -970,7 +985,7 @@ class AwsAlbAuthProvider {
|
|
|
970
985
|
}
|
|
971
986
|
}
|
|
972
987
|
const createAwsAlbProvider = (options) => {
|
|
973
|
-
return ({ config, tokenIssuer, catalogApi, logger }) => {
|
|
988
|
+
return ({ config, tokenIssuer, catalogApi, logger, tokenManager }) => {
|
|
974
989
|
const region = config.getString("region");
|
|
975
990
|
const issuer = config.getOptionalString("iss");
|
|
976
991
|
if ((options == null ? void 0 : options.signIn.resolver) === void 0) {
|
|
@@ -978,7 +993,7 @@ const createAwsAlbProvider = (options) => {
|
|
|
978
993
|
}
|
|
979
994
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
980
995
|
catalogApi,
|
|
981
|
-
|
|
996
|
+
tokenManager
|
|
982
997
|
});
|
|
983
998
|
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile }) => ({
|
|
984
999
|
profile: makeProfileInfo(fullProfile)
|
|
@@ -1106,6 +1121,7 @@ const createBitbucketProvider = (options) => {
|
|
|
1106
1121
|
globalConfig,
|
|
1107
1122
|
config,
|
|
1108
1123
|
tokenIssuer,
|
|
1124
|
+
tokenManager,
|
|
1109
1125
|
catalogApi,
|
|
1110
1126
|
logger
|
|
1111
1127
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -1115,7 +1131,7 @@ const createBitbucketProvider = (options) => {
|
|
|
1115
1131
|
const callbackUrl = `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
1116
1132
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
1117
1133
|
catalogApi,
|
|
1118
|
-
|
|
1134
|
+
tokenManager
|
|
1119
1135
|
});
|
|
1120
1136
|
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile, params }) => ({
|
|
1121
1137
|
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
@@ -1211,7 +1227,10 @@ const githubDefaultSignInResolver = async (info, ctx) => {
|
|
|
1211
1227
|
const { fullProfile } = info.result;
|
|
1212
1228
|
const userId = fullProfile.username || fullProfile.id;
|
|
1213
1229
|
const token = await ctx.tokenIssuer.issueToken({
|
|
1214
|
-
claims: {
|
|
1230
|
+
claims: {
|
|
1231
|
+
sub: `user:default/${userId}`,
|
|
1232
|
+
ent: [`user:default/${userId}`]
|
|
1233
|
+
}
|
|
1215
1234
|
});
|
|
1216
1235
|
return { id: userId, token };
|
|
1217
1236
|
};
|
|
@@ -1221,6 +1240,7 @@ const createGithubProvider = (options) => {
|
|
|
1221
1240
|
globalConfig,
|
|
1222
1241
|
config,
|
|
1223
1242
|
tokenIssuer,
|
|
1243
|
+
tokenManager,
|
|
1224
1244
|
catalogApi,
|
|
1225
1245
|
logger
|
|
1226
1246
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -1235,7 +1255,7 @@ const createGithubProvider = (options) => {
|
|
|
1235
1255
|
const callbackUrl = customCallbackUrl || `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
1236
1256
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
1237
1257
|
catalogApi,
|
|
1238
|
-
|
|
1258
|
+
tokenManager
|
|
1239
1259
|
});
|
|
1240
1260
|
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile }) => ({
|
|
1241
1261
|
profile: makeProfileInfo(fullProfile)
|
|
@@ -1266,7 +1286,8 @@ const createGithubProvider = (options) => {
|
|
|
1266
1286
|
return OAuthAdapter.fromConfig(globalConfig, provider, {
|
|
1267
1287
|
persistScopes: true,
|
|
1268
1288
|
providerId,
|
|
1269
|
-
tokenIssuer
|
|
1289
|
+
tokenIssuer,
|
|
1290
|
+
callbackUrl
|
|
1270
1291
|
});
|
|
1271
1292
|
});
|
|
1272
1293
|
};
|
|
@@ -1278,7 +1299,7 @@ const gitlabDefaultSignInResolver = async (info, ctx) => {
|
|
|
1278
1299
|
id = profile.email.split("@")[0];
|
|
1279
1300
|
}
|
|
1280
1301
|
const token = await ctx.tokenIssuer.issueToken({
|
|
1281
|
-
claims: { sub: id
|
|
1302
|
+
claims: { sub: `user:default/${id}`, ent: [`user:default/${id}`] }
|
|
1282
1303
|
});
|
|
1283
1304
|
return { id, token };
|
|
1284
1305
|
};
|
|
@@ -1362,6 +1383,7 @@ const createGitlabProvider = (options) => {
|
|
|
1362
1383
|
globalConfig,
|
|
1363
1384
|
config,
|
|
1364
1385
|
tokenIssuer,
|
|
1386
|
+
tokenManager,
|
|
1365
1387
|
catalogApi,
|
|
1366
1388
|
logger
|
|
1367
1389
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -1373,7 +1395,7 @@ const createGitlabProvider = (options) => {
|
|
|
1373
1395
|
const callbackUrl = `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
1374
1396
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
1375
1397
|
catalogApi,
|
|
1376
|
-
|
|
1398
|
+
tokenManager
|
|
1377
1399
|
});
|
|
1378
1400
|
const authHandler = (_a = options == null ? void 0 : options.authHandler) != null ? _a : gitlabDefaultAuthHandler;
|
|
1379
1401
|
const signInResolverFn = (_c = (_b = options == null ? void 0 : options.signIn) == null ? void 0 : _b.resolver) != null ? _c : gitlabDefaultSignInResolver;
|
|
@@ -1508,7 +1530,7 @@ const googleDefaultSignInResolver = async (info, ctx) => {
|
|
|
1508
1530
|
userId = profile.email.split("@")[0];
|
|
1509
1531
|
}
|
|
1510
1532
|
const token = await ctx.tokenIssuer.issueToken({
|
|
1511
|
-
claims: { sub: userId
|
|
1533
|
+
claims: { sub: `user:default/${userId}`, ent: [`user:default/${userId}`] }
|
|
1512
1534
|
});
|
|
1513
1535
|
return { id: userId, token };
|
|
1514
1536
|
};
|
|
@@ -1518,6 +1540,7 @@ const createGoogleProvider = (options) => {
|
|
|
1518
1540
|
globalConfig,
|
|
1519
1541
|
config,
|
|
1520
1542
|
tokenIssuer,
|
|
1543
|
+
tokenManager,
|
|
1521
1544
|
catalogApi,
|
|
1522
1545
|
logger
|
|
1523
1546
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -1527,7 +1550,7 @@ const createGoogleProvider = (options) => {
|
|
|
1527
1550
|
const callbackUrl = `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
1528
1551
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
1529
1552
|
catalogApi,
|
|
1530
|
-
|
|
1553
|
+
tokenManager
|
|
1531
1554
|
});
|
|
1532
1555
|
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile, params }) => ({
|
|
1533
1556
|
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
@@ -1662,7 +1685,10 @@ const microsoftDefaultSignInResolver = async (info, ctx) => {
|
|
|
1662
1685
|
}
|
|
1663
1686
|
const userId = profile.email.split("@")[0];
|
|
1664
1687
|
const token = await ctx.tokenIssuer.issueToken({
|
|
1665
|
-
claims: {
|
|
1688
|
+
claims: {
|
|
1689
|
+
sub: `user:default/${userId}`,
|
|
1690
|
+
ent: [`user:default/${userId}`]
|
|
1691
|
+
}
|
|
1666
1692
|
});
|
|
1667
1693
|
return { id: userId, token };
|
|
1668
1694
|
};
|
|
@@ -1672,6 +1698,7 @@ const createMicrosoftProvider = (options) => {
|
|
|
1672
1698
|
globalConfig,
|
|
1673
1699
|
config,
|
|
1674
1700
|
tokenIssuer,
|
|
1701
|
+
tokenManager,
|
|
1675
1702
|
catalogApi,
|
|
1676
1703
|
logger
|
|
1677
1704
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -1684,7 +1711,7 @@ const createMicrosoftProvider = (options) => {
|
|
|
1684
1711
|
const tokenUrl = `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`;
|
|
1685
1712
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
1686
1713
|
catalogApi,
|
|
1687
|
-
|
|
1714
|
+
tokenManager
|
|
1688
1715
|
});
|
|
1689
1716
|
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile, params }) => ({
|
|
1690
1717
|
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
@@ -1807,7 +1834,7 @@ const oAuth2DefaultSignInResolver$1 = async (info, ctx) => {
|
|
|
1807
1834
|
}
|
|
1808
1835
|
const userId = profile.email.split("@")[0];
|
|
1809
1836
|
const token = await ctx.tokenIssuer.issueToken({
|
|
1810
|
-
claims: { sub: userId
|
|
1837
|
+
claims: { sub: `user:default/${userId}`, ent: [`user:default/${userId}`] }
|
|
1811
1838
|
});
|
|
1812
1839
|
return { id: userId, token };
|
|
1813
1840
|
};
|
|
@@ -1817,6 +1844,7 @@ const createOAuth2Provider = (options) => {
|
|
|
1817
1844
|
globalConfig,
|
|
1818
1845
|
config,
|
|
1819
1846
|
tokenIssuer,
|
|
1847
|
+
tokenManager,
|
|
1820
1848
|
catalogApi,
|
|
1821
1849
|
logger
|
|
1822
1850
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -1831,7 +1859,7 @@ const createOAuth2Provider = (options) => {
|
|
|
1831
1859
|
const disableRefresh = (_a = envConfig.getOptionalBoolean("disableRefresh")) != null ? _a : false;
|
|
1832
1860
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
1833
1861
|
catalogApi,
|
|
1834
|
-
|
|
1862
|
+
tokenManager
|
|
1835
1863
|
});
|
|
1836
1864
|
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile, params }) => ({
|
|
1837
1865
|
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
@@ -2262,12 +2290,12 @@ class Oauth2ProxyAuthProvider {
|
|
|
2262
2290
|
};
|
|
2263
2291
|
}
|
|
2264
2292
|
}
|
|
2265
|
-
const createOauth2ProxyProvider = (options) => ({ catalogApi, logger, tokenIssuer }) => {
|
|
2293
|
+
const createOauth2ProxyProvider = (options) => ({ catalogApi, logger, tokenIssuer, tokenManager }) => {
|
|
2266
2294
|
const signInResolver = options.signIn.resolver;
|
|
2267
2295
|
const authHandler = options.authHandler;
|
|
2268
2296
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
2269
2297
|
catalogApi,
|
|
2270
|
-
|
|
2298
|
+
tokenManager
|
|
2271
2299
|
});
|
|
2272
2300
|
return new Oauth2ProxyAuthProvider({
|
|
2273
2301
|
logger,
|
|
@@ -2378,7 +2406,10 @@ const oAuth2DefaultSignInResolver = async (info, ctx) => {
|
|
|
2378
2406
|
}
|
|
2379
2407
|
const userId = profile.email.split("@")[0];
|
|
2380
2408
|
const token = await ctx.tokenIssuer.issueToken({
|
|
2381
|
-
claims: {
|
|
2409
|
+
claims: {
|
|
2410
|
+
sub: `user:default/${userId}`,
|
|
2411
|
+
ent: [`user:default/${userId}`]
|
|
2412
|
+
}
|
|
2382
2413
|
});
|
|
2383
2414
|
return { id: userId, token };
|
|
2384
2415
|
};
|
|
@@ -2388,6 +2419,7 @@ const createOidcProvider = (options) => {
|
|
|
2388
2419
|
globalConfig,
|
|
2389
2420
|
config,
|
|
2390
2421
|
tokenIssuer,
|
|
2422
|
+
tokenManager,
|
|
2391
2423
|
catalogApi,
|
|
2392
2424
|
logger
|
|
2393
2425
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -2401,7 +2433,7 @@ const createOidcProvider = (options) => {
|
|
|
2401
2433
|
const prompt = envConfig.getOptionalString("prompt");
|
|
2402
2434
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
2403
2435
|
catalogApi,
|
|
2404
|
-
|
|
2436
|
+
tokenManager
|
|
2405
2437
|
});
|
|
2406
2438
|
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ userinfo }) => ({
|
|
2407
2439
|
profile: {
|
|
@@ -2545,7 +2577,7 @@ const oktaDefaultSignInResolver = async (info, ctx) => {
|
|
|
2545
2577
|
}
|
|
2546
2578
|
const userId = profile.email.split("@")[0];
|
|
2547
2579
|
const token = await ctx.tokenIssuer.issueToken({
|
|
2548
|
-
claims: { sub: userId
|
|
2580
|
+
claims: { sub: `user:default/${userId}`, ent: [`user:default/${userId}`] }
|
|
2549
2581
|
});
|
|
2550
2582
|
return { id: userId, token };
|
|
2551
2583
|
};
|
|
@@ -2555,6 +2587,7 @@ const createOktaProvider = (_options) => {
|
|
|
2555
2587
|
globalConfig,
|
|
2556
2588
|
config,
|
|
2557
2589
|
tokenIssuer,
|
|
2590
|
+
tokenManager,
|
|
2558
2591
|
catalogApi,
|
|
2559
2592
|
logger
|
|
2560
2593
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -2568,7 +2601,7 @@ const createOktaProvider = (_options) => {
|
|
|
2568
2601
|
}
|
|
2569
2602
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
2570
2603
|
catalogApi,
|
|
2571
|
-
|
|
2604
|
+
tokenManager
|
|
2572
2605
|
});
|
|
2573
2606
|
const authHandler = (_options == null ? void 0 : _options.authHandler) ? _options.authHandler : async ({ fullProfile, params }) => ({
|
|
2574
2607
|
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
@@ -2688,6 +2721,7 @@ const createOneLoginProvider = (options) => {
|
|
|
2688
2721
|
globalConfig,
|
|
2689
2722
|
config,
|
|
2690
2723
|
tokenIssuer,
|
|
2724
|
+
tokenManager,
|
|
2691
2725
|
catalogApi,
|
|
2692
2726
|
logger
|
|
2693
2727
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
@@ -2698,7 +2732,7 @@ const createOneLoginProvider = (options) => {
|
|
|
2698
2732
|
const callbackUrl = `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
2699
2733
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
2700
2734
|
catalogApi,
|
|
2701
|
-
|
|
2735
|
+
tokenManager
|
|
2702
2736
|
});
|
|
2703
2737
|
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile, params }) => ({
|
|
2704
2738
|
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
@@ -2788,13 +2822,14 @@ const createSamlProvider = (options) => {
|
|
|
2788
2822
|
globalConfig,
|
|
2789
2823
|
config,
|
|
2790
2824
|
tokenIssuer,
|
|
2825
|
+
tokenManager,
|
|
2791
2826
|
catalogApi,
|
|
2792
2827
|
logger
|
|
2793
2828
|
}) => {
|
|
2794
2829
|
var _a, _b;
|
|
2795
2830
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
2796
2831
|
catalogApi,
|
|
2797
|
-
|
|
2832
|
+
tokenManager
|
|
2798
2833
|
});
|
|
2799
2834
|
const authHandler = (options == null ? void 0 : options.authHandler) ? options.authHandler : async ({ fullProfile }) => ({
|
|
2800
2835
|
profile: {
|
|
@@ -2902,7 +2937,7 @@ class GcpIapProvider {
|
|
|
2902
2937
|
}
|
|
2903
2938
|
}
|
|
2904
2939
|
function createGcpIapProvider(options) {
|
|
2905
|
-
return ({ config, tokenIssuer, catalogApi, logger }) => {
|
|
2940
|
+
return ({ config, tokenIssuer, catalogApi, logger, tokenManager }) => {
|
|
2906
2941
|
var _a;
|
|
2907
2942
|
const audience = config.getString("audience");
|
|
2908
2943
|
const authHandler = (_a = options.authHandler) != null ? _a : defaultAuthHandler;
|
|
@@ -2910,7 +2945,7 @@ function createGcpIapProvider(options) {
|
|
|
2910
2945
|
const tokenValidator = createTokenValidator(audience);
|
|
2911
2946
|
const catalogIdentityClient = new CatalogIdentityClient({
|
|
2912
2947
|
catalogApi,
|
|
2913
|
-
|
|
2948
|
+
tokenManager
|
|
2914
2949
|
});
|
|
2915
2950
|
return new GcpIapProvider({
|
|
2916
2951
|
authHandler,
|
|
@@ -2940,7 +2975,14 @@ const factories = {
|
|
|
2940
2975
|
};
|
|
2941
2976
|
|
|
2942
2977
|
async function createRouter(options) {
|
|
2943
|
-
const {
|
|
2978
|
+
const {
|
|
2979
|
+
logger,
|
|
2980
|
+
config,
|
|
2981
|
+
discovery,
|
|
2982
|
+
database,
|
|
2983
|
+
tokenManager,
|
|
2984
|
+
providerFactories
|
|
2985
|
+
} = options;
|
|
2944
2986
|
const router = Router__default["default"]();
|
|
2945
2987
|
const appUrl = config.getString("app.baseUrl");
|
|
2946
2988
|
const authUrl = await discovery.getExternalBaseUrl("auth");
|
|
@@ -2986,6 +3028,7 @@ async function createRouter(options) {
|
|
|
2986
3028
|
globalConfig: { baseUrl: authUrl, appUrl, isOriginAllowed },
|
|
2987
3029
|
config: providersConfig.getConfig(providerId),
|
|
2988
3030
|
logger,
|
|
3031
|
+
tokenManager,
|
|
2989
3032
|
tokenIssuer,
|
|
2990
3033
|
discovery,
|
|
2991
3034
|
catalogApi
|