@boxyhq/saml-jackson 0.3.0-beta.247 → 0.3.0-beta.248
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +27 -27
- package/package.json +1 -1
package/README.md
CHANGED
@@ -4,28 +4,28 @@ SAML service [SAML in a box from BoxyHQ]
|
|
4
4
|
|
5
5
|
You need someone like Jules Winnfield to save you from the vagaries of SAML login.
|
6
6
|
|
7
|
-
|
7
|
+
## Source code visualizer
|
8
8
|
|
9
9
|
[CodeSee codebase visualizer](https://app.codesee.io/maps/public/53e91640-23b5-11ec-a724-79d7dd589517)
|
10
10
|
|
11
|
-
|
11
|
+
## Getting Started
|
12
12
|
|
13
13
|
There are two ways to use this repo.
|
14
14
|
|
15
|
-
- As an npm library
|
15
|
+
- As an npm library
|
16
16
|
- As a separate service
|
17
17
|
|
18
18
|
## Install as an npm library
|
19
19
|
|
20
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
21
|
|
22
|
-
```
|
22
|
+
```bash
|
23
23
|
npm i @boxyhq/saml-jackson
|
24
24
|
```
|
25
25
|
|
26
26
|
### Add Express Routes
|
27
27
|
|
28
|
-
```
|
28
|
+
```javascript
|
29
29
|
// express
|
30
30
|
const express = require('express');
|
31
31
|
const router = express.Router();
|
@@ -169,11 +169,11 @@ app.use('/sso', router);
|
|
169
169
|
|
170
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
171
|
|
172
|
-
```
|
172
|
+
```bash
|
173
173
|
docker run -p 5000:5000 -p 6000:6000 boxyhq/jackson:78e9099d
|
174
174
|
```
|
175
175
|
|
176
|
-
Refer to https://github.com/boxyhq/jackson#configuration for the full configuration.
|
176
|
+
Refer to <https://github.com/boxyhq/jackson#configuration> for the full configuration.
|
177
177
|
|
178
178
|
Kubernetes and docker-compose deployment files will be coming soon.
|
179
179
|
|
@@ -187,12 +187,12 @@ Please follow the instructions [here](https://docs.google.com/document/d/1fk---Z
|
|
187
187
|
|
188
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
189
|
|
190
|
-
| SAML Attribute
|
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 |
|
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
196
|
|
197
197
|
### 2. SAML config API
|
198
198
|
|
@@ -202,7 +202,7 @@ You will need to provide a place in the UI for your customers (The account setti
|
|
202
202
|
|
203
203
|
The following API call sets up the configuration in Jackson:
|
204
204
|
|
205
|
-
```
|
205
|
+
```bash
|
206
206
|
curl --location --request POST 'http://localhost:6000/api/v1/saml/config' \
|
207
207
|
--header 'Authorization: Api-Key <Jackson API Key>' \
|
208
208
|
--header 'Content-Type: application/x-www-form-urlencoded' \
|
@@ -225,7 +225,7 @@ The response returns a JSON with `client_id` and `client_secret` that can be sto
|
|
225
225
|
|
226
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
227
|
|
228
|
-
```
|
228
|
+
```bash
|
229
229
|
curl -G --location 'http://localhost:6000/api/v1/saml/config' \
|
230
230
|
--header 'Authorization: Api-Key <Jackson API Key>' \
|
231
231
|
--header 'Content-Type: application/x-www-form-urlencoded' \
|
@@ -233,7 +233,7 @@ curl -G --location 'http://localhost:6000/api/v1/saml/config' \
|
|
233
233
|
--data-urlencode 'product=demo'
|
234
234
|
```
|
235
235
|
|
236
|
-
```
|
236
|
+
```bash
|
237
237
|
curl -G --location 'http://localhost:6000/api/v1/saml/config' \
|
238
238
|
--header 'Authorization: Api-Key <Jackson API Key>' \
|
239
239
|
--header 'Content-Type: application/x-www-form-urlencoded' \
|
@@ -246,7 +246,7 @@ The response returns a JSON with `provider` indicating the domain of your Identi
|
|
246
246
|
|
247
247
|
This endpoint can be used to delete an existing IdP metadata.
|
248
248
|
|
249
|
-
```
|
249
|
+
```bash
|
250
250
|
curl -X "DELETE" --location 'http://localhost:6000/api/v1/saml/config' \
|
251
251
|
--header 'Authorization: Api-Key <Jackson API Key>' \
|
252
252
|
--header 'Content-Type: application/x-www-form-urlencoded' \
|
@@ -254,7 +254,7 @@ curl -X "DELETE" --location 'http://localhost:6000/api/v1/saml/config' \
|
|
254
254
|
--data-urlencode 'product=demo'
|
255
255
|
```
|
256
256
|
|
257
|
-
```
|
257
|
+
```bash
|
258
258
|
curl -X "DELETE" --location 'http://localhost:6000/api/v1/saml/config' \
|
259
259
|
--header 'Authorization: Api-Key <Jackson API Key>' \
|
260
260
|
--header 'Content-Type: application/x-www-form-urlencoded' \
|
@@ -266,7 +266,7 @@ curl -X "DELETE" --location 'http://localhost:6000/api/v1/saml/config' \
|
|
266
266
|
|
267
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
268
|
|
269
|
-
Jackson also supports the PKCE authorization flow (https://oauth.net/2/pkce
|
269
|
+
Jackson also supports the PKCE authorization flow (<https://oauth.net/2/pkce/>), so you can protect your SPAs.
|
270
270
|
|
271
271
|
If for any reason you need to implement the flow on your own, the steps are outlined below:
|
272
272
|
|
@@ -274,7 +274,7 @@ If for any reason you need to implement the flow on your own, the steps are outl
|
|
274
274
|
|
275
275
|
The OAuth flow begins with redirecting your user to the `authorize` URL:
|
276
276
|
|
277
|
-
```
|
277
|
+
```bash
|
278
278
|
https://localhost:5000/oauth/authorize
|
279
279
|
?response_type=code&provider=saml
|
280
280
|
&client_id=<clientID or tenant and product query params as described in the SAML config API section above>
|
@@ -295,7 +295,7 @@ After successful authorization, the user is redirected back to the `redirect_uri
|
|
295
295
|
|
296
296
|
The code can then be exchanged for a token by making the following request:
|
297
297
|
|
298
|
-
```
|
298
|
+
```bash
|
299
299
|
curl --request POST \
|
300
300
|
--url 'http://localhost:5000/oauth/token' \
|
301
301
|
--header 'content-type: application/x-www-form-urlencoded' \
|
@@ -313,7 +313,7 @@ curl --request POST \
|
|
313
313
|
|
314
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
315
|
|
316
|
-
```
|
316
|
+
```json
|
317
317
|
{
|
318
318
|
"access_token": <access token>,
|
319
319
|
"token_type": "bearer",
|
@@ -325,7 +325,7 @@ If everything goes well you should receive a JSON response that includes the acc
|
|
325
325
|
|
326
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
327
|
|
328
|
-
```
|
328
|
+
```bash
|
329
329
|
curl --request GET \
|
330
330
|
--url https://localhost:5000/oauth/userinfo \
|
331
331
|
--header 'authorization: Bearer <access token>' \
|
@@ -334,7 +334,7 @@ curl --request GET \
|
|
334
334
|
|
335
335
|
If everything goes well you should receive a JSON response with the user's profile:
|
336
336
|
|
337
|
-
```
|
337
|
+
```json
|
338
338
|
{
|
339
339
|
"id": <id from the Identity Provider>,
|
340
340
|
"email": "sjackson@coolstartup.com",
|
@@ -390,7 +390,7 @@ The following options are supported and will have to be configured during deploy
|
|
390
390
|
|
391
391
|
If PRE_LOADED_CONFIG is set then it should point to a directory with the following structure (example below):-
|
392
392
|
|
393
|
-
```
|
393
|
+
```bash
|
394
394
|
boxyhq.js
|
395
395
|
boxyhq.xml
|
396
396
|
anothertenant.js
|
@@ -399,7 +399,7 @@ anothertenant.xml
|
|
399
399
|
|
400
400
|
The JS file has the following structure:-
|
401
401
|
|
402
|
-
```
|
402
|
+
```javascript
|
403
403
|
module.exports = {
|
404
404
|
defaultRedirectUrl: 'http://localhost:3000/login/saml',
|
405
405
|
redirectUrl: '["http://localhost:3000/*", "http://localhost:5000/*"]',
|
@@ -414,7 +414,7 @@ The config and XML above correspond to the `SAML API config` (see below).
|
|
414
414
|
|
415
415
|
## SAML Login flows
|
416
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
|
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
418
|
|
419
419
|
## Contributing
|
420
420
|
|