@boxyhq/saml-jackson 0.1.5-beta.93 → 0.1.5-beta.97

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/README.md CHANGED
@@ -105,7 +105,7 @@ docker run -p 5000:5000 -p 6000:6000 boxyhq/jackson:78e9099d
105
105
  ```
106
106
 
107
107
  # Database Support
108
- Jackson currently supports SQL databases (Postgres, CockroachDB, MySQL and MariaDB), MongoDB and Redis.
108
+ Jackson currently supports SQL databases (Postgres, CockroachDB, MySQL, and MariaDB), MongoDB, and Redis.
109
109
 
110
110
  # Configuration
111
111
  Configuration is done via env vars (and in the case of the npm library via an options object). The following options are supported and will have to be configured during deployment:
@@ -114,7 +114,7 @@ Configuration is done via env vars (and in the case of the npm library via an op
114
114
  - EXTERNAL_URL (npm: externalUrl): The public URL to reach this service, used internally for documenting the SAML configuration instructions. Defaults to `http://{HOST_URL}:{HOST_PORT}` for Jackson service, required for npm library
115
115
  - INTERNAL_HOST_URL: The URL to bind to expose the internal APIs, defaults to `localhost`. Do not configure this to a public network
116
116
  - INTERNAL_HOST_PORT: The port to bind to for the internal APIs, defaults to `6000`
117
- - SAML_AUDIENCE (npm: samlAudience): This is just an identitifer to validate the SAML audience, this value will also get configured in the SAML apps created by your customers. Once set do not change this value unless you get your customers to reconfigure their SAML again. Defaults to `https://saml.boxyhq.com` and is case sensitive. This does not have be a real URL
117
+ - SAML_AUDIENCE (npm: samlAudience): This is just an identifier to validate the SAML audience, this value will also get configured in the SAML apps created by your customers. Once set do not change this value unless you get your customers to reconfigure their SAML again. Defaults to `https://saml.boxyhq.com` and is case sensitive. This does not have to be a real URL
118
118
  - IDP_ENABLED (npm: idpEnabled): Set to `true` to enable IdP initiated login for SAML. SP initiated login is the only recommended flow but you might have to support IdP login at times. Defaults to `false`
119
119
  - DB_ENGINE (npm: db.engine): Supported values are `redis`, `sql`, `mongo`, `mem`. Defaults to `sql`
120
120
  - DB_URL (npm: db.url): The database URL to connect to, for example `postgres://postgres:postgres@localhost:5450/jackson`
@@ -167,7 +167,7 @@ curl --location --request POST 'http://localhost:6000/api/v1/saml/config' \
167
167
  - rawMetadata: The XML metadata file your customer gets from their Identity Provider
168
168
  - defaultRedirectUrl: The redirect URL to use in the IdP login flow. Jackson will call this URL after completing an IdP login flow
169
169
  - redirectUrl: JSON encoded array containing a list of allowed redirect URLs. Jackson will disallow any redirects not on this list (or not the default URL above)
170
- - tenant: Jackson supports a multi-tenant architecture, this is a unique identifier you set from your side that relates back to your customer's tenant. This is normally an email, domain, an account id, or user id
170
+ - tenant: Jackson supports a multi-tenant architecture, this is a unique identifier you set from your side that relates back to your customer's tenant. This is normally an email, domain, an account id, or user-id
171
171
  - product: Jackson support multiple products, this is a unique identifier you set from your side that relates back to the product your customer is using
172
172
 
173
173
  The response returns a JSON with `client_id` and `client_secret` that can be stored against your tenant and product for a more secure OAuth 2.0 flow. If you do not want to store the `client_id` and `client_secret` you can alternatively use `client_id=tentant=<tenantID>&product=<productID>` and any arbitrary value for `client_secret` when setting up the OAuth 2.0 flow.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boxyhq/saml-jackson",
3
- "version": "0.1.5-beta.93",
3
+ "version": "0.1.5-beta.97",
4
4
  "license": "Apache 2.0",
5
5
  "description": "SAML 2.0 service",
6
6
  "main": "src/index.js",
