feat(gaurds): use better smartguards to verify action authorization

This commit is contained in:
2024-05-30 22:49:39 +02:00
parent 6b3fd2ce31
commit 929f250006
18 changed files with 1116 additions and 145 deletions

View File

@@ -1,6 +1,6 @@
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import { logger } from './cloudly.logging.js';
import { logger } from './logger.js';
import type { Cloudly } from './classes.cloudly.js';
/**
@@ -56,19 +56,8 @@ export class CloudlyConfig {
],
});
this.smartjwtInstance = new plugins.smartjwt.SmartJwt();
const kvStore = await this.appData.getKvStore();
const existingJwtKeys: plugins.tsclass.network.IJwtKeypair = await kvStore.readKey('jwtKeys');
if (!existingJwtKeys) {
await this.smartjwtInstance.createNewKeyPair();
const newJwtKeys = this.smartjwtInstance.getKeyPairAsJson();
await kvStore.writeKey('jwtKeys', newJwtKeys);
} else {
this.smartjwtInstance.setKeyPairAsJson(existingJwtKeys);
}
this.data = await kvStore.readAll();
const missingKeys = await this.appData.logMissingKeys();
if (missingKeys.length > 0) {