forked from openiap/opencore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudit.ts
More file actions
84 lines (83 loc) · 3.46 KB
/
Copy pathAudit.ts
File metadata and controls
84 lines (83 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { Base, Rights } from "./base";
import { Config } from "./Config";
import { TokenUser } from "./TokenUser";
export class Audit {
public static LoginSuccess(user: TokenUser, type: string, provider: string, remoteip: string, clientagent: string, clientversion: string) {
var log: Singin = new Singin();
log.addRight(user._id, user.name, [Rights.read]);
log.remoteip = remoteip;
log.success = true;
log.type = type;
log.provider = provider;
log.userid = user._id;
log.name = user.name;
log.username = user.username;
log.clientagent = clientagent;
log.clientversion = clientversion;
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken())
.catch((error) => console.error("failed InsertOne in LoginSuccess: " + error));
}
public static ImpersonateSuccess(user: TokenUser, impostor: TokenUser, clientagent: string, clientversion: string) {
var log: Singin = new Singin();
log.addRight(user._id, user.name, [Rights.read]);
log.addRight(impostor._id, impostor.name, [Rights.read]);
log.success = true;
log.type = "impersonate";
log.userid = user._id;
log.name = user.name;
log.username = user.username;
log.impostoruserid = impostor._id;
log.impostorname = impostor.name;
log.impostorusername = impostor.username;
log.clientagent = clientagent;
log.clientversion = clientversion;
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken())
.catch((error) => console.error("failed InsertOne in ImpersonateSuccess: " + error));
}
public static ImpersonateFailed(user: TokenUser, impostor: TokenUser, clientagent: string, clientversion: string) {
var log: Singin = new Singin();
log.addRight(user._id, user.name, [Rights.read]);
log.addRight(impostor._id, impostor.name, [Rights.read]);
log.success = false;
log.type = "impersonate";
log.userid = user._id;
log.name = user.name;
log.username = user.username;
log.impostoruserid = impostor._id;
log.impostorname = impostor.name;
log.clientagent = clientagent;
log.clientversion = clientversion;
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken())
.catch((error) => console.error("failed InsertOne in ImpersonateFailed: " + error));
}
public static LoginFailed(username: string, type: string, provider: string, remoteip: string, clientagent: string, clientversion: string) {
var log: Singin = new Singin();
log._acl
log.remoteip = remoteip;
log.success = false;
log.type = type;
log.provider = provider;
log.username = username;
log.clientagent = clientagent;
log.clientversion = clientversion;
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken())
.catch((error) => console.error("failed InsertOne in LoginFailed: " + error));
}
}
export class Singin extends Base {
public success: boolean;
public type: string;
public provider: string;
public userid: string;
public username: string;
public remoteip: string;
public impostoruserid: string;
public impostorname: string;
public impostorusername: string;
public clientagent: string;
public clientversion: string;
constructor() {
super();
this._type = "signin";
}
}