mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
35 lines
923 B
JavaScript
35 lines
923 B
JavaScript
|
var prettyURLs = require('../middleware/pretty-urls'),
|
||
|
cors = require('../middleware/api/cors'),
|
||
|
auth = require('../auth');
|
||
|
|
||
|
/**
|
||
|
* Auth Middleware Packages
|
||
|
*
|
||
|
* IMPORTANT
|
||
|
* - cors middleware MUST happen before pretty urls, because otherwise cors header can get lost
|
||
|
* - cors middleware MUST happen after authenticateClient, because authenticateClient reads the trusted domains
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* Authentication for public endpoints
|
||
|
*/
|
||
|
module.exports.authenticatePublic = [
|
||
|
auth.authenticate.authenticateClient,
|
||
|
auth.authenticate.authenticateUser,
|
||
|
// This is a labs-enabled middleware
|
||
|
auth.authorize.requiresAuthorizedUserPublicAPI,
|
||
|
cors,
|
||
|
prettyURLs
|
||
|
];
|
||
|
|
||
|
/**
|
||
|
* Authentication for private endpoints
|
||
|
*/
|
||
|
module.exports.authenticatePrivate = [
|
||
|
auth.authenticate.authenticateClient,
|
||
|
auth.authenticate.authenticateUser,
|
||
|
auth.authorize.requiresAuthorizedUser,
|
||
|
cors,
|
||
|
prettyURLs
|
||
|
];
|