1616 *
1717 */
1818
19- package authz
19+ // Package audit contains interfaces for audit logging during authorization.
20+ package audit
2021
2122import (
2223 "encoding/json"
@@ -27,38 +28,38 @@ import (
2728// to facilitate thread-safe reading/writing operations.
2829type loggerBuilderRegistry struct {
2930 mu sync.Mutex
30- builders map [string ]AuditLoggerBuilder
31+ builders map [string ]LoggerBuilder
3132}
3233
3334var (
3435 registry = loggerBuilderRegistry {
35- builders : make (map [string ]AuditLoggerBuilder ),
36+ builders : make (map [string ]LoggerBuilder ),
3637 }
3738)
3839
39- // RegisterAuditLoggerBuilder registers the builder in a global map
40+ // RegisterLoggerBuilder registers the builder in a global map
4041// using b.Name() as the key.
4142//
4243// This should only be called during initialization time (i.e. in an init()
4344// function). If multiple builders are registered with the same name,
4445// the one registered last will take effect.
45- func RegisterAuditLoggerBuilder (b AuditLoggerBuilder ) {
46+ func RegisterLoggerBuilder (b LoggerBuilder ) {
4647 registry .mu .Lock ()
4748 defer registry .mu .Unlock ()
4849 registry .builders [b .Name ()] = b
4950}
5051
51- // GetAuditLoggerBuilder returns a builder with the given name.
52+ // GetLoggerBuilder returns a builder with the given name.
5253// It returns nil if the builder is not found in the registry.
53- func GetAuditLoggerBuilder (name string ) AuditLoggerBuilder {
54+ func GetLoggerBuilder (name string ) LoggerBuilder {
5455 registry .mu .Lock ()
5556 defer registry .mu .Unlock ()
5657 return registry .builders [name ]
5758}
5859
59- // AuditEvent contains information passed to the audit logger as part of an
60+ // Event contains information passed to the audit logger as part of an
6061// audit logging event.
61- type AuditEvent struct {
62+ type Event struct {
6263 // FullMethodName is the full method name of the audited RPC, in the format
6364 // of "/pkg.Service/Method". For example, "/helloworld.Greeter/SayHello".
6465 FullMethodName string
@@ -74,14 +75,14 @@ type AuditEvent struct {
7475 Authorized bool
7576}
7677
77- // AuditLoggerConfig represents an opaque data structure holding an audit
78+ // LoggerConfig represents an opaque data structure holding an audit
7879// logger configuration. Concrete types representing configuration of specific
7980// audit loggers must embed this interface to implement it.
80- type AuditLoggerConfig interface {
81- auditLoggerConfig ()
81+ type LoggerConfig interface {
82+ loggerConfig ()
8283}
8384
84- // AuditLogger is the interface to be implemented by audit loggers.
85+ // Logger is the interface to be implemented by audit loggers.
8586//
8687// An audit logger is a logger instance that can be configured via the
8788// authorization policy API or xDS HTTP RBAC filters. When the authorization
@@ -91,35 +92,35 @@ type AuditLoggerConfig interface {
9192// TODO(lwge): Change the link to the merged gRFC once it's ready.
9293// Please refer to https://github.com/grpc/proposal/pull/346 for more details
9394// about audit logging.
94- type AuditLogger interface {
95+ type Logger interface {
9596 // Log performs audit logging for the provided audit event.
9697 //
9798 // This method is invoked in the RPC path and therefore implementations
9899 // must not block.
99- Log (* AuditEvent )
100+ Log (* Event )
100101}
101102
102- // AuditLoggerBuilder is the interface to be implemented by audit logger
103+ // LoggerBuilder is the interface to be implemented by audit logger
103104// builders that are used at runtime to configure and instantiate audit loggers.
104105//
105106// Users who want to implement their own audit logging logic should
106- // implement this interface, along with the AuditLogger interface, and register
107- // it by calling RegisterAuditLoggerBuilder () at init time.
107+ // implement this interface, along with the Logger interface, and register
108+ // it by calling RegisterLoggerBuilder () at init time.
108109//
109110// TODO(lwge): Change the link to the merged gRFC once it's ready.
110111// Please refer to https://github.com/grpc/proposal/pull/346 for more details
111112// about audit logging.
112- type AuditLoggerBuilder interface {
113- // ParseAuditLoggerConfig parses the given JSON bytes into a structured
113+ type LoggerBuilder interface {
114+ // ParseLoggerConfig parses the given JSON bytes into a structured
114115 // logger config this builder can use to build an audit logger.
115- ParseAuditLoggerConfig (config json.RawMessage ) (AuditLoggerConfig , error )
116+ ParseLoggerConfig (config json.RawMessage ) (LoggerConfig , error )
116117 // Build builds an audit logger with the given logger config.
117118 // This will only be called with valid configs returned from
118- // ParseAuditLoggerConfig () and any runtime issues such as failing to
119+ // ParseLoggerConfig () and any runtime issues such as failing to
119120 // create a file should be handled by the logger implementation instead of
120121 // failing the logger instantiation. So implementers need to make sure it
121122 // can return a logger without error at this stage.
122- Build (AuditLoggerConfig ) AuditLogger
123+ Build (LoggerConfig ) Logger
123124 // Name returns the name of logger built by this builder.
124125 // This is used to register and pick the builder.
125126 Name () string
0 commit comments