Sign-in mode 'key': anyone whose browser holds the curtain pass (opened the key link) may play; tester list still honoured
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -86,11 +86,15 @@ function curtained(req, res, u) {
|
||||
}
|
||||
function admin(req, u) { const k = req.headers['x-admin-key'] || u.searchParams.get('key'); return !!(ADMIN_KEY && k && k.length === ADMIN_KEY.length && crypto.timingSafeEqual(Buffer.from(k), Buffer.from(ADMIN_KEY))); }
|
||||
// who may come through the hand-off
|
||||
function allowed(claims) {
|
||||
// 'key' (Marty, 2026-09-30: "let anyone I send the link to with the key test"): the hand-off is accepted when the
|
||||
// browser carries the curtain pass, i.e. the person opened the tester link with the key first. The list still works too.
|
||||
function hasPass(req) { const m = /(?:^|;\s*)dr\.pass=([^;]+)/.exec(req.headers.cookie || ''); return !!(CURTAIN && m && decodeURIComponent(m[1]) === CURTAIN); }
|
||||
function allowed(claims, req) {
|
||||
const s = ledger.settings(); const mode = String(process.env.DR_SIGNUPS || s.signups || 'testers');
|
||||
if (mode === 'open') return true; if (mode === 'closed') return false;
|
||||
const list = (s.testers || []).map(x => String(x).trim().toLowerCase()).filter(Boolean);
|
||||
return list.includes(String(claims.email || '').toLowerCase()) || list.includes(String(claims.memberId));
|
||||
if (list.includes(String(claims.email || '').toLowerCase()) || list.includes(String(claims.memberId))) return true;
|
||||
return mode === 'key' && req && hasPass(req);
|
||||
}
|
||||
// the IAP -> game callback is signed over the timestamp and the raw body with the shared secret
|
||||
function callbackOk(req, raw) {
|
||||
@@ -119,8 +123,8 @@ const server = http.createServer(async (req, res) => {
|
||||
if (p === '/auth') {
|
||||
const r = sso.verify(u.searchParams.get('t'));
|
||||
if (r.error) return page(res, 400, 'Sign-in did not work', '<p>' + esc(r.error) + '</p><p><a class="btn" href="' + IAP + '/api/my/driprunner">Try again from InstantAdPay</a></p>');
|
||||
if (!allowed(r.claims)) { console.log('hand-off refused: not a tester', r.claims.memberId, r.claims.username || '', String(r.claims.email || '').replace(/^(.).*(@.*)$/, '$1***$2')); notify('refused', { memberId: r.claims.memberId, username: r.claims.username, email: r.claims.email }).catch(() => {}); }
|
||||
if (!allowed(r.claims)) return page(res, 403, 'Not on the tester list yet', '<p>Drip Runner is in a closed trial. Your InstantAdPay account (' + esc(r.claims.username ? '@' + r.claims.username : '#' + r.claims.memberId) + ') is not on the tester list. Ask Marty to add you.</p>');
|
||||
if (!allowed(r.claims, req)) { console.log('hand-off refused: not a tester', r.claims.memberId, r.claims.username || '', String(r.claims.email || '').replace(/^(.).*(@.*)$/, '$1***$2')); notify('refused', { memberId: r.claims.memberId, username: r.claims.username, email: r.claims.email }).catch(() => {}); }
|
||||
if (!allowed(r.claims, req)) { const keyMode = String(process.env.DR_SIGNUPS || ledger.settings().signups) === 'key'; return page(res, 403, keyMode ? 'Open the tester link first' : 'Not on the tester list yet', keyMode ? '<p>Drip Runner is in a closed trial. Open the tester link Marty sent you (the one with the key) in this same browser, then tap Open Drip Runner again. Your InstantAdPay account is ' + esc(r.claims.username ? '@' + r.claims.username : '#' + r.claims.memberId) + '.</p>' : '<p>Drip Runner is in a closed trial. Your InstantAdPay account (' + esc(r.claims.username ? '@' + r.claims.username : '#' + r.claims.memberId) + ') is not on the tester list. Ask Marty to add you.</p>'); }
|
||||
const existing = sso.fromRequest(req);
|
||||
let sid;
|
||||
if (existing && existing.memberId === Number(r.claims.memberId)) { sso.refresh(existing.sid, r.claims); sid = existing.sid; }
|
||||
@@ -164,7 +168,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (p === '/api/admin/settings' && req.method === 'POST') {
|
||||
const { body } = await readBody(req); const patch = {};
|
||||
for (const k of ['usdPerCredit', 'creditsPerVisit', 'poolSharePct', 'usdPerPolFallback', 'dripPol', 'dailyCapPol', 'thresholdPol', 'seedPol', 'lowBalancePol']) if (body[k] != null && body[k] !== '') patch[k] = Number(body[k]);
|
||||
if (body.signups && ['testers', 'open', 'closed'].includes(body.signups)) patch.signups = body.signups;
|
||||
if (body.signups && ['testers', 'key', 'open', 'closed'].includes(body.signups)) patch.signups = body.signups;
|
||||
if (Array.isArray(body.testers)) patch.testers = body.testers.map(x => String(x).trim().toLowerCase()).filter(Boolean).slice(0, 500);
|
||||
if (body.itemPol && typeof body.itemPol === 'object') patch.itemPol = Object.assign({}, ledger.settings().itemPol, body.itemPol);
|
||||
if (body.itemDrips && typeof body.itemDrips === 'object') patch.itemDrips = Object.assign({}, ledger.settings().itemDrips, body.itemDrips);
|
||||
|
||||
Reference in New Issue
Block a user