Documentation
¶
Overview ¶
Package log_options is what an endpoint's audit lines say about the person they concern, and what the service mounting the endpoint adds to them. It is the one place the endpoints take both from, so that a service configures every endpoint it mounts alike.
Index ¶
- Constants
- type Config
- func (c *Config) Apply(options ...Option)
- func (c *Config) Attrs(attrs ...any) []any
- func (c *Config) EmailAddressHash(emailAddress string) string
- func (c *Config) Event(categories []string, types []string, action string, outcome string, ...) slog.Attr
- func (c *Config) User(id string, emailAddress string) *schema.User
- func (c *Config) UserAttrs(id string, emailAddress string) []any
- type Option
Constants ¶
const ( CategoryAuthentication = "authentication" CategoryIam = "iam" TypeStart = "start" TypeEnd = "end" TypeCreation = "creation" OutcomeSuccess = "success" OutcomeFailure = "failure" OutcomeUnknown = "unknown" )
The ECS vocabulary the endpoints' events are given in: event.category, event.type and event.outcome take values from fixed lists, which these name. An authentication is a start (or, a revocation, an end) whatever became of it, the outcome saying which -- so that one query over the type and the outcome finds every refusal, by whichever route it came.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// EmailAddressHasher names a person's address by its keyed hash, which matches across entries
// and can be looked up by hashing an address someone gives. With none, no hash is written.
EmailAddressHasher *pii_hasher.Hasher
// LogEmailAddress writes the address itself beside the id and the hash. Off by default: the id
// names an account to whoever can look it up, and the hash an address to whoever has it.
LogEmailAddress bool
// EventAttrs are added inside the event group of every audit line, after the endpoint's own
// fields: a service's dataset, for one, which its log router tells the audit trail by. They are
// given to the endpoint rather than passed as an event group of LogAttrs because whether two
// groups of one name are merged is the handler's to decide: utils_go's context logger merges
// them, slog's own JSON handler writes the key twice, and the library cannot know which a
// service logs through.
EventAttrs []slog.Attr
// LogAttrs are added at the top level of every audit line.
LogAttrs []slog.Attr
}
func (*Config) Apply ¶
Apply sets options on a config that exists already, as on an endpoint's Log once it is made: a service that makes its endpoints in one place and has its hasher in another adds the hasher without replacing what was set before. Unlike New, it keeps what it is not given.
func (*Config) EmailAddressHash ¶
EmailAddressHash is the keyed hash of emailAddress, or empty without a hasher or an address.
func (*Config) Event ¶
func (c *Config) Event(categories []string, types []string, action string, outcome string, reason string) slog.Attr
Event is the event group of an audit line: the ECS categories, types, action and outcome the endpoint gives it, the reason when there is one, and then the EventAttrs.
func (*Config) User ¶
User names the same person for the request log, which takes its user from the HTTP context.
type Option ¶
type Option func(*Config)
func WithEmailAddressHasher ¶
func WithEmailAddressHasher(emailAddressHasher *pii_hasher.Hasher) Option
func WithEventAttrs ¶
WithEventAttrs adds to the event group of every audit line. They should not repeat the endpoint's own fields -- category, type, action, outcome and reason: a handler that merges groups lets the later value replace the endpoint's, and one that does not writes the key twice.
func WithLogAttrs ¶
func WithLogEmailAddress ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package log_options_testing captures the lines an endpoint logs, through the logger the services log through, for the endpoints' tests of what their audit lines say.
|
Package log_options_testing captures the lines an endpoint logs, through the logger the services log through, for the endpoints' tests of what their audit lines say. |