Migrated the License.ts model -> mongoose-field-encryption
This commit is contained in:
parent
f86683f34c
commit
fc1a6f7605
@ -1,5 +1,6 @@
|
|||||||
import {model, ObjectId, Schema, Types} from "mongoose";
|
import {model, ObjectId, Schema, Types} from "mongoose";
|
||||||
import encrypt from "mongoose-encryption";
|
import { fieldEncryption } from "mongoose-field-encryption";
|
||||||
|
import process from "process";
|
||||||
|
|
||||||
export enum ILicenseMetaType {
|
export enum ILicenseMetaType {
|
||||||
STRING
|
STRING
|
||||||
@ -12,7 +13,7 @@ export interface ILicenseMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ILicense {
|
export interface ILicense {
|
||||||
id: ObjectId,
|
_id: ObjectId,
|
||||||
projectId: ObjectId,
|
projectId: ObjectId,
|
||||||
key: string,
|
key: string,
|
||||||
groups?: string[],
|
groups?: string[],
|
||||||
@ -39,9 +40,10 @@ const LicenseSchema = new Schema<ILicense>({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
LicenseSchema.plugin(encrypt, {
|
LicenseSchema.plugin(fieldEncryption, {
|
||||||
encryptionKey: process.env.ENC_KEY,
|
fields: ["projectId", "key", "groups", "permissions", "meta", "expirationDate"],
|
||||||
signingKey: process.env.SIG_KEY
|
secret: process.env.ENC_KEY,
|
||||||
|
saltGenerator: () => process.env.SIG_KEY
|
||||||
});
|
});
|
||||||
|
|
||||||
export const License = model<ILicense>("licenses", LicenseSchema);
|
export const License = model<ILicense>("licenses", LicenseSchema);
|
Loading…
x
Reference in New Issue
Block a user