@boxyhq/saml-jackson 0.3.3 → 0.3.4-beta.314
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/dist/controller/api.js +9 -5
- package/dist/read-config.js +2 -1
- package/dist/typings.d.ts +2 -1
- package/package.json +4 -4
- package/README.md +0 -440
package/dist/controller/api.js
CHANGED
@@ -43,9 +43,9 @@ class APIController {
|
|
43
43
|
this.configStore = configStore;
|
44
44
|
}
|
45
45
|
_validateIdPConfig(body) {
|
46
|
-
const { rawMetadata, defaultRedirectUrl, redirectUrl, tenant, product } = body;
|
47
|
-
if (!rawMetadata) {
|
48
|
-
throw new error_1.JacksonError('Please provide rawMetadata', 400);
|
46
|
+
const { encodedRawMetadata, rawMetadata, defaultRedirectUrl, redirectUrl, tenant, product } = body;
|
47
|
+
if (!rawMetadata && !encodedRawMetadata) {
|
48
|
+
throw new error_1.JacksonError('Please provide rawMetadata or encodedRawMetadata', 400);
|
49
49
|
}
|
50
50
|
if (!defaultRedirectUrl) {
|
51
51
|
throw new error_1.JacksonError('Please provide a defaultRedirectUrl', 400);
|
@@ -62,9 +62,13 @@ class APIController {
|
|
62
62
|
}
|
63
63
|
config(body) {
|
64
64
|
return __awaiter(this, void 0, void 0, function* () {
|
65
|
-
const { rawMetadata, defaultRedirectUrl, redirectUrl, tenant, product } = body;
|
65
|
+
const { encodedRawMetadata, rawMetadata, defaultRedirectUrl, redirectUrl, tenant, product } = body;
|
66
66
|
this._validateIdPConfig(body);
|
67
|
-
|
67
|
+
let metaData = rawMetadata;
|
68
|
+
if (encodedRawMetadata) {
|
69
|
+
metaData = Buffer.from(encodedRawMetadata, 'base64').toString();
|
70
|
+
}
|
71
|
+
const idpMetadata = yield saml_1.default.parseMetadataAsync(metaData);
|
68
72
|
// extract provider
|
69
73
|
let providerName = extractHostName(idpMetadata.entityID);
|
70
74
|
if (!providerName) {
|
package/dist/read-config.js
CHANGED
@@ -39,9 +39,10 @@ const readConfig = (preLoadedConfig) => __awaiter(void 0, void 0, void 0, functi
|
|
39
39
|
for (const idx in files) {
|
40
40
|
const file = files[idx];
|
41
41
|
if (file.endsWith('.js')) {
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
42
43
|
const config = require(path.join(preLoadedConfig, file));
|
43
44
|
const rawMetadata = yield fs.promises.readFile(path.join(preLoadedConfig, path.parse(file).name + '.xml'), 'utf8');
|
44
|
-
config.
|
45
|
+
config.encodedRawMetadata = Buffer.from(rawMetadata, 'utf8').toString('base64');
|
45
46
|
configs.push(config);
|
46
47
|
}
|
47
48
|
}
|
package/dist/typings.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@boxyhq/saml-jackson",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.4-beta.314",
|
4
4
|
"description": "SAML 2.0 service",
|
5
5
|
"keywords": [
|
6
6
|
"SAML 2.0"
|
@@ -36,10 +36,10 @@
|
|
36
36
|
"@peculiar/x509": "1.6.1",
|
37
37
|
"cors": "2.8.5",
|
38
38
|
"express": "4.17.2",
|
39
|
-
"mongodb": "4.
|
39
|
+
"mongodb": "4.3.0",
|
40
40
|
"mysql2": "2.3.3",
|
41
41
|
"pg": "8.7.1",
|
42
|
-
"rambda": "
|
42
|
+
"rambda": "7.0.1",
|
43
43
|
"redis": "4.0.1",
|
44
44
|
"reflect-metadata": "0.1.13",
|
45
45
|
"ripemd160": "2.0.2",
|
@@ -60,7 +60,7 @@
|
|
60
60
|
"eslint-config-prettier": "8.3.0",
|
61
61
|
"prettier": "2.5.1",
|
62
62
|
"sinon": "12.0.1",
|
63
|
-
"tap": "15.1.
|
63
|
+
"tap": "15.1.6",
|
64
64
|
"ts-node": "10.4.0",
|
65
65
|
"tsconfig-paths": "3.12.0",
|
66
66
|
"typescript": "4.5.4"
|
package/README.md
DELETED
@@ -1,440 +0,0 @@
|
|
1
|
-
# SAML Jackson (not fiction anymore)
|
2
|
-
|
3
|
-
SAML service [SAML in a box from BoxyHQ]
|
4
|
-
|
5
|
-
You need someone like Jules Winnfield to save you from the vagaries of SAML login.
|
6
|
-
|
7
|
-
## Source code visualizer
|
8
|
-
|
9
|
-
[CodeSee codebase visualizer](https://app.codesee.io/maps/public/53e91640-23b5-11ec-a724-79d7dd589517)
|
10
|
-
|
11
|
-
## Getting Started
|
12
|
-
|
13
|
-
There are two ways to use this repo.
|
14
|
-
|
15
|
-
- As an npm library
|
16
|
-
- As a separate service
|
17
|
-
|
18
|
-
## Install as an npm library
|
19
|
-
|
20
|
-
Jackson is available as an [npm package](https://www.npmjs.com/package/@boxyhq/saml-jackson) that can be integrated into any web application framework (like Express.js for example). Please file an issue or submit a PR if you encounter any issues with your choice of framework.
|
21
|
-
|
22
|
-
```bash
|
23
|
-
npm i @boxyhq/saml-jackson
|
24
|
-
```
|
25
|
-
|
26
|
-
### Add Express Routes
|
27
|
-
|
28
|
-
```javascript
|
29
|
-
// express
|
30
|
-
const express = require('express');
|
31
|
-
const router = express.Router();
|
32
|
-
const cors = require('cors'); // needed if you are calling the token userinfo endpoints from the frontend
|
33
|
-
|
34
|
-
// Set the required options. Refer to https://github.com/boxyhq/jackson#configuration for the full list
|
35
|
-
const opts = {
|
36
|
-
externalUrl: 'https://my-cool-app.com',
|
37
|
-
samlAudience: 'https://my-cool-app.com',
|
38
|
-
samlPath: '/sso/oauth/saml',
|
39
|
-
db: {
|
40
|
-
engine: 'mongo',
|
41
|
-
url: 'mongodb://localhost:27017/my-cool-app',
|
42
|
-
}
|
43
|
-
};
|
44
|
-
|
45
|
-
|
46
|
-
let apiController;
|
47
|
-
let oauthController;
|
48
|
-
// Please note that the initialization of @boxyhq/saml-jackson is async, you cannot run it at the top level
|
49
|
-
// Run this in a function where you initialise the express server.
|
50
|
-
async function init() {
|
51
|
-
const ret = await require('@boxyhq/saml-jackson')(opts);
|
52
|
-
apiController = ret.apiController;
|
53
|
-
oauthController = ret.oauthController;
|
54
|
-
}
|
55
|
-
|
56
|
-
// express.js middlewares needed to parse json and x-www-form-urlencoded
|
57
|
-
router.use(express.json());
|
58
|
-
router.use(express.urlencoded({ extended: true }));
|
59
|
-
|
60
|
-
// SAML config API. You should pass this route through your authentication checks, do not expose this on the public interface without proper authentication in place.
|
61
|
-
router.post('/api/v1/saml/config', async (req, res) => {
|
62
|
-
try {
|
63
|
-
// apply your authentication flow (or ensure this route has passed through your auth middleware)
|
64
|
-
...
|
65
|
-
|
66
|
-
// only when properly authenticated, call the config function
|
67
|
-
res.json(await apiController.config(req.body));
|
68
|
-
} catch (err) {
|
69
|
-
res.status(500).json({
|
70
|
-
error: err.message,
|
71
|
-
});
|
72
|
-
}
|
73
|
-
});
|
74
|
-
// fetch config
|
75
|
-
router.get('/api/v1/saml/config', async (req, res) => {
|
76
|
-
try {
|
77
|
-
// apply your authentication flow (or ensure this route has passed through your auth middleware)
|
78
|
-
...
|
79
|
-
|
80
|
-
// only when properly authenticated, call the config function
|
81
|
-
res.json(await apiController.config(req.query));
|
82
|
-
} catch (err) {
|
83
|
-
res.status(500).json({
|
84
|
-
error: err.message,
|
85
|
-
});
|
86
|
-
}
|
87
|
-
});
|
88
|
-
// delete config
|
89
|
-
router.delete('/api/v1/saml/config', async (req, res) => {
|
90
|
-
try {
|
91
|
-
// apply your authentication flow (or ensure this route has passed through your auth middleware)
|
92
|
-
...
|
93
|
-
|
94
|
-
// only when properly authenticated, call the config function
|
95
|
-
await apiController.deleteConfig(req.body);
|
96
|
-
res.status(200).end();
|
97
|
-
} catch (err) {
|
98
|
-
res.status(500).json({
|
99
|
-
error: err.message,
|
100
|
-
});
|
101
|
-
}
|
102
|
-
});
|
103
|
-
// OAuth 2.0 flow
|
104
|
-
router.get('/oauth/authorize', async (req, res) => {
|
105
|
-
try {
|
106
|
-
const { redirect_url } = await oauthController.authorize(req.query);
|
107
|
-
|
108
|
-
res.redirect(redirect_url);
|
109
|
-
} catch (err) {
|
110
|
-
const { message, statusCode = 500 } = err;
|
111
|
-
|
112
|
-
res.status(statusCode).send(message);
|
113
|
-
}
|
114
|
-
});
|
115
|
-
|
116
|
-
router.post('/oauth/saml', async (req, res) => {
|
117
|
-
try {
|
118
|
-
const { redirect_url } = await oauthController.samlResponse(req.body);
|
119
|
-
|
120
|
-
res.redirect(redirect_url);
|
121
|
-
} catch (err) {
|
122
|
-
const { message, statusCode = 500 } = err;
|
123
|
-
|
124
|
-
res.status(statusCode).send(message);
|
125
|
-
}
|
126
|
-
});
|
127
|
-
|
128
|
-
router.post('/oauth/token', cors(), async (req, res) => {
|
129
|
-
try {
|
130
|
-
const result = await oauthController.token(req.body);
|
131
|
-
|
132
|
-
res.json(result);
|
133
|
-
} catch (err) {
|
134
|
-
const { message, statusCode = 500 } = err;
|
135
|
-
|
136
|
-
res.status(statusCode).send(message);
|
137
|
-
}
|
138
|
-
});
|
139
|
-
|
140
|
-
router.get('/oauth/userinfo', async (req, res) => {
|
141
|
-
try {
|
142
|
-
let token = extractAuthToken(req);
|
143
|
-
|
144
|
-
// check for query param
|
145
|
-
if (!token) {
|
146
|
-
token = req.query.access_token;
|
147
|
-
}
|
148
|
-
|
149
|
-
if (!token) {
|
150
|
-
res.status(401).json({ message: 'Unauthorized' });
|
151
|
-
}
|
152
|
-
|
153
|
-
const profile = await oauthController.userInfo(token);
|
154
|
-
|
155
|
-
res.json(profile);
|
156
|
-
} catch (err) {
|
157
|
-
const { message, statusCode = 500 } = err;
|
158
|
-
|
159
|
-
res.status(statusCode).json({ message });
|
160
|
-
}
|
161
|
-
});
|
162
|
-
|
163
|
-
// set the router
|
164
|
-
app.use('/sso', router);
|
165
|
-
|
166
|
-
```
|
167
|
-
|
168
|
-
## Deployment as a service: Docker
|
169
|
-
|
170
|
-
The docker container can be found at [boxyhq/jackson](https://hub.docker.com/r/boxyhq/jackson/tags). It is preferable to use a specific version instead of the `latest` tag. Jackson uses two ports (configurable if needed, see below) 5000 and 6000. 6000 is the internal port and ideally should not be exposed to a public network.
|
171
|
-
|
172
|
-
```bash
|
173
|
-
docker run -p 5000:5000 -p 6000:6000 boxyhq/jackson:78e9099d
|
174
|
-
```
|
175
|
-
|
176
|
-
Refer to <https://github.com/boxyhq/jackson#configuration> for the full configuration.
|
177
|
-
|
178
|
-
Kubernetes and docker-compose deployment files will be coming soon.
|
179
|
-
|
180
|
-
## Usage
|
181
|
-
|
182
|
-
### 1. Setting up SAML with your customer's Identity Provider
|
183
|
-
|
184
|
-
Please follow the instructions [here](https://docs.google.com/document/d/1fk---Z9Ln59u-2toGKUkyO3BF6Dh3dscT2u4J2xHANE) to guide your customers in setting up SAML correctly for your product(s). You should create a copy of the doc and modify it with your custom settings, we have used the values that work for our demo apps.
|
185
|
-
|
186
|
-
### 1.1 SAML profile/claims/attributes mapping
|
187
|
-
|
188
|
-
As outlined in the guide above we try and support 4 attributes in the SAML claims - `id`, `email`, `firstName`, `lastName`. This is how the common SAML attributes map over for most providers, but some providers have custom mappings. Please refer to the documentation on Identity Provider to understand the exact mapping.
|
189
|
-
|
190
|
-
| SAML Attribute | Jackson mapping |
|
191
|
-
| ---------------------------------------------------------------------- | --------------- |
|
192
|
-
| <http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier> | id |
|
193
|
-
| <http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress> | email |
|
194
|
-
| <http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname> | firstName |
|
195
|
-
| <http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname> | lastName |
|
196
|
-
|
197
|
-
### 2. SAML config API
|
198
|
-
|
199
|
-
Once your customer has set up the SAML app on their Identity Provider, the Identity Provider will generate an IdP or SP metadata file. Some Identity Providers only generate an IdP metadata file but it usually works for the SP login flow as well. It is an XML file that contains various attributes Jackson needs to validate incoming SAML login requests. This step is the equivalent of setting an OAuth 2.0 app and generating a client ID and client secret that will be used in the login flow.
|
200
|
-
|
201
|
-
You will need to provide a place in the UI for your customers (The account settings page is usually a good place for this) to configure this and then call the API below.
|
202
|
-
|
203
|
-
The following API call sets up the configuration in Jackson:
|
204
|
-
|
205
|
-
```bash
|
206
|
-
curl --location --request POST 'http://localhost:6000/api/v1/saml/config' \
|
207
|
-
--header 'Authorization: Api-Key <Jackson API Key>' \
|
208
|
-
--header 'Content-Type: application/x-www-form-urlencoded' \
|
209
|
-
--data-urlencode 'rawMetadata=<IdP/SP metadata XML>' \
|
210
|
-
--data-urlencode 'defaultRedirectUrl=http://localhost:3000/login/saml' \
|
211
|
-
--data-urlencode 'redirectUrl=["http://localhost:3000/*"]' \
|
212
|
-
--data-urlencode 'tenant=boxyhq.com' \
|
213
|
-
--data-urlencode 'product=demo'
|
214
|
-
```
|
215
|
-
|
216
|
-
- rawMetadata: The XML metadata file your customer gets from their Identity Provider
|
217
|
-
- defaultRedirectUrl: The redirect URL to use in the IdP login flow. Jackson will call this URL after completing an IdP login flow
|
218
|
-
- 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)
|
219
|
-
- 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
|
220
|
-
- 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
|
221
|
-
|
222
|
-
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=tenant=<tenantID>&product=<productID>` and any arbitrary value for `client_secret` when setting up the OAuth 2.0 flow. Additionally a `provider` attribute is also returned which indicates the domain of your Identity Provider.
|
223
|
-
|
224
|
-
#### 2.1 SAML get config API
|
225
|
-
|
226
|
-
This endpoint can be used to return metadata about an existing SAML config. This can be used to check and display the details to your customers. You can use either `clientID` or `tenant` and `product` combination.
|
227
|
-
|
228
|
-
```bash
|
229
|
-
curl -G --location 'http://localhost:6000/api/v1/saml/config' \
|
230
|
-
--header 'Authorization: Api-Key <Jackson API Key>' \
|
231
|
-
--header 'Content-Type: application/x-www-form-urlencoded' \
|
232
|
-
--data-urlencode 'tenant=boxyhq.com' \
|
233
|
-
--data-urlencode 'product=demo'
|
234
|
-
```
|
235
|
-
|
236
|
-
```bash
|
237
|
-
curl -G --location 'http://localhost:6000/api/v1/saml/config' \
|
238
|
-
--header 'Authorization: Api-Key <Jackson API Key>' \
|
239
|
-
--header 'Content-Type: application/x-www-form-urlencoded' \
|
240
|
-
--data-urlencode 'clientID=<Client ID>'
|
241
|
-
```
|
242
|
-
|
243
|
-
The response returns a JSON with `provider` indicating the domain of your Identity Provider. If an empty JSON payload is returned then we do not have any configuration stored for the attributes you requested.
|
244
|
-
|
245
|
-
#### 2.2 SAML delete config API
|
246
|
-
|
247
|
-
This endpoint can be used to delete an existing IdP metadata.
|
248
|
-
|
249
|
-
```bash
|
250
|
-
curl -X "DELETE" --location 'http://localhost:6000/api/v1/saml/config' \
|
251
|
-
--header 'Authorization: Api-Key <Jackson API Key>' \
|
252
|
-
--header 'Content-Type: application/x-www-form-urlencoded' \
|
253
|
-
--data-urlencode 'tenant=boxyhq.com' \
|
254
|
-
--data-urlencode 'product=demo'
|
255
|
-
```
|
256
|
-
|
257
|
-
```bash
|
258
|
-
curl -X "DELETE" --location 'http://localhost:6000/api/v1/saml/config' \
|
259
|
-
--header 'Authorization: Api-Key <Jackson API Key>' \
|
260
|
-
--header 'Content-Type: application/x-www-form-urlencoded' \
|
261
|
-
--data-urlencode 'clientID=<Client ID>'
|
262
|
-
--data-urlencode 'clientSecret=<Client Secret>'
|
263
|
-
```
|
264
|
-
|
265
|
-
### 3. OAuth 2.0 Flow
|
266
|
-
|
267
|
-
Jackson has been designed to abstract the SAML login flow as a pure OAuth 2.0 flow. This means it's compatible with any standard OAuth 2.0 library out there, both client-side and server-side. It is important to remember that SAML is configured per customer unlike OAuth 2.0 where you can have a single OAuth app supporting logins for all customers.
|
268
|
-
|
269
|
-
Jackson also supports the PKCE authorization flow (<https://oauth.net/2/pkce/>), so you can protect your SPAs.
|
270
|
-
|
271
|
-
If for any reason you need to implement the flow on your own, the steps are outlined below:
|
272
|
-
|
273
|
-
### 4. Authorize
|
274
|
-
|
275
|
-
The OAuth flow begins with redirecting your user to the `authorize` URL:
|
276
|
-
|
277
|
-
```bash
|
278
|
-
https://localhost:5000/oauth/authorize
|
279
|
-
?response_type=code&provider=saml
|
280
|
-
&client_id=<clientID or tenant and product query params as described in the SAML config API section above>
|
281
|
-
&redirect_uri=<redirect URL>
|
282
|
-
&state=<randomly generated state id>
|
283
|
-
```
|
284
|
-
|
285
|
-
- response_type=code: This is the only supported type for now but maybe extended in the future
|
286
|
-
- client_id: Use the client_id returned by the SAML config API or use `tenant=<tenantID>&product=<productID>` to use the tenant and product IDs instead. **Note:** Please don't forget to URL encode the query parameters including `client_id`.
|
287
|
-
- tenant: Optionally you can provide a dummy `client_id` and specify the `tenant` and `product` custom attributes (if your OAuth 2.0 library allows it).
|
288
|
-
- product: Should be specified if specifying `tenant` above
|
289
|
-
- redirect_uri: This is where the user will be taken back once the authorization flow is complete
|
290
|
-
- state: Use a randomly generated string as the state, this will be echoed back as a query parameter when taking the user back to the `redirect_uri` above. You should validate the state to prevent XSRF attacks
|
291
|
-
|
292
|
-
### 5. Code Exchange
|
293
|
-
|
294
|
-
After successful authorization, the user is redirected back to the `redirect_uri`. The query parameters will include the `code` and `state` parameters. You should validate that the state matches the one you sent in the `authorize` request.
|
295
|
-
|
296
|
-
The code can then be exchanged for a token by making the following request:
|
297
|
-
|
298
|
-
```bash
|
299
|
-
curl --request POST \
|
300
|
-
--url 'http://localhost:5000/oauth/token' \
|
301
|
-
--header 'content-type: application/x-www-form-urlencoded' \
|
302
|
-
--data 'grant_type=authorization_code' \
|
303
|
-
--data 'client_id=<clientID or tenant and product query params as described in the SAML config API section above>' \
|
304
|
-
--data 'client_secret=<clientSecret or any arbitrary value if using the tenant and product in the clientID>' \
|
305
|
-
--data 'redirect_uri=<redirect URL>' \
|
306
|
-
--data 'code=<code from the query parameter above>'
|
307
|
-
```
|
308
|
-
|
309
|
-
- grant_type=authorization_code: This is the only supported flow, for now. We might extend this in the future
|
310
|
-
- client_id: Use the client_id returned by the SAML config API or use `tenant=<tenantID>&product=<productID>` to use the tenant and product IDs instead. **Note:** Please don't forget to URL encode the query parameters including `client_id`.
|
311
|
-
- client_secret: Use the client_secret returned by the SAML config API or any arbitrary value if using the tenant and product in the clientID
|
312
|
-
- redirect_uri: This is where the user will be taken back once the authorization flow is complete. Use the same redirect_uri as the previous request
|
313
|
-
|
314
|
-
If everything goes well you should receive a JSON response that includes the access token. This token is needed for the next step where we fetch the user profile.
|
315
|
-
|
316
|
-
```json
|
317
|
-
{
|
318
|
-
"access_token": <access token>,
|
319
|
-
"token_type": "bearer",
|
320
|
-
"expires_in": 300
|
321
|
-
}
|
322
|
-
```
|
323
|
-
|
324
|
-
### 6. Profile Request
|
325
|
-
|
326
|
-
The short-lived access token can now be used to request the user's profile. You'll need to make the following request:
|
327
|
-
|
328
|
-
```bash
|
329
|
-
curl --request GET \
|
330
|
-
--url https://localhost:5000/oauth/userinfo \
|
331
|
-
--header 'authorization: Bearer <access token>' \
|
332
|
-
--header 'content-type: application/json'
|
333
|
-
```
|
334
|
-
|
335
|
-
If everything goes well you should receive a JSON response with the user's profile:
|
336
|
-
|
337
|
-
```json
|
338
|
-
{
|
339
|
-
"id": <id from the Identity Provider>,
|
340
|
-
"email": "sjackson@coolstartup.com",
|
341
|
-
"firstName": "SAML"
|
342
|
-
"lastName": "Jackson"
|
343
|
-
}
|
344
|
-
```
|
345
|
-
|
346
|
-
- id: The id of the user as provided by the Identity Provider
|
347
|
-
- email: The email address of the user as provided by the Identity Provider
|
348
|
-
- firstName: The first name of the user as provided by the Identity Provider
|
349
|
-
- lastName: The last name of the user as provided by the Identity Provider
|
350
|
-
|
351
|
-
## Examples
|
352
|
-
|
353
|
-
To Do
|
354
|
-
|
355
|
-
## Database Support
|
356
|
-
|
357
|
-
Jackson currently supports the following databases.
|
358
|
-
|
359
|
-
- Postgres
|
360
|
-
- MySQL
|
361
|
-
- MariaDB
|
362
|
-
- MongoDB
|
363
|
-
- Redis
|
364
|
-
|
365
|
-
## Configuration
|
366
|
-
|
367
|
-
Configuration is done via env vars (and in the case of the npm library via an options object).
|
368
|
-
|
369
|
-
The following options are supported and will have to be configured during deployment.
|
370
|
-
|
371
|
-
| Key | Description | Default |
|
372
|
-
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
|
373
|
-
| HOST_URL | The URL to bind to | `localhost` |
|
374
|
-
| HOST_PORT | The port to bind to | `5000` |
|
375
|
-
| EXTERNAL_URL (npm: externalUrl) | The public URL to reach this service, used internally for documenting the SAML configuration instructions. | `http://{HOST_URL}:{HOST_PORT}` |
|
376
|
-
| INTERNAL_HOST_URL | The URL to bind to expose the internal APIs. Do not configure this to a public network. | `localhost` |
|
377
|
-
| INTERNAL_HOST_PORT | The port to bind to for the internal APIs. | `6000` |
|
378
|
-
| JACKSON_API_KEYS | A comma separated list of API keys that will be validated when serving the Config API requests | |
|
379
|
-
| 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. It is case-sensitive. This does not have to be a real URL. | `https://saml.boxyhq.com` |
|
380
|
-
| 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. | `false` |
|
381
|
-
| DB_ENGINE (npm: db.engine) | Supported values are `redis`, `sql`, `mongo`, `mem`. | `sql` |
|
382
|
-
| DB_URL (npm: db.url) | The database URL to connect to. For example `postgres://postgres:postgres@localhost:5450/jackson` | |
|
383
|
-
| DB_TYPE (npm: db.type) | Only needed when DB_ENGINE is `sql`. Supported values are `postgres`, `mysql`, `mariadb`. | `postgres` |
|
384
|
-
| DB_TTL (npm: db.ttl) | TTL for the code, session and token stores (in seconds). | 300 |
|
385
|
-
| DB_CLEANUP_LIMIT (npm: db.cleanupLimit) | Limit cleanup of TTL entries to this number. | 1000 |
|
386
|
-
| DB_ENCRYPTION_KEY (npm: db.encryptionKey) | To encrypt data at rest specify a 32 character key. | |
|
387
|
-
| PRE_LOADED_CONFIG | If you only need a single tenant or a handful of pre-configured tenants then this config will help you read and load SAML configs. It works well with the mem DB engine so you don't have to configure any external databases for this to work (though it works with those as well). This is a path (absolute or relative) to a directory that contains files organized in the format described in the next section. | |
|
388
|
-
|
389
|
-
## Pre-loaded SAML Configuration
|
390
|
-
|
391
|
-
If PRE_LOADED_CONFIG is set then it should point to a directory with the following structure (example below):-
|
392
|
-
|
393
|
-
```bash
|
394
|
-
boxyhq.js
|
395
|
-
boxyhq.xml
|
396
|
-
anothertenant.js
|
397
|
-
anothertenant.xml
|
398
|
-
```
|
399
|
-
|
400
|
-
The JS file has the following structure:-
|
401
|
-
|
402
|
-
```javascript
|
403
|
-
module.exports = {
|
404
|
-
defaultRedirectUrl: 'http://localhost:3000/login/saml',
|
405
|
-
redirectUrl: '["http://localhost:3000/*", "http://localhost:5000/*"]',
|
406
|
-
tenant: 'boxyhq.com',
|
407
|
-
product: 'demo',
|
408
|
-
};
|
409
|
-
```
|
410
|
-
|
411
|
-
The XML file (should share the name with the .js file) is the raw XML metadata file you receive from your Identity Provider. Please ensure it is saved in the `utf-8` encoding.
|
412
|
-
|
413
|
-
The config and XML above correspond to the `SAML API config` (see below).
|
414
|
-
|
415
|
-
## SAML Login flows
|
416
|
-
|
417
|
-
There are two kinds of SAML login flows - SP-initiated and IdP-initiated. We highly recommend sticking to the SP-initiated flow since it is more secure but Jackson also supports the IdP-initiated flow if you enable it. For an in-depth understanding of SAML and the two flows please refer to Okta's comprehensive guide - <https://developer.okta.com/docs/concepts/saml/>.
|
418
|
-
|
419
|
-
## Contributing
|
420
|
-
|
421
|
-
Thanks for taking the time to contribute! Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are appreciated.
|
422
|
-
|
423
|
-
Please try to create bug reports that are:
|
424
|
-
|
425
|
-
- _Reproducible._ Include steps to reproduce the problem.
|
426
|
-
- _Specific._ Include as much detail as possible: which version, what environment, etc.
|
427
|
-
- _Unique._ Do not duplicate existing opened issues.
|
428
|
-
- _Scoped to a Single Bug._ One bug per report.
|
429
|
-
|
430
|
-
## Support
|
431
|
-
|
432
|
-
Reach out to the maintainer at one of the following places:
|
433
|
-
|
434
|
-
- [GitHub Discussions](https://github.com/boxyhq/jackson/discussions)
|
435
|
-
- [GitHub Issues](https://github.com/boxyhq/jackson/issues)
|
436
|
-
- The email which is located [in GitHub profile](https://github.com/deepakprabhakara)
|
437
|
-
|
438
|
-
## License
|
439
|
-
|
440
|
-
[Apache 2.0 License](https://github.com/boxyhq/jackson/blob/main/LICENSE)
|