Skip to content

Commit

Permalink
Add audit log
Browse files Browse the repository at this point in the history
  • Loading branch information
sailinder committed Dec 19, 2024
1 parent 9ce484b commit b1bfa56
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pkg/pics/audit/audit_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,31 @@ func NewAuditClient(opts *ClientOpts) (*Client, error) {
}

func (c *Client) CreateSuccessfulLoginAuditEntry(ss *sessions.SessionState, appURL string, tenantID string) {
c.createAuditEntry(ss, appURL, tenantID, "0", "Success")
coding := Coding{
System: "http://hl7.org/fhir/ValueSet/audit-event-type", Version: "1", Code: "110114", Display: "Sailinder Test Image", UserSelected: ""}
c.createAuditEntry(ss, appURL, tenantID, "0", "Success", &coding)
}

func (c *Client) CreateFailedLoginAuditEntry(ss *sessions.SessionState, appURL string, tenantID string, errorDesc string) {
c.createAuditEntry(ss, appURL, tenantID, "1", errorDesc)
coding := Coding{
System: "http://hl7.org/fhir/ValueSet/audit-event-type", Version: "1", Code: "110114", Display: "User Authentication", UserSelected: ""}
c.createAuditEntry(ss, appURL, tenantID, "1", errorDesc, &coding)
}

func (c *Client) createAuditEntry(ss *sessions.SessionState, appURL string, tenantID string, outcomeCode string, outcomeDesc string) {
func (c *Client) CreateSuccessfulLogoutAuditEntry(ss *sessions.SessionState, appURL string, tenantID string) {
coding := Coding{
System: "http://hl7.org/fhir/ValueSet/audit-event-type", Version: "1", Code: "110123", Display: "Logout", UserSelected: "All Sessions"}
c.createAuditEntry(ss, appURL, tenantID, "0", "Success", &coding)
}
func (c *Client) createAuditEntry(ss *sessions.SessionState, appURL string, tenantID string, outcomeCode string, outcomeDesc string, coding *Coding) {
if !c.enabled {
return
}
auditObject := RootEvent{
ResourceType: "AuditEvent",
Event: &Event{
Type: &Coding{
System: "http://hl7.org/fhir/ValueSet/audit-event-type", Version: "1", Code: "110114", Display: "User Authentication"},
coding.System, coding.Version, coding.Code, coding.Display, coding.UserSelected},
Action: "E",
DateTime: time.Now().UTC().Format(time.RFC3339),
Outcome: outcomeCode,
Expand Down

0 comments on commit b1bfa56

Please sign in to comment.