audit

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2015 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(raw interface{}) error

Hash will hash the given type. This has built-in support for auth, requests, and responses. If it is a type that isn't recognized, then it will be passed through.

The structure is modified in-place.

func HashStructure

func HashStructure(s interface{}, cb HashCallback) (interface{}, error)

HashStructure takes an interface and hashes all the values within the structure. Only _values_ are hashed: keys of objects are not.

For the HashCallback, see the built-in HashCallbacks below.

Types

type Backend

type Backend interface {
	// LogRequest is used to syncronously log a request. This is done after the
	// request is authorized but before the request is executed. The arguments
	// MUST not be modified in anyway. They should be deep copied if this is
	// a possibility.
	LogRequest(*logical.Auth, *logical.Request, error) error

	// LogResponse is used to syncronously log a response. This is done after
	// the request is processed but before the response is sent. The arguments
	// MUST not be modified in anyway. They should be deep copied if this is
	// a possibility.
	LogResponse(*logical.Auth, *logical.Request, *logical.Response, error) error
}

Backend interface must be implemented for an audit mechanism to be made available. Audit backends can be enabled to sink information to different backends such as logs, file, databases, or other external services.

type Factory

type Factory func(map[string]string) (Backend, error)

Factory is the factory function to create an audit backend.

type FormatJSON

type FormatJSON struct{}

FormatJSON is a Formatter implementation that structures data into a JSON format.

func (*FormatJSON) FormatRequest

func (f *FormatJSON) FormatRequest(
	w io.Writer,
	auth *logical.Auth,
	req *logical.Request,
	err error) error

func (*FormatJSON) FormatResponse

func (f *FormatJSON) FormatResponse(
	w io.Writer,
	auth *logical.Auth,
	req *logical.Request,
	resp *logical.Response,
	err error) error

type Formatter

type Formatter interface {
	FormatRequest(io.Writer, *logical.Auth, *logical.Request, error) error
	FormatResponse(io.Writer, *logical.Auth, *logical.Request, *logical.Response, error) error
}

Formatter is an interface that is responsible for formating a request/response into some format. Formatters write their output to an io.Writer.

It is recommended that you pass data through Hash prior to formatting it.

type HashCallback

type HashCallback func(string) (string, error)

HashCallback is the callback called for HashStructure to hash a value.

func HashSHA1

func HashSHA1(salt string) HashCallback

HashSHA1 returns a HashCallback that hashes data with SHA1 and with an optional salt. If salt is a blank string, no salt is used.

type JSONAuth

type JSONAuth struct {
	ClientToken string            `json:"client_token,omitempty"`
	DisplayName string            `json:"display_name"`
	Policies    []string          `json:"policies"`
	Metadata    map[string]string `json:"metadata"`
}

type JSONRequest

type JSONRequest struct {
	Operation  logical.Operation      `json:"operation"`
	Path       string                 `json:"path"`
	Data       map[string]interface{} `json:"data"`
	RemoteAddr string                 `json:"remote_address"`
}

type JSONRequestEntry

type JSONRequestEntry struct {
	Type    string      `json:"type"`
	Auth    JSONAuth    `json:"auth"`
	Request JSONRequest `json:"request"`
	Error   string      `json:"error"`
}

JSONRequest is the structure of a request audit log entry in JSON.

type JSONResponse

type JSONResponse struct {
	Auth     *JSONAuth              `json:"auth,omitempty"`
	Secret   *JSONSecret            `json:"secret,emitempty"`
	Data     map[string]interface{} `json:"data"`
	Redirect string                 `json:"redirect"`
}

type JSONResponseEntry

type JSONResponseEntry struct {
	Type     string       `json:"type"`
	Error    string       `json:"error"`
	Auth     JSONAuth     `json:"auth"`
	Request  JSONRequest  `json:"request"`
	Response JSONResponse `json:"response"`
}

JSONResponseEntry is the structure of a response audit log entry in JSON.

type JSONSecret

type JSONSecret struct {
	LeaseID string `json:"lease_id"`
}

Jump to

Keyboard shortcuts

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