Added encryption to the Permission.ts model
This commit is contained in:
parent
07723ec54f
commit
72014cadf6
@ -1,4 +1,6 @@
|
||||
import {model, ObjectId, Schema, Types} from "mongoose";
|
||||
import {model, ObjectId, Schema} from "mongoose";
|
||||
import { fieldEncryption } from "mongoose-field-encryption";
|
||||
import process from "process";
|
||||
|
||||
export interface IPermission {
|
||||
projectId: ObjectId,
|
||||
@ -8,7 +10,7 @@ export interface IPermission {
|
||||
|
||||
const PermissionSchema = new Schema<IPermission>({
|
||||
projectId: {
|
||||
type: Types.ObjectId,
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
permission: {
|
||||
@ -21,4 +23,10 @@ const PermissionSchema = new Schema<IPermission>({
|
||||
}
|
||||
});
|
||||
|
||||
PermissionSchema.plugin(fieldEncryption, {
|
||||
fields: ["projectId", "permission", "description"],
|
||||
secret: process.env.ENC_KEY,
|
||||
saltGenerator: () => process.env.SIG_KEY
|
||||
});
|
||||
|
||||
export const Permission = model<IPermission>("permissions", PermissionSchema);
|
Loading…
x
Reference in New Issue
Block a user