mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
f22796ff7d
no issue - added ghost-admin client_id to admin - added ghost-admin client_secret to admin - added client.read() api endpoint - added random generation of client_secret to migration - removed addClientSecret method - updated tests
26 lines
776 B
JavaScript
26 lines
776 B
JavaScript
var passport = require('passport'),
|
|
oauthServer,
|
|
|
|
clientAuth;
|
|
|
|
function cacheOauthServer(server) {
|
|
oauthServer = server;
|
|
}
|
|
|
|
clientAuth = {
|
|
// ### Authenticate Client Middleware
|
|
// authenticate client that is asking for an access token
|
|
authenticateClient: function authenticateClient(req, res, next) {
|
|
return passport.authenticate(['oauth2-client-password'], {session: false})(req, res, next);
|
|
},
|
|
|
|
// ### Generate access token Middleware
|
|
// register the oauth2orize middleware for password and refresh token grants
|
|
generateAccessToken: function generateAccessToken(req, res, next) {
|
|
return oauthServer.token()(req, res, next);
|
|
}
|
|
};
|
|
|
|
module.exports = clientAuth;
|
|
module.exports.cacheOauthServer = cacheOauthServer;
|