fix(image registry): start work on image registry

This commit is contained in:
2024-06-01 05:48:57 +02:00
parent 482a6a101c
commit 338ed5ed75
22 changed files with 703 additions and 903 deletions

View File

@@ -30,6 +30,7 @@ export class CloudlyAuthManager {
public async start() {
// lets setup the smartjwtInstance
this.smartjwtInstance = new plugins.smartjwt.SmartJwt();
await this.smartjwtInstance.init();
const kvStore = await this.cloudlyRef.config.appData.getKvStore();
const existingJwtKeys: plugins.tsclass.network.IJwtKeypair = await kvStore.readKey('jwtKeys');
@@ -51,7 +52,7 @@ export class CloudlyAuthManager {
if (!user) {
logger.log('warn', 'login failed');
} else {
jwt = await this.cloudlyRef.config.smartjwtInstance.createJWT({
jwt = await this.smartjwtInstance.createJWT({
userId: user.id,
status: 'loggedIn',
});
@@ -69,8 +70,12 @@ export class CloudlyAuthManager {
public adminJwtGuard = new plugins.smartguard.Guard<{jwt: string}>(async (dataArg) => {
const jwt = dataArg.jwt;
const jwtData: IJwtData = await this.cloudlyRef.config.smartjwtInstance.verifyJWTAndGetData(jwt);
const jwtData: IJwtData = await this.smartjwtInstance.verifyJWTAndGetData(jwt);
const user = await this.CUser.getInstance({id: jwtData.userId});
return user.data.role === 'admin';
const isAdminBool = user.data.role === 'admin';
console.log(`user is admin: ${isAdminBool}`);
return isAdminBool;
}, {
failedHint: 'user is not admin.'
})
}