// xyOps runs this once for each new SSO session. The plugin owns JWT validation. const { run } = require('/opt/xyops/guide/node_modules/@pixlcore/xyplug-sso-aws-alb'); (async function() { try { let input = ''; for await (const chunk of process.stdin) input += chunk; const hook = JSON.parse(input); const headers = await run(hook); // Optional claims may be missing. Always replace every mapped header, // including an empty group, so only the verified identity reaches xyOps. for (const key of Object.values(hook.config.header_map)) { const name = key.toLowerCase(); if (!Object.hasOwn(headers, name)) headers[name] = ''; } // Require an administrator-assigned role before creating a xyOps session. if (!['setup', 'operator'].includes(headers['x-forwarded-groups'])) throw new Error('No assigned xyOps role'); process.stdout.write(JSON.stringify({ xy: 1, code: 0, headers }) + '\n'); } catch (err) { process.stdout.write(JSON.stringify({ xy: 1, code: 1, description: String(err.message) }) + '\n'); } })();