@@ -32,27 +32,27 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@boxyhq/saml20": "0.2.0",
35
- "@peculiar/webcrypto": "1.1.7",
36
- "@peculiar/x509": "1.4.1",
35
+ "@peculiar/webcrypto": "1.2.2",
36
+ "@peculiar/x509": "1.6.0",
37
37
  "cors": "2.8.5",
38
38
  "express": "4.17.1",
39
- "mongodb": "4.1.3",
40
- "mysql2": "^2.3.3-rc.0",
39
+ "mongodb": "4.2.0",
40
+ "mysql2": "2.3.3",
41
41
  "pg": "8.7.1",
42
42
  "rambda": "6.9.0",
43
- "redis": "4.0.0-rc.3",
43
+ "redis": "4.0.0-rc.4",
44
44
  "reflect-metadata": "0.1.13",
45
45
  "ripemd160": "2.0.2",
46
46
  "thumbprint": "0.0.1",
47
- "typeorm": "0.2.38",
47
+ "typeorm": "0.2.41",
48
48
  "xml-crypto": "2.1.3",
49
49
  "xml2js": "0.4.23",
50
50
  "xmlbuilder": "15.1.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "cross-env": "7.0.3",
54
- "eslint": "^8.2.0",
55
- "nodemon": "2.0.13",
56
- "tap": "15.0.10"
54
+ "eslint": "8.3.0",
55
+ "nodemon": "2.0.15",
56
+ "tap": "15.1.2"
57
57
  }
58
58
  }
@@ -13,9 +13,11 @@ module.exports = new EntitySchema({
13
13
  },
14
14
  key: {
15
15
  type: 'varchar',
16
+ length: 1500,
16
17
  },
17
18
  storeKey: {
18
19
  type: 'varchar',
20
+ length: 1500,
19
21
  }
20
22
  },
