feat(bsr): add BSR playback/conversion interfaces
This commit is contained in:
1 parent
444af9151c
commit
47477e8fd6
5 files changed
+99
No files matched your search
@@ -138,6 +138,15 @@ func persistBsrSessionKeys(ctx context.Context, keys *kms.Keys, c *container) er
|
||||
return nil
|
||||
}
|
||||
|
||||
// OpenSession retrieves a BSR from storage using the sessionRecordingId and initializes it for reading.
|
||||
// Encryption keys necessary for checking signed files will be unwrapped using the keyUnwrapFn
|
||||
// Signature and checksum files will then be verified.
|
||||
// Fields on the underlying container will be populated so that the returned Session can be used for BSR
|
||||
// playback and conversion to formats such as asciinema
|
||||
func OpenSession(ctx context.Context, sessionRecordingId string, f storage.FS, keyUnwrapFn kms.KeyUnwrapCallbackFunc) (*Session, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
// NewConnection creates a Connection container for a given connection id.
|
||||
func (s *Session) NewConnection(ctx context.Context, meta *ConnectionMeta) (*Connection, error) {
|
||||
const op = "bsr.(Session).NewConnection"
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package convert
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/bsr"
|
||||
"github.com/hashicorp/boundary/internal/storage"
|
||||
)
|
||||
|
||||
// ToAsciinema accepts a bsr.Session and will convert the underlying BSR connection or channel file to an asciinema file.
|
||||
// The tempFs will be used to write the asciinema file to disk
|
||||
// It returns an io.Reader to the converted asciinema file
|
||||
// Supports WithChannelId() to indicate this conversion should occur on a chanel on a multiplexed session
|
||||
func ToAsciinema(ctx context.Context, session bsr.Session, tempFs storage.FS, connectionId string, options ...Option) (io.Reader, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package convert
|
||||
|
||||
// getOpts - iterate the inbound Options and return a struct
|
||||
func getOpts(opt ...Option) options {
|
||||
opts := getDefaultOptions()
|
||||
for _, o := range opt {
|
||||
o(&opts)
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
// Option - how Options are passed as arguments
|
||||
type Option func(*options)
|
||||
|
||||
// options = how options are represented
|
||||
type options struct {
|
||||
withChannelId string
|
||||
}
|
||||
|
||||
func getDefaultOptions() options {
|
||||
return options{}
|
||||
}
|
||||
|
||||
// WithChannelId provides and option to specify the channelId
|
||||
func WithChannelId(id string) Option {
|
||||
return func(o *options) {
|
||||
o.withChannelId = id
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package convert
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Test_GetOpts provides unit tests for GetOpts and all the options
|
||||
func Test_GetOpts(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("WithChannelId", func(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
channelId := "channel-id"
|
||||
opts := getOpts(WithChannelId(channelId))
|
||||
testOpts := getDefaultOptions()
|
||||
testOpts.withChannelId = channelId
|
||||
assert.Equal(opts, testOpts)
|
||||
})
|
||||
}
|
||||
@@ -51,6 +51,21 @@ type Keys struct {
|
||||
l sync.RWMutex
|
||||
}
|
||||
|
||||
// WrappedKeys contains the wrapped BSR and priv keys
|
||||
type WrappedKeys struct {
|
||||
WrappedBsrKey *wrapping.KeyInfo
|
||||
WrappedPrivKey *wrapping.KeyInfo
|
||||
}
|
||||
|
||||
// Unwrapped keys contains the unwrapped BSR and priv keys
|
||||
type UnwrappedKeys struct {
|
||||
BsrKey *wrapping.KeyInfo
|
||||
PrivKey *wrapping.KeyInfo
|
||||
}
|
||||
|
||||
// KeyUnwrapCallbackFunc is used by OpenSession to unwrap BSR and private keys
|
||||
type KeyUnwrapCallbackFunc func(WrappedKeys) (UnwrappedKeys, error)
|
||||
|
||||
// CreateKeys creates new bsr keys, wrapping and signing keys as required
|
||||
// using the provided bsrWrapper. Supported options: WithRandomReader
|
||||
func CreateKeys(ctx context.Context, bsrWrapper wrapping.Wrapper, sessionId string, opt ...Option) (*Keys, error) {
|
||||
|
||||
Reference in new issue
Block a user