// Ghost SSO adapter: signs exe.dev users in to Ghost Admin as the staff user // with the same email. From https://exe.dev/deploy/ghost // // exe.dev's HTTPS proxy adds X-ExeDev-Email to requests from people signed in // to exe.dev and removes any copy a visitor sends. Caddy lets only the emails // in ~/ghost/caddy/staff-emails reach /ghost. When one of them opens Ghost // Admin, this adapter starts a Ghost session for the staff user with that // email; anyone else sees Ghost's normal sign-in page. Ghost loads it from // content/adapters/sso/exe-dev/index.js when adapters__sso__active=exe-dev. const path = require('node:path'); const {SSOBase} = require(require.resolve('@tryghost/adapter-base-sso', { paths: [path.dirname(require.main.filename)] })); module.exports = class ExeDevSSOAdapter extends SSOBase { async getRequestCredentials(req) { // Only the admin page itself (/ghost/), not its assets or API calls. if (req.path !== '/') { return null; } const email = (req.get('x-exedev-email') || '').trim().toLowerCase(); return email || null; } async getIdentityFromCredentials(email) { return email; } async getUserForIdentity(email) { const user = await this.getUserByEmail(email); if (!user || ['inactive', 'locked'].includes(user.status)) { return null; } return user; } };