21
23
  relations: {
@@ -1,20 +1,36 @@
1
1
  const EntitySchema = require('typeorm').EntitySchema;
2
2
  const JacksonStore = require('../model/JacksonStore.js');
3
3
 
4
- module.exports = new EntitySchema({
5
- name: 'JacksonStore',
6
- target: JacksonStore,
7
- columns: {
8
- key: {
9
- primary: true,
10
- type: 'varchar',
11
- },
12
- value: {
13
- type: 'varchar',
4
+ const valueType = (type) => {
5
+ switch (type) {
6
+ case 'postgres':
7
+ case 'cockroachdb':
8
+ return 'text';
9
+ case 'mysql':
10
+ case 'mariadb':
11
+ return 'mediumtext';
12
+ default:
13
+ return 'varchar';
14
+ }
15
+ };
16
+
17
+ module.exports = (type) => {
18
+ return new EntitySchema({
19
+ name: 'JacksonStore',
20
+ target: JacksonStore,
21
+ columns: {
22
+ key: {
23
+ primary: true,
24
+ type: 'varchar',
25
+ length: 1500,
26
+ },
27
+ value: {
28
+ type: valueType(type),
29
+ },
30
+ expiresAt: {
31
+ type: 'bigint',
32
+ nullable: true,
33
+ },
14
34
  },
15
- expiresAt: {
16
- type: 'bigint',
17
- nullable: true,
18
- }
19
- },
20
- });
35
+ });
36
+ };
package/src/db/sql/sql.js CHANGED
@@ -8,17 +8,28 @@ const dbutils = require('../utils.js');
8
8
  class Sql {
9
9
  constructor(options) {
10
10
  return (async () => {
11
- this.connection = await typeorm.createConnection({
12
- name: options.type,
13
- type: options.type,
14
- url: options.url,
15
- synchronize: true,
16
- logging: false,
17
- entities: [
18
- require('./entity/JacksonStore.js'),
19
- require('./entity/JacksonIndex.js'),
20
- ],
21
- });
11
+ while (true) {
12
+ try {
13
+ this.connection = await typeorm.createConnection({
14
+ name: options.type,
15
+ type: options.type,
16
+ url: options.url,
17
+ synchronize: true,
18
+ migrationsTableName: '_jackson_migrations',
19
+ logging: false,
20
+ entities: [
21
+ require('./entity/JacksonStore.js')(options.type),
22
+ require('./entity/JacksonIndex.js'),
23
+ ],
24
+ });
25
+
26
+ break;
27
+ } catch (err) {
28
+ console.error(`error connecting to ${options.type} db: ${err}`);
29
+ await dbutils.sleep(1000);
30
+ continue;
31
+ }
32
+ }
22
33
 
23
34
  this.storeRepository = this.connection.getRepository(JacksonStore);
24
35
  this.indexRepository = this.connection.getRepository(JacksonIndex);
@@ -45,7 +56,9 @@ class Sql {
45
56
 
46
57
  this.timerId = setTimeout(this.ttlCleanup, options.ttl * 1000);
47
58
  } else {
48
- console.log('Warning: ttl cleanup not enabled, set both "ttl" and "limit" options to enable it!')
59
+ console.log(
60
+ 'Warning: ttl cleanup not enabled, set both "ttl" and "limit" options to enable it!'
61
+ );
49
62
  }
50
63
 
51
64
  return this;
package/src/db/utils.js CHANGED
@@ -16,14 +16,15 @@ const keyFromParts = (...parts) => {
16
16
  return parts.join(':'); // TODO: pick a better strategy, keys can collide now
17
17
  };
18
18
 
19
+ const sleep = (ms) => {
20
+ return new Promise((resolve) => setTimeout(resolve, ms));
21
+ };
22
+
19
23
  module.exports = {
20
24
  key,
21
-
22
25
  keyForIndex,
23
-
24
26
  keyDigest,
25
-
26
27
  keyFromParts,
27
-
28
+ sleep,
28
29
  indexPrefix: '_index',
29
30
  };
package/src/index.js CHANGED
@@ -56,7 +56,8 @@ module.exports = async function (opts) {
56
56
  }
57
57
  }
58
58
 
59
- console.log(`Using engine: ${opts.db.engine}`);
59
+ const type = opts.db.type ? ' Type: ' + opts.db.type : '';
60
+ console.log(`Using engine: ${opts.db.engine}.${type}`);
60
61
 
61
62
  return {
62
63
  apiController,
package/src/saml/saml.js CHANGED
@@ -141,20 +141,12 @@ module.exports = {
141
141
  let X509Certificate = null;
142
142
  let ssoPostUrl = null;
143
143
  let ssoRedirectUrl = null;
144
- let loginType = 'idp';
145
144
 
146
- let ssoDes = rambda.pathOr(
147
- null,
145
+ const ssoDes = rambda.pathOr(
146
+ [],
148
147
  'EntityDescriptor.IDPSSODescriptor',
149
148
  res
150
149
  );
151
- if (!ssoDes) {
152
- ssoDes = rambda.pathOr([], 'EntityDescriptor.SPSSODescriptor', res);
153
- if (!ssoDes) {
154
- loginType = 'sp';
155
- }
156
- }
157
-
158
150
  for (const ssoDesRec of ssoDes) {
159
151
  const keyDes = ssoDesRec['KeyDescriptor'];
160
152
  for (const keyDesRec of keyDes) {
@@ -165,10 +157,7 @@ module.exports = {
165
157
  }
166
158
  }
167
159
 
168
- const ssoSvc =
169
- ssoDesRec['SingleSignOnService'] ||
170
- ssoDesRec['AssertionConsumerService'] ||
171
- [];
160
+ const ssoSvc = ssoDesRec['SingleSignOnService'] || [];
172
161
  for (const ssoSvcRec of ssoSvc) {
173
162
  if (
174
163
  rambda.pathOr('', '$.Binding', ssoSvcRec).endsWith('HTTP-POST')
@@ -199,7 +188,6 @@ module.exports = {
199
188
  if (ssoRedirectUrl) {
200
189
  ret.sso.redirectUrl = ssoRedirectUrl;
201
190
  }
202
- ret.loginType = loginType;
203
191
 
204
192
  resolve(ret);
205
193
  }