server: add option to disable auth

This commit is contained in:
Koushik Dutta
2022-11-03 09:11:07 -07:00
parent 575dc79725
commit 2aa07a32e9
2 changed files with 16 additions and 0 deletions

View File

@@ -29,6 +29,7 @@
],
"env": {
// "SCRYPTED_SHARED_WORKER": "true",
"SCRYPTED_DISABLE_AUTHENTICATION": "true",
"DEBUG": "/scrypted/*",
}
},

View File

@@ -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)