Commit graph

18 commits

Author SHA1 Message Date
Brian Joerger 7bff7c41bd
Remove API aliases (#6983) 2021-06-04 13:29:31 -07:00
Joel Wejdenstål 33315dc139
set correct auditlog instead of discard (#6431)
Co-authored-by: Russell Jones <russjones@users.noreply.github.com>
2021-04-16 23:16:44 +02:00
Roman Tkachenko 8230d6e436
Capture postgres extended protocol messages in audit log (#6303) 2021-04-14 13:39:59 -07:00
Joel Wejdenstål 28c7163e13
Always set an AuditLog (#6326) 2021-04-07 11:47:02 +02:00
Andrej Tokarčík f4e13ea8f3 Don't defer Close calls on writable files 2021-03-01 22:14:10 +01:00
Andrew Lytvynov fc1c1dbd14 Move all utils.InitLoggerForTests calls to TestMain
This prevents data races between changing the standard logger and it
acutally being used.
2021-02-23 18:04:55 -08:00
Jane Quintero 0d35e26968 feedback changes
lint
2021-02-19 17:29:11 -08:00
Jane Quintero f3f87489ce remove pointer from GetUploadMetadata in MultipartUploader interface + PR feedback
pass uploadmetadata by value

update test

use DiscardAuditLog in tests

update e and use uploadHandler as UploadMetadataGetter
2021-02-19 17:29:11 -08:00
Jane Quintero 1ca978bc43 make only protostreamer implement getuploadmetadata 2021-02-19 17:29:11 -08:00
Jane Quintero 9b26bfe821 emit session upload event 2021-02-19 17:29:11 -08:00
Sasha Klizhentas 7b8bfe4f60 Backoff on network errors and mark corrupted records.
Uploader retries slower on network errors and picks the pace
after any upload has succeeded.

Records that were corrupted, will never get uploaded.

The uploader will create streams indefinitely, clogging the auth server
with streams. Now uploader writes marker for bad session uploads
and does not attempt to reupload.
2020-10-21 14:33:04 -07:00
Andrew Lytvynov 566b7cc457 RFD 1: user testify/require instead of testify/assert
`require` is a sister package to `assert` that terminates the test on
failure. `assert` records the failure but lets the test proceed, which
is un-intuitive.

Also update all existing tests to match.
2020-10-16 00:15:25 +00:00
Sasha Klizhentas c1b1c6a154 Improves logging and error handling in filesessions.
Adds chaos tests for async file upload.

Fixes playback for legacy sessions stored unpacked on disk
2020-10-06 13:41:17 -07:00
Sasha Klizhentas d160507430 Session streaming
This commit introduces GRPC API for streaming sessions.

It adds structured events and sync streaming
that avoids storing events on disk.

You can find design in rfd/0002-streaming.md RFD.
2020-09-28 23:08:56 -07:00
Andrew Lytvynov 935375a00d Fix staticcheck findings in lib/events/...
Fixed findings:
```
lib/events/test/suite.go:88:2: SA4006: this value of `err` is never used (staticcheck)
	err := s.Log.EmitAuditEvent(events.UserLocalLogin, events.EventFields{
	^
lib/events/auditlog_test.go:98:2: SA4006: this value of `err` is never used (staticcheck)
	fileHandler, err := filesessions.NewHandler(filesessions.Config{
	^
lib/events/auditlog_test.go:121:2: SA4006: this value of `err` is never used (staticcheck)
	err = os.MkdirAll(filepath.Join(uploadDir, "upload", "sessions", defaults.Namespace), 0755)
	^
lib/events/auditlog_test.go:224:2: SA4006: this value of `err` is never used (staticcheck)
	fileHandler, err := filesessions.NewHandler(filesessions.Config{
	^
lib/events/auditlog_test.go:246:2: SA4006: this value of `err` is never used (staticcheck)
	err = os.MkdirAll(filepath.Join(uploadDir, "upload", "sessions", defaults.Namespace), 0755)
	^
lib/events/auditlog_test.go:381:2: SA4006: this value of `err` is never used (staticcheck)
	fileHandler, err := filesessions.NewHandler(filesessions.Config{
	^
lib/events/auditlog_test.go:403:2: SA4006: this value of `err` is never used (staticcheck)
	fileHandler, err := filesessions.NewHandler(filesessions.Config{
	^
lib/events/auditlog_test.go:431:2: SA4006: this value of `err` is never used (staticcheck)
	err := os.MkdirAll(filepath.Join(uploadDir, "upload", "sessions", defaults.Namespace), 0755)
	^
lib/events/filesessions/fileuploader.go:84:2: SA4006: this value of `err` is never used (staticcheck)
	_, err := os.Stat(filepath.Dir(path))
	^
lib/events/dynamoevents/dynamoevents.go:352:2: SA4006: this value of `err` is never used (staticcheck)
	attributeValues, err := dynamodbattribute.MarshalMap(attributes)
	^
lib/events/dynamoevents/dynamoevents.go:405:2: SA4006: this value of `err` is never used (staticcheck)
	attributeValues, err := dynamodbattribute.MarshalMap(attributes)
	^
```
2020-04-28 15:17:44 +00:00
Andrew Lytvynov f8661edea3 Clean up dead code across the codebase
Spring cleaning!
A very mechanical cleanup using several linters (unused, deadcode,
structcheck). Build and tests still pass so no behavior should be
affected.
2020-04-09 21:10:12 +00:00
Sasha Klizhentas f699bd1a76 Fix error handling in audit sessions and events.
This commit fixes #2084
2018-07-18 15:54:51 -07:00
Sasha Klizhentas bad1b0498d External events and sessions storage.
Updates #1755

Design
------

This commit adds support for pluggable events and
sessions recordings and adds several plugins.

In case if external sessions recording storage
is used, nodes or proxies depending on configuration
store the session recordings locally and
then upload the recordings in the background.

Non-print session events are always sent to the
remote auth server as usual.

In case if remote events storage is used, auth
servers download recordings from it during playbacks.

DynamoDB event backend
----------------------

Transient DynamoDB backend is added for events
storage. Events are stored with default TTL of 1 year.

External lambda functions should be used
to forward events from DynamoDB.

Parameter audit_table_name in storage section
turns on dynamodb backend.

The table will be auto created.

S3 sessions backend
-------------------

If audit_sessions_uri is specified to s3://bucket-name
node or proxy depending on recording mode
will start uploading the recorded sessions
to the bucket.

If the bucket does not exist, teleport will
attempt to create a bucket with versioning and encryption
turned on by default.

Teleport will turn on bucket-side encryption for the tarballs
using aws:kms key.

File sessions backend
---------------------

If audit_sessions_uri is specified to file:///folder
teleport will start writing tarballs to this folder instead
of sending records to the file server.

This is helpful for plugin writers who can use fuse or NFS
mounted storage to handle the data.

Working dynamic configuration.
2018-03-15 12:42:43 -07:00