From 9359582a8dc6e85462b87d9980b1829b620aa8c2 Mon Sep 17 00:00:00 2001 From: SylvainLap Date: Wed, 4 Nov 2015 17:31:07 +0100 Subject: [PATCH] remove passport, added grant --- lib/configuration/hooks/defaultHooks.js | 2 +- lib/configuration/hooks/grant/index.js | 46 +++++++++++++++++++++++++ package.json | 4 +-- 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 lib/configuration/hooks/grant/index.js diff --git a/lib/configuration/hooks/defaultHooks.js b/lib/configuration/hooks/defaultHooks.js index ad55a2e5e4..aabc94889c 100755 --- a/lib/configuration/hooks/defaultHooks.js +++ b/lib/configuration/hooks/defaultHooks.js @@ -11,7 +11,7 @@ module.exports = { waterline: true, bodyParser: true, session: true, - passport: true, + grant: true, proxy: true, ssl: true, ip: true, diff --git a/lib/configuration/hooks/grant/index.js b/lib/configuration/hooks/grant/index.js new file mode 100644 index 0000000000..0413415a37 --- /dev/null +++ b/lib/configuration/hooks/grant/index.js @@ -0,0 +1,46 @@ +'use strict'; + +/** + * Module dependencies + */ + +// Public node modules. +const _ = require('lodash'); +const Grant = require('grant-koa'); + +/** + * Grant hook + */ + +module.exports = function (strapi) { + const hook = { + + /** + * Default options + */ + + defaults: { + grant: {} + }, + + /** + * Initialize the hook + */ + + initialize: function (cb) { + const serverConf = { + server: { + protocol: strapi.config.ssl ? 'https' : 'http', + host: strapi.config.host + ':' + strapi.config.port + } + }; + _.defaultsDeep(strapi.config.grant, serverConf); + const grant = new Grant(strapi.config.grant); + strapi.app.use(strapi.middlewares.mount(grant)); + + cb(); + } + }; + + return hook; +}; diff --git a/package.json b/package.json index 2947f29094..b1fe851c9c 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "api", "auth", "framework", + "grant", "graphql", "koa", "koajs", @@ -15,7 +16,6 @@ "oauth", "oauth2", "orm", - "passport", "realtime", "rest", "restful", @@ -36,6 +36,7 @@ "commander": "^2.9.0", "consolidate": "^0.13.1", "fs-extra": "^0.24.0", + "grant-koa": "^3.5.2", "graphql": "^0.4.9", "include-all": "^0.1.6", "json-stringify-safe": "^5.0.1", @@ -52,7 +53,6 @@ "koa-locale": "^1.0.0", "koa-lusca": "^2.1.0", "koa-mount": "^1.3.0", - "koa-passport": "^1.2.0", "koa-proxy": "^0.4.1", "koa-response-time": "^1.0.2", "koa-router": "^5.2.3",