@boxyhq/saml-jackson
Advanced tools
Comparing version 0.1.1 to 0.1.2-beta.73
{ | ||
"name": "@boxyhq/saml-jackson", | ||
"version": "0.1.1", | ||
"version": "0.1.2-beta.73", | ||
"license": "Apache 2.0", | ||
@@ -5,0 +5,0 @@ "description": "SAML 2.0 service", |
@@ -17,17 +17,37 @@ # SAML Jackson (not fiction anymore) | ||
``` | ||
// express | ||
const express = require('express'); | ||
const router = express.Router(); | ||
const cors = require('cors'); // needed if you are calling the token userinfo endpoints from the frontend | ||
// Set the required options | ||
const opts = { | ||
externalUrl: 'https://my-cool-app.com', | ||
samlAudience: 'https://my-cool-app.com', | ||
samlPath: '/sso/oauth/saml', | ||
db: { | ||
engine: 'mongo', | ||
url: 'mongodb://localhost:27017/my-cool-app', | ||
} | ||
}; | ||
const ret = await require('@boxyhq/saml-jackson')(opts); | ||
const apiController = ret.apiController; | ||
const oauthController = ret.oauthController; | ||
// Please note that the initialization of @boxyhq/saml-jackson is async, you cannot run it at the top level | ||
// Run this in a function where you initialise the express server. | ||
asyn function init() { | ||
const ret = await require('@boxyhq/saml-jackson')(opts); | ||
const apiController = ret.apiController; | ||
const oauthController = ret.oauthController; | ||
} | ||
// express.js middlewares needed | ||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: true })); | ||
// express.js middlewares needed to parse json and x-www-form-urlencoded | ||
router.use(express.json()); | ||
router.use(express.urlencoded({ extended: true })); | ||
// SAML config API | ||
app.post('/api/v1/saml/config', async (req, res) => { | ||
// 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. | ||
router.post('/api/v1/saml/config', async (req, res) => { | ||
try { | ||
// apply your authentication flow (or ensure this route has passed through your auth middleware) | ||
... | ||
// only when properly authenticated, call the config function | ||
res.json(await apiController.config(req.body)); | ||
@@ -42,3 +62,3 @@ } catch (err) { | ||
// OAuth 2.0 flow | ||
app.get('/oauth/authorize', async (req, res) => { | ||
router.get('/oauth/authorize', async (req, res) => { | ||
try { | ||
@@ -51,3 +71,3 @@ await oauthController.authorize(req, res); | ||
app.post('/oauth/saml', async (req, res) => { | ||
router.post('/oauth/saml', async (req, res) => { | ||
try { | ||
@@ -60,3 +80,3 @@ await oauthController.samlResponse(req, res); | ||
app.post('/oauth/token', cors(), async (req, res) => { | ||
router.post('/oauth/token', cors(), async (req, res) => { | ||
try { | ||
@@ -69,3 +89,3 @@ await oauthController.token(req, res); | ||
app.get('/oauth/userinfo', cors(), async (req, res) => { | ||
router.get('/oauth/userinfo', cors(), async (req, res) => { | ||
try { | ||
@@ -77,2 +97,6 @@ await oauthController.userInfo(req, res); | ||
}); | ||
// set the router | ||
app.user('/sso', router); | ||
``` | ||
@@ -104,5 +128,4 @@ You can also refer to our usage of the library internally in the Jackson service here - https://github.com/boxyhq/jackson/blob/main/src/jackson.js | ||
- DB_TYPE (npm: db.type): Only needed when DB_ENGINE is `sql`. Supported values are `postgres`, `cockroachdb`, `mysql`, `mariadb`. Defaults to `postgres` | ||
- 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 direct that contains files organized in the format described in the next section. | ||
- PRE_LOADED_CONFIG: If you only need a single tenant or a handful of pre-configured tenants then this config will help you red 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 direct that contains files organized in the format described in the next section. | ||
# Pre-loaded SAML Configuration | ||
@@ -109,0 +132,0 @@ If PRE_LOADED_CONFIG is set then it should point to a directory with the following structure (example below):- |
@@ -15,3 +15,2 @@ const EntitySchema = require('typeorm').EntitySchema; | ||
key: { | ||
primary: true, | ||
type: 'varchar', | ||
@@ -18,0 +17,0 @@ }, |
@@ -30,3 +30,2 @@ const DB = require('./db/db.js'); | ||
opts = defaultOpts(opts); | ||
console.log('opts=', opts); | ||
@@ -33,0 +32,0 @@ const db = await DB.new(opts.db); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74061
247
1405