func (b *Backend) LogRequest(auth *logical.Auth, req *logical.Request) error { if !b.logRaw { // Copy the structures cp, err := copystructure.Copy(auth) if err != nil { return err } auth = cp.(*logical.Auth) cp, err = copystructure.Copy(req) if err != nil { return err } req = cp.(*logical.Request) // Hash any sensitive information if err := audit.Hash(auth); err != nil { return err } if err := audit.Hash(req); err != nil { return err } } // Encode the entry as JSON var buf bytes.Buffer var format audit.FormatJSON if err := format.FormatRequest(&buf, auth, req); err != nil { return err } // Write out to syslog _, err := b.logger.Write(buf.Bytes()) return err }
func (b *Backend) LogRequest(auth *logical.Auth, req *logical.Request) error { if err := b.open(); err != nil { return err } if !b.LogRaw { // Copy the structures cp, err := copystructure.Copy(auth) if err != nil { return err } auth = cp.(*logical.Auth) cp, err = copystructure.Copy(req) if err != nil { return err } req = cp.(*logical.Request) // Hash any sensitive information if err := audit.Hash(auth); err != nil { return err } if err := audit.Hash(req); err != nil { return err } } var format audit.FormatJSON return format.FormatRequest(b.f, auth, req) }
func (b *Backend) LogRequest(auth *logical.Auth, req *logical.Request, outerErr error) error { if !b.logRaw { // Before we copy the structure we must nil out some data // otherwise we will cause reflection to panic and die if req.Connection != nil && req.Connection.ConnState != nil { origReq := req origState := req.Connection.ConnState req.Connection.ConnState = nil defer func() { origReq.Connection.ConnState = origState }() } // Copy the structures cp, err := copystructure.Copy(auth) if err != nil { return err } auth = cp.(*logical.Auth) cp, err = copystructure.Copy(req) if err != nil { return err } req = cp.(*logical.Request) // Hash any sensitive information if err := audit.Hash(auth); err != nil { return err } if err := audit.Hash(req); err != nil { return err } } // Encode the entry as JSON var buf bytes.Buffer var format audit.FormatJSON if err := format.FormatRequest(&buf, auth, req, outerErr); err != nil { return err } // Write out to syslog _, err := b.logger.Write(buf.Bytes()) return err }
func (b *Backend) LogRequest(auth *logical.Auth, req *logical.Request, outerErr error) error { if err := b.open(); err != nil { return err } if !b.logRaw { // Before we copy the structure we must nil out some data // otherwise we will cause reflection to panic and die if req.Connection != nil && req.Connection.ConnState != nil { origReq := req origState := req.Connection.ConnState req.Connection.ConnState = nil defer func() { origReq.Connection.ConnState = origState }() } // Copy the structures cp, err := copystructure.Copy(auth) if err != nil { return err } auth = cp.(*logical.Auth) cp, err = copystructure.Copy(req) if err != nil { return err } req = cp.(*logical.Request) // Hash any sensitive information if err := audit.Hash(b.salt, auth); err != nil { return err } if err := audit.Hash(b.salt, req); err != nil { return err } } var format audit.FormatJSON return format.FormatRequest(b.f, auth, req, outerErr) }