feat(auth): implement JWT-based authentication with admin access controls
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import * as plugins from '../../plugins.js';
|
||||
import type { OpsServer } from '../classes.opsserver.js';
|
||||
import * as interfaces from '../../../ts_interfaces/index.js';
|
||||
import { requireAdminIdentity } from '../helpers/guards.js';
|
||||
|
||||
export class ConfigHandler {
|
||||
public typedrouter = new plugins.typedrequest.TypedRouter();
|
||||
@ -32,12 +33,18 @@ export class ConfigHandler {
|
||||
'updateConfiguration',
|
||||
async (dataArg, toolsArg) => {
|
||||
try {
|
||||
// Require admin access to update configuration
|
||||
await requireAdminIdentity(this.opsServerRef.adminHandler, dataArg);
|
||||
|
||||
const updatedConfig = await this.updateConfiguration(dataArg.section, dataArg.config);
|
||||
return {
|
||||
updated: true,
|
||||
config: updatedConfig,
|
||||
};
|
||||
} catch (error) {
|
||||
if (error instanceof plugins.typedrequest.TypedResponseError) {
|
||||
throw error;
|
||||
}
|
||||
return {
|
||||
updated: false,
|
||||
config: null,
|
||||
|
Reference in New Issue
Block a user