Skip to content

Commit

Permalink
[audit] extract project_id from token instead user
Browse files Browse the repository at this point in the history
  • Loading branch information
notandy committed Dec 16, 2024
1 parent 241c69d commit a8db699
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions middlewares/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type AuditResource struct {
// Render implements the audittools.EventRenderer interface.
func (a AuditResource) Render() cadf.Resource {
id := ""
attachments := []cadf.Attachment{}
var attachments []cadf.Attachment
for _, routeParam := range a.routeParams {
attachments = append(attachments, cadf.Attachment{
Name: routeParam.Name,
Expand All @@ -97,6 +97,7 @@ func (arw *auditResponseWriter) WriteHeader(code int) {
mr := middleware.MatchedRouteFrom(arw.request)
resource := strings.Split(policy.RuleFromHTTPRequest(arw.request), ":")[1]
user, err := auth.UserForRequest(arw.request)
projectID, _ := auth.ProjectScopeForRequest(arw.request)
if err != nil {
log.Error(err.Error())
return
Expand All @@ -109,7 +110,7 @@ func (arw *auditResponseWriter) WriteHeader(code int) {
ReasonCode: code,
Action: cadf.GetAction(arw.request.Method),
Target: AuditResource{
user.ProjectScopeUUID(),
projectID,
resource,
mr.Params,
},
Expand Down

0 comments on commit a8db699

Please sign in to comment.