✨ API wrapper of record audit log
This commit is contained in:
parent
17db3c4998
commit
4de0c4c969
30
pkg/hyper/audit.go
Normal file
30
pkg/hyper/audit.go
Normal file
@ -0,0 +1,30 @@
|
||||
package hyper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (v *HyperConn) RecordAuditLog(user uint, action, target, ip, ua string) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
||||
defer cancel()
|
||||
|
||||
in, err := v.GetServiceGrpcConn(ServiceTypeAuthProvider)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = proto.NewEventRecorderClient(in).RecordEvent(ctx, &proto.RecordEventRequest{
|
||||
UserId: uint64(user),
|
||||
Action: action,
|
||||
Target: target,
|
||||
Ip: ip,
|
||||
UserAgent: ua,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user