diff --git a/server/.vscode/launch.json b/server/.vscode/launch.json index 39b7f5060..fd580a4ff 100644 --- a/server/.vscode/launch.json +++ b/server/.vscode/launch.json @@ -29,6 +29,7 @@ ], "env": { // "SCRYPTED_SHARED_WORKER": "true", + "SCRYPTED_DISABLE_AUTHENTICATION": "true", "DEBUG": "/scrypted/*", } }, diff --git a/server/src/scrypted-server-main.ts b/server/src/scrypted-server-main.ts index cbc1190e2..416d6fb22 100644 --- a/server/src/scrypted-server-main.ts +++ b/server/src/scrypted-server-main.ts @@ -179,6 +179,12 @@ async function start() { } app.use(async (req, res, next) => { + if (process.env.SCRYPTED_DISABLE_AUTHENTICATION === 'true') { + res.locals.username = 'anonymous'; + next(); + return; + } + // this is a trap for all auth. // only basic auth will fail with 401. it is up to the endpoints to manage // lack of login from cookie auth. @@ -538,6 +544,15 @@ async function start() { return; } + if (process.env.SCRYPTED_DISABLE_AUTHENTICATION === 'true') { + res.send({ + expiration: ONE_DAY_MILLISECONDS, + username: 'anonymous', + addresses, + }) + return; + } + try { const login_user_token = getSignedLoginUserTokenRawValue(req); if (!login_user_token)