Encrypted the Group.ts model

This commit is contained in:
Mathias Wagner 2023-08-02 17:14:11 +02:00
parent efdd4ab336
commit 7d18e773f9
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -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 IGroup {
projectId: ObjectId,
@ -9,7 +11,7 @@ export interface IGroup {
const GroupSchema = new Schema<IGroup>({
projectId: {
type: Types.ObjectId,
type: String,
required: true
},
name: {
@ -23,4 +25,10 @@ const GroupSchema = new Schema<IGroup>({
permissions: [String]
});
GroupSchema.plugin(fieldEncryption, {
fields: ["projectId", "name", "description", "permissions"],
secret: process.env.ENC_KEY,
saltGenerator: () => process.env.SIG_KEY
});
export const Group = model<IGroup>("groups", GroupSchema);