Skip to content

Commit 16c8a75

Browse files
committed
Block more operations when not authenticated
1 parent 5ac4fa1 commit 16c8a75

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Server/MarkerEditor.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { GetServerState, ServerState, SetServerState } from './ServerState.js';
2121
import { registerPostCommands, runPostCommand } from './PostCommands.js';
2222
import { sendJsonError, sendJsonSuccess } from './ServerHelpers.js';
2323
import { ServerEventHandler, ServerEvents } from './ServerEvents.js';
24+
import { User, UserAuthentication } from './Authentication/Authentication.js';
2425
import { AuthDatabase } from './Authentication/AuthDatabase.js';
2526
import { DatabaseImportExport } from './ImportExport.js';
2627
import FirstRunConfig from './FirstRunConfig.js';
@@ -33,7 +34,6 @@ import { ServerConfigState } from '../Shared/ServerConfig.js';
3334
import ServerError from './ServerError.js';
3435
import { default as Sqlite3Store } from './Authentication/SqliteSessionStore.js';
3536
import { ThumbnailManager } from './ThumbnailManager.js';
36-
import { UserAuthentication } from './Authentication/Authentication.js';
3737

3838
/**
3939
* @typedef {Object} CLIArguments
@@ -509,7 +509,12 @@ async function handlePost(req, res) {
509509
try {
510510
if (Object.prototype.hasOwnProperty.call(ServerActionMap, endpoint)
511511
&& typeof ServerActionMap[endpoint] === 'function') {
512-
await ServerActionMap[endpoint](res);
512+
if (!Config.useAuth() || User.signedIn(req)) {
513+
await ServerActionMap[endpoint](res);
514+
} else {
515+
sendJsonError(res, new ServerError('Not authorized', 401));
516+
}
517+
513518
return;
514519
}
515520

0 commit comments

Comments
 (0)