mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 06:45:28 +00:00
Initial schema ideas for logging
This commit is contained in:
@@ -12,6 +12,7 @@ import Token, { IToken } from './token';
|
||||
import User, { IUser } from './user';
|
||||
import UserAction, { IUserAction } from './userAction';
|
||||
import Workspace, { IWorkspace } from './workspace';
|
||||
import Log, { ILog } from './log';
|
||||
|
||||
export {
|
||||
BackupPrivateKey,
|
||||
@@ -41,5 +42,7 @@ export {
|
||||
UserAction,
|
||||
IUserAction,
|
||||
Workspace,
|
||||
IWorkspace
|
||||
IWorkspace,
|
||||
Log,
|
||||
ILog
|
||||
};
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Schema, model, Types } from 'mongoose';
|
||||
|
||||
export interface ILog {
|
||||
_id: Types.ObjectId;
|
||||
user: Types.ObjectId;
|
||||
workspace: Types.ObjectId;
|
||||
event: string;
|
||||
source: string;
|
||||
ipAddress: string;
|
||||
}
|
||||
|
||||
// TODO: need a way to store payload info for each
|
||||
// log
|
||||
|
||||
// which secret is being ref etc.
|
||||
|
||||
const logSchema = new Schema<ILog>(
|
||||
{
|
||||
user: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: 'User'
|
||||
},
|
||||
workspace: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: 'Workspace'
|
||||
},
|
||||
event: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
source: { // should this just be a payload attr?
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
ipAddress: { // store in bytes?
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
}, {
|
||||
timestamps: true
|
||||
}
|
||||
);
|
||||
|
||||
const Log = model<ILog>('Log', logSchema);
|
||||
|
||||
export default Log;
|
||||
Reference in New Issue
Block a user