Commit Graph
44 Commits
Author SHA1 Message Date
Krzysztof Skrzętnicki bb9140f1ae Decouple GetKerberosClient() from DB session context (#52179) 2025-02-14 17:13:54 +00:00
Krzysztof Skrzętnicki d8fe3a6d8f Extract Kerberos functionality from SQL Server engine (#51352)
* Extract Kerberos functionality from SQL Server engine

* fix typo, add missing trace.Wrap()
2025-02-12 11:11:16 +00:00
rosstimothy af2db96d59 Convert lib/srv/db to use slog (#50116) 2024-12-16 20:25:51 +00:00
Krzysztof SkrzętnickiandSTeve Huang 18fe621bab convert db lib to use slog, part 2 (#43849)
* Switch Engine, EngineConfig and SessionContext to slog.

* Apply suggestions from code review

Co-authored-by: STeve (Xin) Huang <xin.huang@goteleport.com>

* fix some lint issues, restore trace logs,

* fix tests

* fix some more lint issues

---------

Co-authored-by: STeve (Xin) Huang <xin.huang@goteleport.com>
2024-07-04 15:22:30 +00:00
Forrest 1742c46887 readonly shared cluster configs (#43422) 2024-07-02 17:23:13 +00:00
STeve (Xin) Huang a9d02f6122 convert db lib to use slog, part 1 (#43382)
* convert db lib to use slog, part 1

* fix typo

* fix build and add deprecate

* fix lint
2024-07-02 15:35:18 +00:00
Krzysztof Skrzętnicki 18b6b7f11a Database Access: decouple Auth from Session (#43344)
* Database Access: decouple Auth from Session, add SessionAuth wrapper, share CloudClients instance, update tests.

* Drop `SessionAuth` interface, shift usages over to updated `Auth` interface

* Drop unused params
2024-06-26 06:03:14 +00:00
rosstimothy 1aec5414f1 Replace constants from trace with equivalents defined in teleport (#39307)
* Remove logging from circuit breaker

The logging is never output, and if it was would be very verbose.
Instead of dropping the level down to trace the logger is removed
entirely.

* Add constants from trace library

The logging functionality in trace is being removed in an upcoming
release. To prepare the logging component keys are copied from trace
into teleport.

* Convert trace.ComponentFields to teleport.ComponentFields

* Replace trace.Component with teleport.ComponentKey

* Replace trace logging constants
2024-03-14 13:04:29 +00:00
Gavin Frazar 5c568bbe07 split database CA into server/client CAs (#35949)
* split database CA into server/client CAs

* update migration logging
    * include auth component in migrations
    * debug log when skipping db client ca migration
* update tctl auth sign for cockroachdb
* update tctl auth sign for oracle
* set ExtKeyUsage for DB certs
    * clientAuth for DB Client CA
    * serverAuth for DB Server CA
* inject filter for pre-v14.3.1 clients
* inject a filter instead of dropping events in grpcserver
* add DatabaseClientCA type

* debug log when skipping filter injection

* update CA filter injection version check func name and doc
2024-01-14 23:53:24 +00:00
Tim Buckley f7e97d0c3c Add bot field to certificates and various usage events (#35881)
* Add bot field to certificates and various usage events

This adds a new certificate extension field, `teleport-bot`, to
certificates issued to Machine ID bot users that can definitively
identify certificates as having been issued to a bot user.

Additionally, this uses the new `Bot` identity flag to mark certain
usage events as originating from bot users. As such, it includes a
protobuf update from Cloud [1], which pulled in some small additional
(mostly comment) changes.

[1] https://github.com/gravitational/cloud/pull/7060

* Small bot flag plumbing fixes

* Convert bot flag to BotName and UserKind enum

This makes a few changes to the bot tagging approach:
* The bot name is embedded in the cert rather than just true/false
* UserKind is included in events rather than just a bot flag, to
  allow for an unspecified value for older client nodes.

* Add a quick unit test for bot cert extensions

* Fix outdated grpc

* Include bot flag on initial certs

* Log a warning and override user kind for usage records if they differ

* Fix several unit tests; add a bot metadata test case

* Fix unit tests with UserKind zero value

* Rename SSH cert extension to use standard format

Renames the `teleport-bot` extension to `bot-name@goteleport.com`,
to better follow SSH cert extension naming conventions.

* Attempt to improve unspecified userkind aggregating logic
2024-01-04 23:07:08 +00:00
fheinecke b178b8b732 Updated Teleport codebase to AGPL3 license (#35259)
Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
2023-12-01 17:48:14 +00:00
rosstimothy d5a796c056 Enable testify lint (#34222)
Updates our golangci-lint configuration to enable testifylint and
fixes all issues found.

Bump e ref to include gravitational/teleport.e#2567
2023-11-06 20:38:38 +00:00
Gabriel Corado 86358c14e4 Support auditing chunked SQL Server packets (#29228)
* feat(sqlserver): parse chunked packets

* chore(sqlserver): fix typo

* fix(sqlserver): assert final packet on flag bit

* refactor(sqlserver): return chunks data using Bytes()

* chore(sqlserver): update comparision logic

* chore(sqlserver): typo
2023-08-09 03:18:52 +00:00
Krzysztof Skrzętnicki 32ccd98af0 Add metrics for database service (#28150)
* Add DB metrics

* Address PR feedback.

- rename functions to better indicate their intent
- drop unused clock field
- cache labels
- add godoc

* Refactoring to return concrete types instead of interfaces.
2023-08-07 08:25:40 +00:00
Mike Jensen b90e362e7b Fuzz Test Improvements (#29918)
* Added Fuzz Seeds for services/fuzz_test.go

* Fuzzing improvements for `lib/srv/db` fuzzing

This ensures that all fuzzing under `lib/srv/db` has the following:
* Good seeds that provide basic levels of coverage
* Enabled in OSS-Fuzz

* Fuzzing improvements for `lib/sshutils`

This improves the fuzzing in `lib/sshutils/sftp/parse_test.go` and `lib/sshutils/x11/display_test.go`.
Seeds were added and additional local fuzzing was done.  In addition these functions are now enabled in `oss-fuzz`.
2023-08-02 18:55:55 +00:00
Marek Smoliński d4805cc428 Extend DatabaseSessionStart posthog event (#28931) 2023-07-14 07:15:02 +00:00
Gavin Frazar 2496e37124 update database and kube name validation (#28841)
* update database name validation

* move name validation into DatabaseV3 CheckAndSetDefaults
* replace use of DNS1305 name validation
  * remove 63 char length restriction
  * remove lowercase restriction

* fix failing tests

* update more tests

* update CHANGELOG.md
* explain breaking change to database discovery name validation
2023-07-12 21:24:25 +00:00
Andrew LeFevre d4b3afe9a1 split recording session events and emitting audit events (#27873)
* split recording session events and emitting audit events

This is a refactor of how audit events and session events are handled.
Previously, all events were emitted using the same interface,
api/types/events.Emitter. This lead to event-related code getting to be
very confusing, as it was often unclear whether a given event was being
recorded as a session event and emitted as an audit event, or only one
of the two. Naturally, a few bugs arose due to this.

To simplify event handling, a separate interface for recording session
events has been created. A api/types/events.Recorder should now only be
used to record session events, and an Emitter should now only be used to
emit audit events. Instead of using a confusing TeeWriter that would
transparently (and confusingly, given its name) hold a few event types
that only belonged in session recordings, callers can now explicitly
record and/or emit an event when necessary.

* ensure e build won't break
2023-07-11 19:53:33 +00:00
Gabriel Corado a80497d287 tests(sqlserver): fix test variable length packet fixture (#25658) 2023-05-15 23:37:23 +00:00
Gavin Frazar a190a2e0fa support cross-account AWS db access (#23680)
* AWS cross account database access

* update aws cloud clients, engines, metadata
* base64 encode semaphor
* update tests for refactored cloud clients

* use TTL cache for AWS sessions
2023-04-08 00:01:56 +00:00
Gabriel Corado 428701b8ca Support SQL Server through RDS Proxy (#23600)
* feat(db): add support for sqlserver rds proxy

* chore(gomod): go mod tidy

* chore(gomod): go mod tidy

* chore(sqlserver): move params keys to constants
2023-04-04 15:15:14 +00:00
Gabriel Corado a4785855c5 Set CRL LDAP path based on certificate authority type (#23814)
* refactor(windows): use CA type to define CRL path

* chore(windows): update updateCRL comment

* chore(windows): fix imports
2023-03-31 15:20:55 +00:00
Gabriel Corado f3dc81b14a SQL Server PKINIT authentication update (#22792)
* feat: fix and improve kinit sqlserver

* test(kinit): use a temp dir for writing ccache files

* chore(services): update validation error message

* chore(kinit): improve field description

* refactor(kinit): use CA from certificate generation

* refactor(kinit): remove unused function

* chore(kinit): remove leftover file
2023-03-28 15:04:29 +00:00
Steven Martin b4e1f39742 Fix DB Query always return success false in audit log (#23270)
* Initialize db query to status of success true

* Init event status as success true
2023-03-18 14:01:30 +00:00
rosstimothy 95d6d0fee1 Migrate GetCertAuthority to gRPC (#22624)
The HTTP client created by `auth.NewClient` has an idle timeout of
30s and each instance periodically gets cert authorities in
`TeleportProcess.syncRotationStateCycle`. If there has been no
activity when the ticker expires then the request will result in a
brand new connection to Auth to be established. This can cause a
spikes in open file descriptors on the Proxy when there are a large
number of instances connected via a tunnel.

To prevent periodic dialing when retrieving cert authorities the
endpoint has been migrated to the new Trust gRPC service. For now
only the get endpoint has been migrated but the rest of the CRUD
operations for cert authorities should be migrated from the HTTP
api to the gRPC service as well.
2023-03-10 14:32:34 +00:00
Anton Miniailo 3633c6181e Add secure client IP propagation throughout teleport (#21080) 2023-02-28 20:38:12 +00:00
Gabriel Corado 22dc3dfb2e Update SQL Server library (#21065)
* refactor(sqlserver): change to microsoft fork

* chore(gomod): update mssqldb dep

* test(sqlserver): add server on parsing PLP RPC packets

* fix(db): change mssql import

* chore(gomod): update go-mssqldb reference

* test(protocol): use fuzz arguments

* chore: code review suggestions

* test(sqlserver): add missing protocols attribute
2023-02-10 11:39:11 +00:00
STeve (Xin) Huang 704a514742 AWS IAM role matching for database users (#20610)
* Add database user matching logic for databases require AWS IAM role

* Fix UT

* fix lint/typo

* fix typo in error message

* reduce bool return
2023-02-03 18:33:56 +00:00
Alan Parra 11d58e25c7 Refactor AccessMFAParams and MFAParams to allow additional data (#20300)
Refactor `services.AccessMFAParams` and the accompanying `MFAParams` methods so
they may be extended to carry additional data (eg, information required to
perform device trust checks).

This PR refactors existing code without adding any new functionality, so it may
be backported to older branches to alleviate eventual conflicts. Follow up
changes will take advantage of it to add support for device trust.

Related to gravitational/teleport.e#514.
2023-01-17 20:02:38 +00:00
Isaiah Becker-Mayer 9a06ca404c Windows Certificate SID Mapping (#19340) 2022-12-22 21:54:50 +00:00
STeve (Xin) Huang 6c858c09ee Register database engines directly from db lib (#19279) 2022-12-18 05:59:47 +00:00
Christopher Cooper 9c2192ebb6 Prepare sql server kinit authorization (#18299) 2022-12-06 22:55:20 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Gabriel Corado 65c022893d Add Azure AD user managed identity authentication for SQL server (#17142) 2022-10-21 15:06:51 +00:00
Brian Joerger 2654add770 RequireMFAType (#16034)
Replace role/authPref RequireSessionMFA (bool) with RequireMFAType
(string).

  - Add new RequireMFAType constant values with custom boolean marshalling.

  - Add RequireMFAType to role and auth preference and deprecate
RequireSessionMFA.

  - Add session-mfa override login when hardware_key_touch is enforced.

  - Add protobuf enum for RequireMFAType.

  - Add support for proto enums in protoc-gen-crd and update Kubernetes
Operator manifests.
2022-09-22 20:30:32 +00:00
Trent Clarke 9514a313c3 Break DB integration tests out into their own package (#16133)
Making all of our integration tests run in entirely parallel requires
a large engineering effort to enforce test isolation and remove all race
conditions between tests.

A lower-effort alternative may be to split apart the various test suites
into their own Go packages, and test those packages in parallel, even if
the tests inside are still executed serially. Auditing the test suites
for races on system-level resources (e.g. files, ports) is much easier
than chasing down every p[ossible race in the testing system.

This patch acts as a trial run, breaking a fairly well-defined and
self-contained test suite out into its own package. Note that the goal of
this change is not necessarily to shave minutes off the build (although
that would be nice), but to act as an illustration of how other, less
well-formed test suites might be broken apart.

See-Also: #12421
See-Also: #14408
2022-09-07 11:04:35 +10:00
Gabriel Corado a3a65e863b TLS routing ping for database protocols (#14887) 2022-08-26 16:42:23 +00:00
Norbert SzeteiandZac Bergquist 0ab9716aac oss fuzz integration (#13473)
* Update api/types/fuzz_test.go
* do not fail if the file is missing
* missing go-118-fuzz-build fix

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-06-18 21:28:07 +00:00
Marek Smoliński 3d938e8a2d SQLServer add suport for SSMS client (#13372) 2022-06-13 11:53:29 +00:00
Marek Smoliński d1db890a10 SQLServer event add missing conversion (#13094) 2022-06-03 10:31:41 +00:00
Marek Smoliński 4602b485ef SQLServer audit events (#12521) 2022-05-31 14:43:40 +02:00
Roman Tkachenko 97c0b5cb83 Add auth'd tunnel mode to tsh proxy db command (#11720) 2022-04-07 18:33:39 +00:00
Jakub Nyckowski 24cafecd87 Fix panic in MSSQL when Login7 package is invalid (#10452) 2022-03-01 03:35:56 +00:00
Roman Tkachenko 41899806fd Add SQL Server support for database access (#10097) 2022-02-17 02:20:33 +00:00