diff --git a/internal/bsr/bsr.go b/internal/bsr/bsr.go index ae069e13fc..beed5b4919 100644 --- a/internal/bsr/bsr.go +++ b/internal/bsr/bsr.go @@ -58,6 +58,8 @@ func NewSession(ctx context.Context, meta *SessionMeta, f storage.FS, keys *kms. return nil, fmt.Errorf("%s: missing session user: %w", op, ErrInvalidParameter) case is.Nil(meta.Target): return nil, fmt.Errorf("%s: missing session target: %w", op, ErrInvalidParameter) + case is.Nil(meta.Worker): + return nil, fmt.Errorf("%s: missing session worker: %w", op, ErrInvalidParameter) case is.Nil(f): return nil, fmt.Errorf("%s: missing storage fs: %w", op, ErrInvalidParameter) case is.Nil(keys): diff --git a/internal/bsr/meta.go b/internal/bsr/meta.go index 4b9662f479..3aba4fff0e 100644 --- a/internal/bsr/meta.go +++ b/internal/bsr/meta.go @@ -163,6 +163,29 @@ func (t Target) writeMeta(ctx context.Context, c *container) error { return nil } +// Worker contains information about the worker used to record this session +type Worker struct { + PublicId string + Version string + Sha string +} + +func (w Worker) writeMeta(ctx context.Context, c *container) error { + _, err := c.WriteMeta(ctx, "worker_publicId", w.PublicId) + if err != nil { + return err + } + _, err = c.WriteMeta(ctx, "worker_version", w.Version) + if err != nil { + return err + } + _, err = c.WriteMeta(ctx, "worker_sha", w.Sha) + if err != nil { + return err + } + return nil +} + // StaticHostCatalog contains information about the static host catalog for this session type StaticHostCatalog struct { PublicId string @@ -702,6 +725,7 @@ type SessionMeta struct { Protocol Protocol User *User Target *Target + Worker *Worker // StaticHost and DynamicHost are mutually exclusive StaticHost *StaticHost DynamicHost *DynamicHost @@ -727,6 +751,10 @@ func (s SessionMeta) writeMeta(ctx context.Context, c *container) error { if err != nil { return err } + err = s.Worker.writeMeta(ctx, c) + if err != nil { + return err + } if s.StaticHost != nil { err = s.StaticHost.writeMeta(ctx, c) if err != nil { diff --git a/internal/bsr/testdata/TestBsr/session_multiplexed/closed/SHA256SUM b/internal/bsr/testdata/TestBsr/session_multiplexed/closed/SHA256SUM index bd71cde18d..56820fd861 100644 --- a/internal/bsr/testdata/TestBsr/session_multiplexed/closed/SHA256SUM +++ b/internal/bsr/testdata/TestBsr/session_multiplexed/closed/SHA256SUM @@ -3,5 +3,5 @@ .* wrappedPrivKey .* pubKeyBsrSignature.sign .* pubKeySelfSignature.sign -f9c1b3593565129acbb7f62cd2397b527c86183bb552c5de4c27560b58602ddc session.meta +04fb6e9ce96c411f2ab185167d8b69a6d66d894d8620bf347e4003afe270f662 session.meta e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 session.summary diff --git a/internal/bsr/testdata/TestBsr/session_multiplexed/closed/session.meta b/internal/bsr/testdata/TestBsr/session_multiplexed/closed/session.meta index 4a522ce70b..2f5a530109 100644 --- a/internal/bsr/testdata/TestBsr/session_multiplexed/closed/session.meta +++ b/internal/bsr/testdata/TestBsr/session_multiplexed/closed/session.meta @@ -10,6 +10,9 @@ target_projectId: proj123 target_defaultPort: 0 target_sessionMaxSeconds: 0 target_sessionConnectionLimit: 0 +worker_publicId: w_12345 +worker_version: 0.25.5 +worker_sha: beepboopgitsha staticHost_publicId: host123 staticHostCatalog_publicId: staticcat123 staticHostCatalog_projectId: proj123 diff --git a/internal/bsr/testdata/TestBsr/session_multiplexed/opened/session.meta b/internal/bsr/testdata/TestBsr/session_multiplexed/opened/session.meta index 5ee3fb1ad8..26cccf86c3 100644 --- a/internal/bsr/testdata/TestBsr/session_multiplexed/opened/session.meta +++ b/internal/bsr/testdata/TestBsr/session_multiplexed/opened/session.meta @@ -10,6 +10,9 @@ target_projectId: proj123 target_defaultPort: 0 target_sessionMaxSeconds: 0 target_sessionConnectionLimit: 0 +worker_publicId: w_12345 +worker_version: 0.25.5 +worker_sha: beepboopgitsha staticHost_publicId: host123 staticHostCatalog_publicId: staticcat123 staticHostCatalog_projectId: proj123 diff --git a/internal/bsr/testdata/TestBsr/session_not_multiplexed/closed/SHA256SUM b/internal/bsr/testdata/TestBsr/session_not_multiplexed/closed/SHA256SUM index bd71cde18d..56820fd861 100644 --- a/internal/bsr/testdata/TestBsr/session_not_multiplexed/closed/SHA256SUM +++ b/internal/bsr/testdata/TestBsr/session_not_multiplexed/closed/SHA256SUM @@ -3,5 +3,5 @@ .* wrappedPrivKey .* pubKeyBsrSignature.sign .* pubKeySelfSignature.sign -f9c1b3593565129acbb7f62cd2397b527c86183bb552c5de4c27560b58602ddc session.meta +04fb6e9ce96c411f2ab185167d8b69a6d66d894d8620bf347e4003afe270f662 session.meta e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 session.summary diff --git a/internal/bsr/testdata/TestBsr/session_not_multiplexed/closed/session.meta b/internal/bsr/testdata/TestBsr/session_not_multiplexed/closed/session.meta index e6f4cb8901..3c8233707b 100644 --- a/internal/bsr/testdata/TestBsr/session_not_multiplexed/closed/session.meta +++ b/internal/bsr/testdata/TestBsr/session_not_multiplexed/closed/session.meta @@ -10,6 +10,9 @@ target_projectId: proj123 target_defaultPort: 0 target_sessionMaxSeconds: 0 target_sessionConnectionLimit: 0 +worker_publicId: w_12345 +worker_version: 0.25.5 +worker_sha: beepboopgitsha staticHost_publicId: host123 staticHostCatalog_publicId: staticcat123 staticHostCatalog_projectId: proj123 diff --git a/internal/bsr/testdata/TestBsr/session_not_multiplexed/opened/session.meta b/internal/bsr/testdata/TestBsr/session_not_multiplexed/opened/session.meta index 5ee3fb1ad8..26cccf86c3 100644 --- a/internal/bsr/testdata/TestBsr/session_not_multiplexed/opened/session.meta +++ b/internal/bsr/testdata/TestBsr/session_not_multiplexed/opened/session.meta @@ -10,6 +10,9 @@ target_projectId: proj123 target_defaultPort: 0 target_sessionMaxSeconds: 0 target_sessionConnectionLimit: 0 +worker_publicId: w_12345 +worker_version: 0.25.5 +worker_sha: beepboopgitsha staticHost_publicId: host123 staticHostCatalog_publicId: staticcat123 staticHostCatalog_projectId: proj123 diff --git a/internal/bsr/testing.go b/internal/bsr/testing.go index f0058f35ef..05159143ea 100644 --- a/internal/bsr/testing.go +++ b/internal/bsr/testing.go @@ -66,6 +66,11 @@ func TestSessionMeta(s string, p Protocol) *SessionMeta { SessionMaxSeconds: 0, SessionConnectionLimit: 0, }, + Worker: &Worker{ + PublicId: "w_12345", + Version: "0.25.5", + Sha: "beepboopgitsha", + }, StaticCredentialStore: staticCredentialStore, VaultCredentialStore: vaultCredentialStore, }