Navigation Menu

Skip to content

Commit

Permalink
Added publicAdminApi middleware stack
Browse files Browse the repository at this point in the history
refs #11083

- the `/api/v2/admin/site/` endpoint is "public" and as such was not using the `authAdminApi` middleware stack so it did not act like other API endpoints with protocol or trailing-slash redirects
- adds `publicAdminApi` middleware array and uses it for the `/site/` endpoint in both v2 and canary API versions
  • Loading branch information
kevinansfield committed Sep 10, 2019
1 parent 7dc38e2 commit 58b9aea
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions core/server/web/api/canary/admin/middleware.js
Expand Up @@ -56,3 +56,13 @@ module.exports.authAdminApi = [
shared.middlewares.prettyUrls,
notImplemented
];

/**
* Middleware for public admin endpoints
*/
module.exports.publicAdminApi = [
shared.middlewares.api.cors,
shared.middlewares.urlRedirects.adminRedirect,
shared.middlewares.prettyUrls,
notImplemented
];
2 changes: 1 addition & 1 deletion core/server/web/api/canary/admin/routes.js
Expand Up @@ -19,7 +19,7 @@ module.exports = function apiRoutes() {
const http = apiCanary.http;

// ## Public
router.get('/site', http(apiCanary.site.read));
router.get('/site', mw.publicAdminApi, http(apiCanary.site.read));

// ## Configuration
router.get('/config', mw.authAdminApi, http(apiCanary.config.read));
Expand Down
11 changes: 11 additions & 0 deletions core/server/web/api/v2/admin/middleware.js
Expand Up @@ -55,3 +55,14 @@ module.exports.authAdminApi = [
shared.middlewares.prettyUrls,
notImplemented
];

/**
* Middleware for public admin endpoints
*/
module.exports.publicAdminApi = [
shared.middlewares.api.cors,
shared.middlewares.urlRedirects.adminRedirect,
shared.middlewares.prettyUrls,
notImplemented
];

2 changes: 1 addition & 1 deletion core/server/web/api/v2/admin/routes.js
Expand Up @@ -19,7 +19,7 @@ module.exports = function apiRoutes() {
const http = apiv2.http;

// ## Public
router.get('/site', http(apiv2.site.read));
router.get('/site', mw.publicAdminApi, http(apiv2.site.read));

// ## Configuration
router.get('/config', mw.authAdminApi, http(apiv2.config.read));
Expand Down

0 comments on commit 58b9aea

Please sign in to comment.