Skip to content

Commit

Permalink
Fix audit log for logout all (#65)
Browse files Browse the repository at this point in the history
- [x] Fix audit for logout all

AB#1579962
  • Loading branch information
andersonvcv authored Jan 14, 2025
2 parents 2b0118c + bd198f3 commit b3bf233
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 4 additions & 5 deletions pkg/pics/audit/audit_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ func NewAuditClient(opts *ClientOpts) (*Client, error) {

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

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

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: "110114", Display: "Logout", UserSelected: "All Sessions"}
System: "http://hl7.org/fhir/ValueSet/audit-event-type", Version: "1", Code: "110123", Display: "User Logout All Sessions"}
c.createAuditEntry(ss, appURL, tenantID, "0", "Success", &coding)
}

Expand All @@ -77,8 +77,7 @@ func (c *Client) createAuditEntry(ss *sessions.SessionState, appURL string, tena
auditObject := RootEvent{
ResourceType: "AuditEvent",
Event: &Event{
Type: &Coding{
coding.System, coding.Version, coding.Code, coding.Display, coding.UserSelected},
Type: &Coding{System: coding.System, Version: coding.Version, Code: coding.Code, Display: coding.Display},
Action: "E",
DateTime: time.Now().UTC().Format(time.RFC3339),
Outcome: outcomeCode,
Expand Down
9 changes: 5 additions & 4 deletions pkg/pics/audit/audit_event.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package audit

type Coding struct {
System string `json:"system,omitempty"`
Version string `json:"version,omitempty"`
Code string `json:"code,omitempty"`
Display string `json:"display,omitempty"`
System string `json:"system,omitempty"`
Version string `json:"version,omitempty"`
Code string `json:"code,omitempty"`
Display string `json:"display,omitempty"`
// AuditServer is complaining about UserSelected. Do not use.
UserSelected string `json:"userSelected,omitempty"`
}

Expand Down

0 comments on commit b3bf233

Please sign in to comment.