@boxyhq/saml-jackson 0.2.3-beta.219 → 0.2.3-beta.220
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/package.json
CHANGED
package/src/controller/oauth.ts
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
import crypto from 'crypto';
|
2
|
-
import * as dbutils from '../db/utils';
|
3
2
|
import {
|
4
3
|
IOAuthController,
|
4
|
+
JacksonOption,
|
5
5
|
OAuthReqBody,
|
6
6
|
OAuthTokenReq,
|
7
7
|
OAuthTokenRes,
|
8
8
|
Profile,
|
9
9
|
SAMLResponsePayload,
|
10
|
+
Storable,
|
10
11
|
} from 'saml-jackson';
|
12
|
+
import * as dbutils from '../db/utils';
|
13
|
+
import saml from '../saml/saml';
|
11
14
|
import { JacksonError } from './error';
|
12
15
|
import * as allowed from './oauth/allowed';
|
13
16
|
import * as codeVerifier from './oauth/code-verifier';
|
14
17
|
import * as redirect from './oauth/redirect';
|
15
18
|
import { IndexNames } from './utils';
|
16
19
|
|
17
|
-
import saml from '../saml/saml';
|
18
|
-
|
19
20
|
const relayStatePrefix = 'boxyhq_jackson_';
|
20
21
|
|
21
22
|
function getEncodedClientId(
|
@@ -39,11 +40,11 @@ function getEncodedClientId(
|
|
39
40
|
}
|
40
41
|
|
41
42
|
export class OAuthController implements IOAuthController {
|
42
|
-
private configStore;
|
43
|
-
private sessionStore;
|
44
|
-
private codeStore;
|
45
|
-
private tokenStore;
|
46
|
-
private opts;
|
43
|
+
private configStore: Storable;
|
44
|
+
private sessionStore: Storable;
|
45
|
+
private codeStore: Storable;
|
46
|
+
private tokenStore: Storable;
|
47
|
+
private opts: JacksonOption;
|
47
48
|
|
48
49
|
constructor({ configStore, sessionStore, codeStore, tokenStore, opts }) {
|
49
50
|
this.configStore = configStore;
|
@@ -133,6 +134,7 @@ export class OAuthController implements IOAuthController {
|
|
133
134
|
}
|
134
135
|
|
135
136
|
const samlReq = saml.request({
|
137
|
+
// @ts-ignore
|
136
138
|
entityID: this.opts.samlAudience,
|
137
139
|
callbackUrl: this.opts.externalUrl + this.opts.samlPath,
|
138
140
|
signingKey: samlConfig.certs.privateKey,
|
@@ -188,6 +190,8 @@ export class OAuthController implements IOAuthController {
|
|
188
190
|
|
189
191
|
const samlConfigs = await this.configStore.getByIndex({
|
190
192
|
name: IndexNames.EntityID,
|
193
|
+
|
194
|
+
// @ts-ignore
|
191
195
|
value: parsedResp?.issuer,
|
192
196
|
});
|
193
197
|
|
File without changes
|
package/src/test/db.test.ts
CHANGED
@@ -25,17 +25,17 @@ const record2 = {
|
|
25
25
|
city: 'London',
|
26
26
|
};
|
27
27
|
|
28
|
-
const memDbConfig
|
28
|
+
const memDbConfig = <DatabaseOption>{
|
29
29
|
engine: 'mem',
|
30
30
|
ttl: 1,
|
31
31
|
};
|
32
32
|
|
33
|
-
const redisDbConfig
|
33
|
+
const redisDbConfig = <DatabaseOption>{
|
34
34
|
engine: 'redis',
|
35
35
|
url: 'redis://localhost:6379',
|
36
36
|
};
|
37
37
|
|
38
|
-
const postgresDbConfig
|
38
|
+
const postgresDbConfig = <DatabaseOption>{
|
39
39
|
engine: 'sql',
|
40
40
|
url: 'postgresql://postgres:postgres@localhost:5432/postgres',
|
41
41
|
type: 'postgres',
|
@@ -43,12 +43,12 @@ const postgresDbConfig: Partial<DatabaseOption> = {
|
|
43
43
|
cleanupLimit: 1,
|
44
44
|
};
|
45
45
|
|
46
|
-
const mongoDbConfig
|
46
|
+
const mongoDbConfig = <DatabaseOption>{
|
47
47
|
engine: 'mongo',
|
48
48
|
url: 'mongodb://localhost:27017/jackson',
|
49
49
|
};
|
50
50
|
|
51
|
-
const mysqlDbConfig
|
51
|
+
const mysqlDbConfig = <DatabaseOption>{
|
52
52
|
engine: 'sql',
|
53
53
|
url: 'mysql://root:mysql@localhost:3307/mysql',
|
54
54
|
type: 'mysql',
|
@@ -56,7 +56,7 @@ const mysqlDbConfig: Partial<DatabaseOption> = {
|
|
56
56
|
cleanupLimit: 1,
|
57
57
|
};
|
58
58
|
|
59
|
-
const mariadbDbConfig
|
59
|
+
const mariadbDbConfig = <DatabaseOption>{
|
60
60
|
engine: 'sql',
|
61
61
|
url: 'mariadb://root@localhost:3306/mysql',
|
62
62
|
type: 'mariadb',
|
@@ -111,7 +111,7 @@ const dbs = [
|
|
111
111
|
|
112
112
|
tap.before(async () => {
|
113
113
|
for (const idx in dbs) {
|
114
|
-
const opts =
|
114
|
+
const opts = dbs[idx];
|
115
115
|
const db = await DB.new(opts);
|
116
116
|
|
117
117
|
configStores.push(db.store('saml:config'));
|
@@ -130,8 +130,6 @@ tap.test('dbs', ({ end }) => {
|
|
130
130
|
let dbEngine = dbs[idx].engine;
|
131
131
|
|
132
132
|
if (dbs[idx].type) {
|
133
|
-
// TODO Fix it
|
134
|
-
// @ts-ignore
|
135
133
|
dbEngine += ': ' + dbs[idx].type;
|
136
134
|
}
|
137
135
|
|
@@ -277,10 +275,7 @@ tap.test('dbs', ({ end }) => {
|
|
277
275
|
});
|
278
276
|
|
279
277
|
tap.test('ttl expiry: ' + dbEngine, async (t) => {
|
280
|
-
console.log({ dbEngine });
|
281
|
-
|
282
278
|
// mongo runs ttl task every 60 seconds
|
283
|
-
// @ts-ignore
|
284
279
|
if (dbEngine.startsWith('mongo')) {
|
285
280
|
t.end();
|
286
281
|
return;
|
@@ -302,9 +297,9 @@ tap.test('dbs', ({ end }) => {
|
|
302
297
|
|
303
298
|
tap.test('db.new() error', async (t) => {
|
304
299
|
try {
|
305
|
-
await DB.new({
|
306
|
-
engine: 'somedb'
|
307
|
-
}
|
300
|
+
await DB.new(<DatabaseOption>{
|
301
|
+
engine: <DatabaseEngine>'somedb',
|
302
|
+
});
|
308
303
|
|
309
304
|
t.fail('expecting an unsupported db error');
|
310
305
|
} catch (err) {
|
File without changes
|