audit

package
v1.21.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuditMark   = "needAudit"
	AuditAction = "auditAction"
)
View Source
const (
	AuditSubjectKey   = "audit_subject"
	AuditExtraDataKey = "audit_extra_datas"
)

Variables

This section is empty.

Functions

func GetAuditData

func GetAuditData(c *gin.Context) map[string]string

func GetExtraAuditData

func GetExtraAuditData(c *gin.Context) (string, map[string]string)

Types

type AuditInterface

type AuditInterface interface {
	AuditProxyFunc(c *gin.Context, p *ProxyObject)
	WebsocketAuditFunc(username string, parents []cache.CommonResourceIface, ip string, proxyobj *ProxyObject) func(cmd string)

	// 重构版本新加的方法
	SetAuditData(c *gin.Context, action, mod, name string)
	SetExtraAuditData(c *gin.Context, kind string, uid uint)
	SetExtraAuditDataByClusterNamespace(c *gin.Context, cluster, namesapce string)
}

type DefaultAuditInstance

type DefaultAuditInstance struct {
	// contains filtered or unexported fields
}

func NewAuditMiddleware

func NewAuditMiddleware(db *gorm.DB, cache *cache.ModelCache, uinterface aaa.ContextUserOperator) *DefaultAuditInstance

func (*DefaultAuditInstance) AuditProxyFunc

func (audit *DefaultAuditInstance) AuditProxyFunc(c *gin.Context, proxyobj *ProxyObject)

func (*DefaultAuditInstance) Consumer

func (audit *DefaultAuditInstance) Consumer(ctx context.Context) error

func (*DefaultAuditInstance) Log

func (audit *DefaultAuditInstance) Log(username, module, tenant, operation, name string, labels map[string]string, raw interface{}, success bool, ip string)

func (*DefaultAuditInstance) LogIt

func (audit *DefaultAuditInstance) LogIt(c *gin.Context, t time.Time, raw gin.H)

func (*DefaultAuditInstance) Middleware

func (audit *DefaultAuditInstance) Middleware() func(c *gin.Context)

func (*DefaultAuditInstance) SaveAuditLog

func (audit *DefaultAuditInstance) SaveAuditLog(c *gin.Context)

func (*DefaultAuditInstance) SetAuditData

func (audit *DefaultAuditInstance) SetAuditData(c *gin.Context, action, module, name string)

SetAuditData 设置上下文的审计数据

func (*DefaultAuditInstance) SetExtraAuditData

func (audit *DefaultAuditInstance) SetExtraAuditData(c *gin.Context, kind string, uid uint)

SetExtraAuditData 设置上下文的审计数据 的系统环境信息(租户,项目,环境)

func (*DefaultAuditInstance) SetExtraAuditDataByClusterNamespace

func (audit *DefaultAuditInstance) SetExtraAuditDataByClusterNamespace(c *gin.Context, cluster, namespace string)

SetExtraAuditDataByClusterNamespace 根据集群namesapce设置上下文的审计数据 的系统环境信息(租户,项目,环境)

func (*DefaultAuditInstance) WebsocketAuditFunc

func (audit *DefaultAuditInstance) WebsocketAuditFunc(username string, parents []cache.CommonResourceIface, ip string, proxyobj *ProxyObject) func(cmd string)

type ProxyObject

type ProxyObject struct {
	NamespacedScoped bool
	Cluster          string
	Namespace        string
	Name             string
	Group            string
	Version          string
	Resource         string
	Action           string
}

func (*ProxyObject) InNamespace

func (p *ProxyObject) InNamespace() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL