mirror of
https://github.com/koush/scrypted.git
synced 2026-09-17 17:20:39 +01:00
server: add option to disable auth
This commit is contained in:
1
server/.vscode/launch.json
vendored
1
server/.vscode/launch.json
vendored
@@ -29,6 +29,7 @@
|
||||
],
|
||||
"env": {
|
||||
// "SCRYPTED_SHARED_WORKER": "true",
|
||||
"SCRYPTED_DISABLE_AUTHENTICATION": "true",
|
||||
"DEBUG": "/scrypted/*",
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user