forked from raystack/frontier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: logs activity of shield entities
- Loading branch information
1 parent
81b8706
commit 6ec8f98
Showing
29 changed files
with
748 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package activity | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/goto/salt/audit" | ||
) | ||
|
||
type Repository interface { | ||
Insert(ctx context.Context, log *audit.Log) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package activity | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/goto/salt/audit" | ||
"github.com/goto/shield/config" | ||
) | ||
|
||
type Service struct { | ||
repository Repository | ||
} | ||
|
||
func NewService(repository Repository) *Service { | ||
return &Service{ | ||
repository: repository, | ||
} | ||
} | ||
|
||
func (s Service) Log(ctx context.Context, action string, actor string, data map[string]string) error { | ||
metadata := map[string]string{ | ||
"app_name": "shield", | ||
"app_version": config.Version, | ||
} | ||
|
||
log := &audit.Log{ | ||
Timestamp: time.Now(), | ||
Action: action, | ||
Data: data, | ||
Actor: actor, | ||
Metadata: metadata, | ||
} | ||
|
||
return s.repository.Insert(ctx, log) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.