@backstage/plugin-auth-backend 0.0.0-nightly-202192122645 → 0.0.0-nightly-2021101322257
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 +35 -6
- package/config.d.ts +27 -0
- package/dist/index.cjs.js +300 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +156 -97
- package/package.json +10 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,47 @@
|
|
|
1
1
|
# @backstage/plugin-auth-backend
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.4.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5ee31f860b: Only use settings that have a value when creating a new FirestoreKeyStore instance
|
|
8
|
+
- 3e0e2f09d5: Added forwarding of the `audience` option for the SAML provider, making it possible to enable `audience` verification.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/backend-common@0.9.9
|
|
11
|
+
- @backstage/test-utils@0.1.21
|
|
12
|
+
- @backstage/catalog-client@0.5.1
|
|
13
|
+
|
|
14
|
+
## 0.4.6
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 3b767f19c9: Allow OAuth state to be encoded by a stateEncoder.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @backstage/test-utils@0.1.20
|
|
21
|
+
- @backstage/config@0.1.11
|
|
22
|
+
- @backstage/errors@0.1.4
|
|
23
|
+
- @backstage/backend-common@0.9.8
|
|
24
|
+
- @backstage/catalog-model@0.9.6
|
|
25
|
+
|
|
26
|
+
## 0.4.5
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
6
29
|
|
|
7
30
|
- 9322e632e9: Require that audience URLs for Okta authentication start with https
|
|
8
31
|
- de3e26aecc: Fix a bug preventing an access token to be refreshed a second time with the GitHub provider.
|
|
32
|
+
- ab9b4a6ea6: Add Firestore as key-store provider.
|
|
33
|
+
Add `auth.keyStore` section to application config.
|
|
34
|
+
- 202f322927: Atlassian auth provider
|
|
35
|
+
|
|
36
|
+
- AtlassianAuth added to core-app-api
|
|
37
|
+
- Atlassian provider added to plugin-auth-backend
|
|
38
|
+
- Updated user-settings with Atlassian connection
|
|
39
|
+
|
|
9
40
|
- 36e67d2f24: Internal updates to apply more strict checks to throw errors.
|
|
10
41
|
- Updated dependencies
|
|
11
|
-
- @backstage/backend-common@0.
|
|
12
|
-
- @backstage/errors@0.
|
|
13
|
-
- @backstage/catalog-model@0.
|
|
14
|
-
- @backstage/catalog-client@0.0.0-nightly-202192122645
|
|
15
|
-
- @backstage/test-utils@0.0.0-nightly-202192122645
|
|
42
|
+
- @backstage/backend-common@0.9.7
|
|
43
|
+
- @backstage/errors@0.1.3
|
|
44
|
+
- @backstage/catalog-model@0.9.5
|
|
16
45
|
|
|
17
46
|
## 0.4.4
|
|
18
47
|
|
package/config.d.ts
CHANGED
|
@@ -31,6 +31,32 @@ export interface Config {
|
|
|
31
31
|
secret?: string;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
/** To control how to store JWK data in auth-backend */
|
|
35
|
+
keyStore?: {
|
|
36
|
+
provider?: 'database' | 'memory' | 'firestore';
|
|
37
|
+
firestore?: {
|
|
38
|
+
/** The host to connect to */
|
|
39
|
+
host?: string;
|
|
40
|
+
/** The port to connect to */
|
|
41
|
+
port?: number;
|
|
42
|
+
/** Whether to use SSL when connecting. */
|
|
43
|
+
ssl?: boolean;
|
|
44
|
+
/** The Google Cloud Project ID */
|
|
45
|
+
projectId?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Local file containing the Service Account credentials.
|
|
48
|
+
* You can omit this value to automatically read from
|
|
49
|
+
* GOOGLE_APPLICATION_CREDENTIALS env which is useful for local
|
|
50
|
+
* development.
|
|
51
|
+
*/
|
|
52
|
+
keyFilename?: string;
|
|
53
|
+
/** The path to use for the collection. Defaults to 'sessions' */
|
|
54
|
+
path?: string;
|
|
55
|
+
/** Timeout used for database operations. Defaults to 10000ms */
|
|
56
|
+
timeout?: number;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
34
60
|
/**
|
|
35
61
|
* The available auth-provider options and attributes
|
|
36
62
|
*/
|
|
@@ -49,6 +75,7 @@ export interface Config {
|
|
|
49
75
|
logoutUrl?: string;
|
|
50
76
|
issuer: string;
|
|
51
77
|
cert: string;
|
|
78
|
+
audience?: string;
|
|
52
79
|
privateKey?: string;
|
|
53
80
|
authnContext?: string[];
|
|
54
81
|
identifierFormat?: string;
|
package/dist/index.cjs.js
CHANGED
|
@@ -29,6 +29,8 @@ var catalogClient = require('@backstage/catalog-client');
|
|
|
29
29
|
var uuid = require('uuid');
|
|
30
30
|
var luxon = require('luxon');
|
|
31
31
|
var backendCommon = require('@backstage/backend-common');
|
|
32
|
+
var firestore = require('@google-cloud/firestore');
|
|
33
|
+
var lodash = require('lodash');
|
|
32
34
|
var session = require('express-session');
|
|
33
35
|
var passport = require('passport');
|
|
34
36
|
var minimatch = require('minimatch');
|
|
@@ -549,6 +551,7 @@ class GithubAuthProvider {
|
|
|
549
551
|
constructor(options) {
|
|
550
552
|
this.signInResolver = options.signInResolver;
|
|
551
553
|
this.authHandler = options.authHandler;
|
|
554
|
+
this.stateEncoder = options.stateEncoder;
|
|
552
555
|
this.tokenIssuer = options.tokenIssuer;
|
|
553
556
|
this.catalogIdentityClient = options.catalogIdentityClient;
|
|
554
557
|
this.logger = options.logger;
|
|
@@ -566,7 +569,7 @@ class GithubAuthProvider {
|
|
|
566
569
|
async start(req) {
|
|
567
570
|
return await executeRedirectStrategy(req, this._strategy, {
|
|
568
571
|
scope: req.scope,
|
|
569
|
-
state:
|
|
572
|
+
state: (await this.stateEncoder(req)).encodedState
|
|
570
573
|
});
|
|
571
574
|
}
|
|
572
575
|
async handler(req) {
|
|
@@ -632,7 +635,7 @@ const createGithubProvider = (options) => {
|
|
|
632
635
|
catalogApi,
|
|
633
636
|
logger
|
|
634
637
|
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
635
|
-
var _a, _b;
|
|
638
|
+
var _a, _b, _c;
|
|
636
639
|
const clientId = envConfig.getString("clientId");
|
|
637
640
|
const clientSecret = envConfig.getString("clientSecret");
|
|
638
641
|
const enterpriseInstanceUrl = envConfig.getOptionalString("enterpriseInstanceUrl");
|
|
@@ -654,6 +657,9 @@ const createGithubProvider = (options) => {
|
|
|
654
657
|
tokenIssuer,
|
|
655
658
|
logger
|
|
656
659
|
});
|
|
660
|
+
const stateEncoder = (_c = options == null ? void 0 : options.stateEncoder) != null ? _c : async (req) => {
|
|
661
|
+
return {encodedState: encodeState(req.state)};
|
|
662
|
+
};
|
|
657
663
|
const provider = new GithubAuthProvider({
|
|
658
664
|
clientId,
|
|
659
665
|
clientSecret,
|
|
@@ -665,6 +671,7 @@ const createGithubProvider = (options) => {
|
|
|
665
671
|
authHandler,
|
|
666
672
|
tokenIssuer,
|
|
667
673
|
catalogIdentityClient,
|
|
674
|
+
stateEncoder,
|
|
668
675
|
logger
|
|
669
676
|
});
|
|
670
677
|
return OAuthAdapter.fromConfig(globalConfig, provider, {
|
|
@@ -1556,6 +1563,177 @@ const createBitbucketProvider = (options) => {
|
|
|
1556
1563
|
});
|
|
1557
1564
|
};
|
|
1558
1565
|
|
|
1566
|
+
const defaultScopes = ["offline_access", "read:me"];
|
|
1567
|
+
class AtlassianStrategy extends OAuth2Strategy__default['default'] {
|
|
1568
|
+
constructor(options, verify) {
|
|
1569
|
+
if (!options.scope) {
|
|
1570
|
+
throw new TypeError("Atlassian requires a scope option");
|
|
1571
|
+
}
|
|
1572
|
+
const scopes = options.scope.split(" ");
|
|
1573
|
+
const optionsWithURLs = {
|
|
1574
|
+
...options,
|
|
1575
|
+
authorizationURL: `https://auth.atlassian.com/authorize`,
|
|
1576
|
+
tokenURL: `https://auth.atlassian.com/oauth/token`,
|
|
1577
|
+
scope: Array.from(new Set([...defaultScopes, ...scopes]))
|
|
1578
|
+
};
|
|
1579
|
+
super(optionsWithURLs, verify);
|
|
1580
|
+
this.profileURL = "https://api.atlassian.com/me";
|
|
1581
|
+
this.name = "atlassian";
|
|
1582
|
+
this._oauth2.useAuthorizationHeaderforGET(true);
|
|
1583
|
+
}
|
|
1584
|
+
authorizationParams() {
|
|
1585
|
+
return {
|
|
1586
|
+
audience: "api.atlassian.com",
|
|
1587
|
+
prompt: "consent"
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
userProfile(accessToken, done) {
|
|
1591
|
+
this._oauth2.get(this.profileURL, accessToken, (err, body) => {
|
|
1592
|
+
if (err) {
|
|
1593
|
+
return done(new OAuth2Strategy.InternalOAuthError("Failed to fetch user profile", err.statusCode));
|
|
1594
|
+
}
|
|
1595
|
+
if (!body) {
|
|
1596
|
+
return done(new Error("Failed to fetch user profile, body cannot be empty"));
|
|
1597
|
+
}
|
|
1598
|
+
try {
|
|
1599
|
+
const json = typeof body !== "string" ? body.toString() : body;
|
|
1600
|
+
const profile = AtlassianStrategy.parse(json);
|
|
1601
|
+
return done(null, profile);
|
|
1602
|
+
} catch (e) {
|
|
1603
|
+
return done(new Error("Failed to parse user profile"));
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
static parse(json) {
|
|
1608
|
+
const resp = JSON.parse(json);
|
|
1609
|
+
return {
|
|
1610
|
+
id: resp.account_id,
|
|
1611
|
+
provider: "atlassian",
|
|
1612
|
+
username: resp.nickname,
|
|
1613
|
+
displayName: resp.name,
|
|
1614
|
+
emails: [{value: resp.email}],
|
|
1615
|
+
photos: [{value: resp.picture}]
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
const atlassianDefaultAuthHandler = async ({
|
|
1621
|
+
fullProfile,
|
|
1622
|
+
params
|
|
1623
|
+
}) => ({
|
|
1624
|
+
profile: makeProfileInfo(fullProfile, params.id_token)
|
|
1625
|
+
});
|
|
1626
|
+
class AtlassianAuthProvider {
|
|
1627
|
+
constructor(options) {
|
|
1628
|
+
this.catalogIdentityClient = options.catalogIdentityClient;
|
|
1629
|
+
this.logger = options.logger;
|
|
1630
|
+
this.tokenIssuer = options.tokenIssuer;
|
|
1631
|
+
this.authHandler = options.authHandler;
|
|
1632
|
+
this.signInResolver = options.signInResolver;
|
|
1633
|
+
this._strategy = new AtlassianStrategy({
|
|
1634
|
+
clientID: options.clientId,
|
|
1635
|
+
clientSecret: options.clientSecret,
|
|
1636
|
+
callbackURL: options.callbackUrl,
|
|
1637
|
+
scope: options.scopes
|
|
1638
|
+
}, (accessToken, refreshToken, params, fullProfile, done) => {
|
|
1639
|
+
done(void 0, {
|
|
1640
|
+
fullProfile,
|
|
1641
|
+
accessToken,
|
|
1642
|
+
refreshToken,
|
|
1643
|
+
params
|
|
1644
|
+
});
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
async start(req) {
|
|
1648
|
+
return await executeRedirectStrategy(req, this._strategy, {
|
|
1649
|
+
state: encodeState(req.state)
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
async handler(req) {
|
|
1653
|
+
var _a;
|
|
1654
|
+
const {result} = await executeFrameHandlerStrategy(req, this._strategy);
|
|
1655
|
+
return {
|
|
1656
|
+
response: await this.handleResult(result),
|
|
1657
|
+
refreshToken: (_a = result.refreshToken) != null ? _a : ""
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1660
|
+
async handleResult(result) {
|
|
1661
|
+
const {profile} = await this.authHandler(result);
|
|
1662
|
+
const response = {
|
|
1663
|
+
providerInfo: {
|
|
1664
|
+
idToken: result.params.id_token,
|
|
1665
|
+
accessToken: result.accessToken,
|
|
1666
|
+
refreshToken: result.refreshToken,
|
|
1667
|
+
scope: result.params.scope,
|
|
1668
|
+
expiresInSeconds: result.params.expires_in
|
|
1669
|
+
},
|
|
1670
|
+
profile
|
|
1671
|
+
};
|
|
1672
|
+
if (this.signInResolver) {
|
|
1673
|
+
response.backstageIdentity = await this.signInResolver({
|
|
1674
|
+
result,
|
|
1675
|
+
profile
|
|
1676
|
+
}, {
|
|
1677
|
+
tokenIssuer: this.tokenIssuer,
|
|
1678
|
+
catalogIdentityClient: this.catalogIdentityClient,
|
|
1679
|
+
logger: this.logger
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
return response;
|
|
1683
|
+
}
|
|
1684
|
+
async refresh(req) {
|
|
1685
|
+
const {
|
|
1686
|
+
accessToken,
|
|
1687
|
+
params,
|
|
1688
|
+
refreshToken: newRefreshToken
|
|
1689
|
+
} = await executeRefreshTokenStrategy(this._strategy, req.refreshToken, req.scope);
|
|
1690
|
+
const fullProfile = await executeFetchUserProfileStrategy(this._strategy, accessToken);
|
|
1691
|
+
return this.handleResult({
|
|
1692
|
+
fullProfile,
|
|
1693
|
+
params,
|
|
1694
|
+
accessToken,
|
|
1695
|
+
refreshToken: newRefreshToken
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
const createAtlassianProvider = (options) => {
|
|
1700
|
+
return ({
|
|
1701
|
+
providerId,
|
|
1702
|
+
globalConfig,
|
|
1703
|
+
config,
|
|
1704
|
+
tokenIssuer,
|
|
1705
|
+
catalogApi,
|
|
1706
|
+
logger
|
|
1707
|
+
}) => OAuthEnvironmentHandler.mapConfig(config, (envConfig) => {
|
|
1708
|
+
var _a, _b;
|
|
1709
|
+
const clientId = envConfig.getString("clientId");
|
|
1710
|
+
const clientSecret = envConfig.getString("clientSecret");
|
|
1711
|
+
const scopes = envConfig.getString("scopes");
|
|
1712
|
+
const callbackUrl = `${globalConfig.baseUrl}/${providerId}/handler/frame`;
|
|
1713
|
+
const catalogIdentityClient = new CatalogIdentityClient({
|
|
1714
|
+
catalogApi,
|
|
1715
|
+
tokenIssuer
|
|
1716
|
+
});
|
|
1717
|
+
const authHandler = (_a = options == null ? void 0 : options.authHandler) != null ? _a : atlassianDefaultAuthHandler;
|
|
1718
|
+
const provider = new AtlassianAuthProvider({
|
|
1719
|
+
clientId,
|
|
1720
|
+
clientSecret,
|
|
1721
|
+
scopes,
|
|
1722
|
+
callbackUrl,
|
|
1723
|
+
authHandler,
|
|
1724
|
+
signInResolver: (_b = options == null ? void 0 : options.signIn) == null ? void 0 : _b.resolver,
|
|
1725
|
+
catalogIdentityClient,
|
|
1726
|
+
logger,
|
|
1727
|
+
tokenIssuer
|
|
1728
|
+
});
|
|
1729
|
+
return OAuthAdapter.fromConfig(globalConfig, provider, {
|
|
1730
|
+
disableRefresh: true,
|
|
1731
|
+
providerId,
|
|
1732
|
+
tokenIssuer
|
|
1733
|
+
});
|
|
1734
|
+
});
|
|
1735
|
+
};
|
|
1736
|
+
|
|
1559
1737
|
const ALB_JWT_HEADER = "x-amzn-oidc-data";
|
|
1560
1738
|
const ALB_ACCESSTOKEN_HEADER = "x-amzn-oidc-accesstoken";
|
|
1561
1739
|
const getJWTHeaders = (input) => {
|
|
@@ -1856,6 +2034,7 @@ const createSamlProvider = (_options) => {
|
|
|
1856
2034
|
callbackUrl: `${globalConfig.baseUrl}/${providerId}/handler/frame`,
|
|
1857
2035
|
entryPoint: config.getString("entryPoint"),
|
|
1858
2036
|
logoutUrl: config.getOptionalString("logoutUrl"),
|
|
2037
|
+
audience: config.getOptionalString("audience"),
|
|
1859
2038
|
issuer: config.getString("issuer"),
|
|
1860
2039
|
cert: config.getString("cert"),
|
|
1861
2040
|
privateCert: config.getOptionalString("privateKey"),
|
|
@@ -2069,7 +2248,8 @@ const factories = {
|
|
|
2069
2248
|
oidc: createOidcProvider(),
|
|
2070
2249
|
onelogin: createOneLoginProvider(),
|
|
2071
2250
|
awsalb: createAwsAlbProvider(),
|
|
2072
|
-
bitbucket: createBitbucketProvider()
|
|
2251
|
+
bitbucket: createBitbucketProvider(),
|
|
2252
|
+
atlassian: createAtlassianProvider()
|
|
2073
2253
|
};
|
|
2074
2254
|
|
|
2075
2255
|
function createOidcRouter(options) {
|
|
@@ -2288,6 +2468,121 @@ class DatabaseKeyStore {
|
|
|
2288
2468
|
}
|
|
2289
2469
|
}
|
|
2290
2470
|
|
|
2471
|
+
class MemoryKeyStore {
|
|
2472
|
+
constructor() {
|
|
2473
|
+
this.keys = new Map();
|
|
2474
|
+
}
|
|
2475
|
+
async addKey(key) {
|
|
2476
|
+
this.keys.set(key.kid, {
|
|
2477
|
+
createdAt: luxon.DateTime.utc().toJSDate(),
|
|
2478
|
+
key: JSON.stringify(key)
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2481
|
+
async removeKeys(kids) {
|
|
2482
|
+
for (const kid of kids) {
|
|
2483
|
+
this.keys.delete(kid);
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
async listKeys() {
|
|
2487
|
+
return {
|
|
2488
|
+
items: Array.from(this.keys).map(([, {createdAt, key: keyStr}]) => ({
|
|
2489
|
+
createdAt,
|
|
2490
|
+
key: JSON.parse(keyStr)
|
|
2491
|
+
}))
|
|
2492
|
+
};
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
const DEFAULT_TIMEOUT_MS = 1e4;
|
|
2497
|
+
const DEFAULT_DOCUMENT_PATH = "sessions";
|
|
2498
|
+
class FirestoreKeyStore {
|
|
2499
|
+
constructor(database, path, timeout) {
|
|
2500
|
+
this.database = database;
|
|
2501
|
+
this.path = path;
|
|
2502
|
+
this.timeout = timeout;
|
|
2503
|
+
}
|
|
2504
|
+
static async create(settings) {
|
|
2505
|
+
const {path, timeout, ...firestoreSettings} = settings != null ? settings : {};
|
|
2506
|
+
const database = new firestore.Firestore(firestoreSettings);
|
|
2507
|
+
return new FirestoreKeyStore(database, path != null ? path : DEFAULT_DOCUMENT_PATH, timeout != null ? timeout : DEFAULT_TIMEOUT_MS);
|
|
2508
|
+
}
|
|
2509
|
+
static async verifyConnection(keyStore, logger) {
|
|
2510
|
+
try {
|
|
2511
|
+
await keyStore.verify();
|
|
2512
|
+
} catch (error) {
|
|
2513
|
+
if (process.env.NODE_ENV !== "development") {
|
|
2514
|
+
throw new Error(`Failed to connect to database: ${error.message}`);
|
|
2515
|
+
}
|
|
2516
|
+
logger == null ? void 0 : logger.warn(`Failed to connect to database: ${error.message}`);
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
async addKey(key) {
|
|
2520
|
+
await this.withTimeout(this.database.collection(this.path).doc(key.kid).set({
|
|
2521
|
+
kid: key.kid,
|
|
2522
|
+
key: JSON.stringify(key)
|
|
2523
|
+
}));
|
|
2524
|
+
}
|
|
2525
|
+
async listKeys() {
|
|
2526
|
+
const keys = await this.withTimeout(this.database.collection(this.path).get());
|
|
2527
|
+
return {
|
|
2528
|
+
items: keys.docs.map((key) => ({
|
|
2529
|
+
key: key.data(),
|
|
2530
|
+
createdAt: key.createTime.toDate()
|
|
2531
|
+
}))
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
async removeKeys(kids) {
|
|
2535
|
+
for (const kid of kids) {
|
|
2536
|
+
await this.withTimeout(this.database.collection(this.path).doc(kid).delete());
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
async withTimeout(operation) {
|
|
2540
|
+
const timer = new Promise((_, reject) => setTimeout(() => {
|
|
2541
|
+
reject(new Error(`Operation timed out after ${this.timeout}ms`));
|
|
2542
|
+
}, this.timeout));
|
|
2543
|
+
return Promise.race([operation, timer]);
|
|
2544
|
+
}
|
|
2545
|
+
async verify() {
|
|
2546
|
+
await this.withTimeout(this.database.collection(this.path).limit(1).get());
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
class KeyStores {
|
|
2551
|
+
static async fromConfig(config, options) {
|
|
2552
|
+
var _a;
|
|
2553
|
+
const {logger, database} = options != null ? options : {};
|
|
2554
|
+
const ks = config.getOptionalConfig("auth.keyStore");
|
|
2555
|
+
const provider = (_a = ks == null ? void 0 : ks.getOptionalString("provider")) != null ? _a : "database";
|
|
2556
|
+
logger == null ? void 0 : logger.info(`Configuring "${provider}" as KeyStore provider`);
|
|
2557
|
+
if (provider === "database") {
|
|
2558
|
+
if (!database) {
|
|
2559
|
+
throw new Error("This KeyStore provider requires a database");
|
|
2560
|
+
}
|
|
2561
|
+
return await DatabaseKeyStore.create({
|
|
2562
|
+
database: await database.getClient()
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
if (provider === "memory") {
|
|
2566
|
+
return new MemoryKeyStore();
|
|
2567
|
+
}
|
|
2568
|
+
if (provider === "firestore") {
|
|
2569
|
+
const settings = ks == null ? void 0 : ks.getConfig(provider);
|
|
2570
|
+
const keyStore = await FirestoreKeyStore.create(lodash.pickBy({
|
|
2571
|
+
projectId: settings == null ? void 0 : settings.getOptionalString("projectId"),
|
|
2572
|
+
keyFilename: settings == null ? void 0 : settings.getOptionalString("keyFilename"),
|
|
2573
|
+
host: settings == null ? void 0 : settings.getOptionalString("host"),
|
|
2574
|
+
port: settings == null ? void 0 : settings.getOptionalNumber("port"),
|
|
2575
|
+
ssl: settings == null ? void 0 : settings.getOptionalBoolean("ssl"),
|
|
2576
|
+
path: settings == null ? void 0 : settings.getOptionalString("path"),
|
|
2577
|
+
timeout: settings == null ? void 0 : settings.getOptionalNumber("timeout")
|
|
2578
|
+
}, (value) => value !== void 0));
|
|
2579
|
+
await FirestoreKeyStore.verifyConnection(keyStore, logger);
|
|
2580
|
+
return keyStore;
|
|
2581
|
+
}
|
|
2582
|
+
throw new Error(`Unknown KeyStore provider: ${provider}`);
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2291
2586
|
async function createRouter({
|
|
2292
2587
|
logger,
|
|
2293
2588
|
config,
|
|
@@ -2298,10 +2593,8 @@ async function createRouter({
|
|
|
2298
2593
|
const router = Router__default['default']();
|
|
2299
2594
|
const appUrl = config.getString("app.baseUrl");
|
|
2300
2595
|
const authUrl = await discovery.getExternalBaseUrl("auth");
|
|
2596
|
+
const keyStore = await KeyStores.fromConfig(config, {logger, database});
|
|
2301
2597
|
const keyDurationSeconds = 3600;
|
|
2302
|
-
const keyStore = await DatabaseKeyStore.create({
|
|
2303
|
-
database: await database.getClient()
|
|
2304
|
-
});
|
|
2305
2598
|
const tokenIssuer = new TokenFactory({
|
|
2306
2599
|
issuer: authUrl,
|
|
2307
2600
|
keyStore,
|
|
@@ -2396,6 +2689,7 @@ exports.OAuthAdapter = OAuthAdapter;
|
|
|
2396
2689
|
exports.OAuthEnvironmentHandler = OAuthEnvironmentHandler;
|
|
2397
2690
|
exports.bitbucketUserIdSignInResolver = bitbucketUserIdSignInResolver;
|
|
2398
2691
|
exports.bitbucketUsernameSignInResolver = bitbucketUsernameSignInResolver;
|
|
2692
|
+
exports.createAtlassianProvider = createAtlassianProvider;
|
|
2399
2693
|
exports.createAwsAlbProvider = createAwsAlbProvider;
|
|
2400
2694
|
exports.createBitbucketProvider = createBitbucketProvider;
|
|
2401
2695
|
exports.createGithubProvider = createGithubProvider;
|