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