mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
ef143978e7
closes https://linear.app/tryghost/issue/ENG-721 ref https://linear.app/tryghost/issue/ENG-708 Comments-UI loads `/ghost/admin-frame/` in an iframe to check if a Staff User is authenticated in order to show moderation options. That iframe request loads a HTML page which in turn contains a script that fires off an API request that attempts to fetch the logged-in user details, resulting in a 403 "error" showing up when not authenticated. In the vast majority of cases there will be no staff user authenticated so lots of extra requests and "errors" are seen unnecessarily. - adjusted the `/ghost/auth-frame/` endpoint to check if the request contains an Admin session cookie - if it does, continue as before with rendering the HTML page so the script is loaded - if it doesn't, return an empty 204 response avoiding the script request and subsequent 403-generating API request - eliminates the 403 error being generated for all typical visitor traffic, the error should only be seen when an Admin was previously logged in but their cookie is no longer valid (either from logging out, or going past the 6month validity period)
23 lines
618 B
JavaScript
23 lines
618 B
JavaScript
const fs = require('fs-extra');
|
|
const path = require('path');
|
|
|
|
const adminFiles = [
|
|
'built/admin/index.html',
|
|
'built/admin/assets/ghost.js',
|
|
'built/admin/assets/ghost.css',
|
|
'built/admin/assets/vendor.js',
|
|
'built/admin/assets/vendor.css'
|
|
];
|
|
|
|
module.exports.stubAdminFiles = () => {
|
|
adminFiles.forEach((file) => {
|
|
const filePath = path.resolve(__dirname, '../../core/', file);
|
|
fs.ensureFileSync(filePath);
|
|
});
|
|
};
|
|
|
|
module.exports.stubAuthFrameFiles = (publicPath) => {
|
|
const filePath = path.resolve(publicPath, 'admin-auth/index.html');
|
|
fs.ensureFileSync(filePath);
|
|
};
|