Documentation ¶
Index ¶
- Constants
- func GetOpts(opt ...Option) options
- func Prefixes() []string
- func Register(s subtypes.Subtype, th targetHooks, prefix string)
- func SubtypeFromId(id string) subtypes.Subtype
- func SubtypeFromType(t string) subtypes.Subtype
- type AllocFunc
- type Cloneable
- type CredentialLibrary
- func NewCredentialLibrary(targetId, credentialLibraryId string, purpose credential.Purpose) (*CredentialLibrary, error)
- func TestCredentialLibrary(t testing.TB, conn *db.DB, targetId, libraryId string) *CredentialLibrary
- func TestNewCredentialLibrary(targetId, credentialLibraryId string, purpose credential.Purpose) *CredentialLibrary
- type CredentialSource
- type CredentialSourceType
- type CredentialSources
- type HostSource
- type NewFunc
- type Option
- func WithCredentialLibraries(cl []*CredentialLibrary) Option
- func WithDefaultPort(p uint32) Option
- func WithDescription(desc string) Option
- func WithHostSources(hs []string) Option
- func WithLimit(limit int) Option
- func WithName(name string) Option
- func WithPermissions(perms []perms.Permission) Option
- func WithProjectId(projectId string) Option
- func WithProjectIds(projectIds []string) Option
- func WithProjectName(projectName string) Option
- func WithPublicId(id string) Option
- func WithSessionConnectionLimit(limit int32) Option
- func WithSessionMaxSeconds(dur uint32) Option
- func WithStaticCredentials(c []*StaticCredential) Option
- func WithTargetIds(with []string) Option
- func WithType(t subtypes.Subtype) Option
- func WithUserId(userId string) Option
- func WithWorkerFilter(filter string) Option
- type Repository
- func (r *Repository) AddTargetCredentialSources(ctx context.Context, targetId string, targetVersion uint32, ...) (Target, []HostSource, []CredentialSource, error)
- func (r *Repository) AddTargetHostSources(ctx context.Context, targetId string, targetVersion uint32, ...) (Target, []HostSource, []CredentialSource, error)
- func (r *Repository) CreateTarget(ctx context.Context, target Target, opt ...Option) (Target, []HostSource, []CredentialSource, error)
- func (r *Repository) DeleteTarget(ctx context.Context, publicId string, _ ...Option) (int, error)
- func (r *Repository) DeleteTargetCredentialSources(ctx context.Context, targetId string, targetVersion uint32, ...) (int, error)
- func (r *Repository) DeleteTargetHostSources(ctx context.Context, targetId string, targetVersion uint32, ...) (int, error)
- func (r *Repository) FetchAuthzProtectedEntitiesByScope(ctx context.Context, projectIds []string) (map[string][]boundary.AuthzProtectedEntity, error)
- func (r *Repository) ListTargets(ctx context.Context, opt ...Option) ([]Target, error)
- func (r *Repository) LookupTarget(ctx context.Context, publicIdOrName string, opt ...Option) (Target, []HostSource, []CredentialSource, error)
- func (r *Repository) SetTargetCredentialSources(ctx context.Context, targetId string, targetVersion uint32, ...) ([]HostSource, []CredentialSource, int, error)
- func (r *Repository) SetTargetHostSources(ctx context.Context, targetId string, targetVersion uint32, ...) ([]HostSource, []CredentialSource, int, error)
- func (r *Repository) UpdateTarget(ctx context.Context, target Target, version uint32, fieldMaskPaths []string, ...) (Target, []HostSource, []CredentialSource, int, error)
- type RepositoryFactory
- type StaticCredential
- type Target
- type TargetCredentialSource
- func (ts *TargetCredentialSource) CredentialPurpose() credential.Purpose
- func (ts *TargetCredentialSource) CredentialStoreId() string
- func (ts *TargetCredentialSource) Id() string
- func (ts *TargetCredentialSource) TableName() string
- func (ts *TargetCredentialSource) TargetId() string
- func (ts *TargetCredentialSource) Type() CredentialSourceType
- type TargetHostSet
- type TargetSet
- type VetCredentialSourcesFunc
- type VetForUpdateFunc
- type VetFunc
Constants ¶
const (
DefaultTargetHostSetTableName = "target_host_set"
)
Variables ¶
This section is empty.
Functions ¶
func GetOpts ¶ added in v0.7.0
func GetOpts(opt ...Option) options
GetOpts - iterate the inbound Options and return a struct
func Prefixes ¶ added in v0.7.4
func Prefixes() []string
Prefixes returns the list of all known target Prefixes.
func Register ¶ added in v0.7.0
Register registers repository hooks and the prefixes for a provided Subtype. Register panics if the subtype has already been registered or if any of the prefixes are associated with another subtype.
func SubtypeFromId ¶
SubtypeFromId returns the Subtype from the provided id if the id's prefix was registered with a Subtype. Otherwise Unknown is returned.
func SubtypeFromType ¶
SubtypeFromType returns the Subtype from the provided string or if no Subtype was registered with that string Unknown is returned.
Types ¶
type AllocFunc ¶ added in v0.7.0
type AllocFunc func() Target
AllocFunc is a function that creates an in-memory Target.
type CredentialLibrary ¶ added in v0.4.0
type CredentialLibrary struct { *store.CredentialLibrary // contains filtered or unexported fields }
A CredentialLibrary is a CredentialSource that represents the relationship between a target and a credential library.
func NewCredentialLibrary ¶ added in v0.4.0
func NewCredentialLibrary(targetId, credentialLibraryId string, purpose credential.Purpose) (*CredentialLibrary, error)
NewCredentialLibrary creates a new in memory CredentialLibrary representing the relationship between targetId and credentialLibraryId.
func TestCredentialLibrary ¶ added in v0.4.0
func TestCredentialLibrary(t testing.TB, conn *db.DB, targetId, libraryId string) *CredentialLibrary
TestCredentialLibrary creates a CredentialLibrary for targetId and libraryId with the credential purpose of brokered.
func TestNewCredentialLibrary ¶ added in v0.7.0
func TestNewCredentialLibrary(targetId, credentialLibraryId string, purpose credential.Purpose) *CredentialLibrary
TestNewCredentialLibrary creates a new in memory CredentialLibrary representing the relationship between targetId and credentialLibraryId with the given purpose.
func (*CredentialLibrary) SetTableName ¶ added in v0.4.0
func (t *CredentialLibrary) SetTableName(n string)
SetTableName sets the table name.
func (*CredentialLibrary) TableName ¶ added in v0.4.0
func (t *CredentialLibrary) TableName() string
TableName returns the table name.
type CredentialSource ¶ added in v0.5.0
type CredentialSource interface { CredentialStoreId() string Id() string CredentialPurpose() credential.Purpose TargetId() string Type() CredentialSourceType }
CredentialSource is an interface that can be implemented by both a library and a singular credential.
type CredentialSourceType ¶ added in v0.9.0
type CredentialSourceType string
CredentialSourceType is the type of credential source.
const ( LibraryCredentialSourceType CredentialSourceType = "library" StaticCredentialSourceType CredentialSourceType = "static" )
Credential source type values.
type CredentialSources ¶ added in v0.9.0
type CredentialSources struct { BrokeredCredentialIds []string InjectedApplicationCredentialIds []string }
CredentialSources contains slices of credential publicIds per purpose to be attached to the target.
type HostSource ¶ added in v0.5.0
HostSource is an interface that can be implemented by both a set and a singular host.
type NewFunc ¶ added in v0.7.4
NewFunc is a function that creates a Target with the provided project and options.
type Option ¶
type Option func(*options)
Option - how Options are passed as arguments
func WithCredentialLibraries ¶ added in v0.4.0
func WithCredentialLibraries(cl []*CredentialLibrary) Option
WithCredentialLibraries provides an option for providing a list of credential libraries.
func WithDefaultPort ¶
WithDefaultPort provides an option to specify the default target port.
func WithDescription ¶
WithDescription provides an optional description
func WithHostSources ¶ added in v0.5.0
WithHostSources provides an option for providing a list of host source ids
func WithLimit ¶
WithLimit provides an option to provide a limit. Intentionally allowing negative integers. If WithLimit < 0, then unlimited results are returned. If WithLimit == 0, then default limits are used for results.
func WithPermissions ¶ added in v0.10.4
func WithPermissions(perms []perms.Permission) Option
WithPermissions is used by this repo to restrict a list request's results based on the given set of permissions.
func WithProjectId ¶ added in v0.10.2
WithProjectId provides an option to search by a project id
func WithProjectIds ¶ added in v0.10.2
WithProjectId provides an option to search by multiple project id
func WithProjectName ¶ added in v0.10.2
WithProjectId provides an option to search by a project name
func WithSessionMaxSeconds ¶
func WithStaticCredentials ¶ added in v0.9.0
func WithStaticCredentials(c []*StaticCredential) Option
WithStaticCredentials provides an option for providing a list of static credentials.
func WithTargetIds ¶ added in v0.8.0
WithTargetIds provides an option to search by specific target IDs
func WithUserId ¶
WithUserId provides an option to search by a user public id
func WithWorkerFilter ¶ added in v0.1.5
WithWorkerFilter provides an optional worker filter
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository is the target database repository
func NewRepository ¶
func NewRepository(ctx context.Context, r db.Reader, w db.Writer, kms *kms.Kms, opt ...Option) (*Repository, error)
NewRepository creates a new target Repository. Supports the following options: - WithLimit: sets a limit on the number of results returned by various repo operations. - WithPermissions: defines the permissions the user has to perform different actions and access resources within the created repo object.
func (*Repository) AddTargetCredentialSources ¶ added in v0.5.0
func (r *Repository) AddTargetCredentialSources(ctx context.Context, targetId string, targetVersion uint32, idsByPurpose CredentialSources, _ ...Option) (Target, []HostSource, []CredentialSource, error)
AddTargetCredentialSources adds the credential source ids by purpose to the targetId in the repository. The target and the list of credential sources attached to the target, after ids are added, will be returned on success. The targetVersion must match the current version of the targetId in the repository.
func (*Repository) AddTargetHostSources ¶ added in v0.5.0
func (r *Repository) AddTargetHostSources(ctx context.Context, targetId string, targetVersion uint32, hostSourceIds []string, _ ...Option) (Target, []HostSource, []CredentialSource, error)
AddTargetHostSources provides the ability to add host sources (hostSourceIds) to a target (targetId). The target's current db version must match the targetVersion or an error will be returned. The target and a list of current host source ids will be returned on success. Zero is not a valid value for the WithVersion option and will return an error.
func (*Repository) CreateTarget ¶ added in v0.7.0
func (r *Repository) CreateTarget(ctx context.Context, target Target, opt ...Option) (Target, []HostSource, []CredentialSource, error)
CreateTarget inserts into the repository and returns the new Target with its list of host sets and credential libraries. WithPublicId is the only supported option.
func (*Repository) DeleteTarget ¶
DeleteTarget will delete a target from the repository.
func (*Repository) DeleteTargetCredentialSources ¶ added in v0.5.0
func (r *Repository) DeleteTargetCredentialSources(ctx context.Context, targetId string, targetVersion uint32, idsByPurpose CredentialSources, _ ...Option) (int, error)
DeleteTargetCredentialSources deletes credential sources from a target in the repository. The target's current db version must match the targetVersion or an error will be returned.
func (*Repository) DeleteTargetHostSources ¶ added in v0.5.0
func (r *Repository) DeleteTargetHostSources(ctx context.Context, targetId string, targetVersion uint32, hostSourceIds []string, _ ...Option) (int, error)
DeleteTargeHostSources deletes host sources from a target (targetId). The target's current db version must match the targetVersion or an error will be returned. Zero is not a valid value for the WithVersion option and will return an error.
func (*Repository) FetchAuthzProtectedEntitiesByScope ¶ added in v0.8.0
func (r *Repository) FetchAuthzProtectedEntitiesByScope(ctx context.Context, projectIds []string) (map[string][]boundary.AuthzProtectedEntity, error)
FetchAuthzProtectedEntitiesByScope implements boundary.AuthzProtectedEntityProvider
func (*Repository) ListTargets ¶
ListTargets lists targets in a project based on the data in the WithPermissions option provided to the Repository constructor. If no permissions are available, this function is a no-op. Supports WithLimit which overrides the limit set in the Repository object.
func (*Repository) LookupTarget ¶
func (r *Repository) LookupTarget(ctx context.Context, publicIdOrName string, opt ...Option) (Target, []HostSource, []CredentialSource, error)
LookupTarget will look up a target in the repository and return the target with its host source ids and credential source ids. If the target is not found, it will return nil, nil, nil, nil. No options are currently supported.
func (*Repository) SetTargetCredentialSources ¶ added in v0.5.0
func (r *Repository) SetTargetCredentialSources(ctx context.Context, targetId string, targetVersion uint32, ids CredentialSources, _ ...Option) ([]HostSource, []CredentialSource, int, error)
SetTargetCredentialSources will set the target's credential sources. Set will add and/or delete credential sources as need to reconcile the existing credential sources with the request. If clIds is empty, all the credential sources will be cleared from the target.
func (*Repository) SetTargetHostSources ¶ added in v0.5.0
func (r *Repository) SetTargetHostSources(ctx context.Context, targetId string, targetVersion uint32, hostSourceIds []string, _ ...Option) ([]HostSource, []CredentialSource, int, error)
SetTargetHostSources will set the target's host sources. Set add and/or delete target host sources as need to reconcile the existing sets with the sets requested. If hostSourceIds is empty, the target host sources will be cleared. Zero is not a valid value for the WithVersion option and will return an error.
func (*Repository) UpdateTarget ¶ added in v0.7.0
func (r *Repository) UpdateTarget(ctx context.Context, target Target, version uint32, fieldMaskPaths []string, _ ...Option) (Target, []HostSource, []CredentialSource, int, error)
UpdateTarget will update a target in the repository and return the written target. fieldMaskPaths provides field_mask.proto paths for fields that should be updated. Fields will be set to NULL if the field is a zero value and included in fieldMask. Name, Description, and WorkerFilter are the only updatable fields. If no updatable fields are included in the fieldMaskPaths, then an error is returned.
type RepositoryFactory ¶ added in v0.10.4
type RepositoryFactory func(...Option) (*Repository, error)
RepositoryFactory enables `target.Repository` object instantiation, and is used by the various service packages/controller object to do so.
type StaticCredential ¶ added in v0.9.0
type StaticCredential struct { *store.StaticCredential // contains filtered or unexported fields }
A StaticCredential is a CredentialSource that represents the relationship between a target and a static credential.
func NewStaticCredential ¶ added in v0.9.0
func NewStaticCredential(targetId, credentialId string, purpose credential.Purpose) (*StaticCredential, error)
NewStaticCredential creates a new in memory StaticCredential representing the relationship between targetId and credentialId.
func TestNewStaticCredential ¶ added in v0.9.0
func TestNewStaticCredential(targetId, credentialId string, purpose credential.Purpose) *StaticCredential
TestNewStaticCredential creates a new in memory StaticCredential representing the relationship between targetId and credentialId with the given purpose.
func (*StaticCredential) SetTableName ¶ added in v0.9.0
func (t *StaticCredential) SetTableName(n string)
SetTableName sets the table name.
func (*StaticCredential) TableName ¶ added in v0.9.0
func (t *StaticCredential) TableName() string
TableName returns the table name.
type Target ¶
type Target interface { GetPublicId() string GetProjectId() string GetDefaultPort() uint32 GetName() string GetDescription() string GetVersion() uint32 GetType() subtypes.Subtype GetCreateTime() *timestamp.Timestamp GetUpdateTime() *timestamp.Timestamp GetSessionMaxSeconds() uint32 GetSessionConnectionLimit() int32 GetWorkerFilter() string Clone() Target SetPublicId(context.Context, string) error SetProjectId(string) SetName(string) SetDescription(string) SetVersion(uint32) SetDefaultPort(uint32) SetCreateTime(*timestamp.Timestamp) SetUpdateTime(*timestamp.Timestamp) SetSessionMaxSeconds(uint32) SetSessionConnectionLimit(int32) SetWorkerFilter(string) Oplog(op oplog.OpType) oplog.Metadata }
Target is a commmon interface for all target subtypes
type TargetCredentialSource ¶ added in v0.9.0
type TargetCredentialSource struct { *store.CredentialSource StoreId string }
A TargetCredentialSource represents the relationship between a target and a credential library and includes the id of the credential store that the library is a part of and the library's name and description.
It implements the target.CredentialSource interface.
func (*TargetCredentialSource) CredentialPurpose ¶ added in v0.9.0
func (ts *TargetCredentialSource) CredentialPurpose() credential.Purpose
CredentialPurpose returns the purpose of the credential
func (*TargetCredentialSource) CredentialStoreId ¶ added in v0.9.0
func (ts *TargetCredentialSource) CredentialStoreId() string
CredentialStoreId returns the ID of the store containing the credential source
func (*TargetCredentialSource) Id ¶ added in v0.9.0
func (ts *TargetCredentialSource) Id() string
Id returns the ID of the credential source
func (*TargetCredentialSource) TableName ¶ added in v0.9.0
func (ts *TargetCredentialSource) TableName() string
TableName returns the tablename to override the default gorm table name
func (*TargetCredentialSource) TargetId ¶ added in v0.9.0
func (ts *TargetCredentialSource) TargetId() string
TargetId returns the target linked to this credential source
func (*TargetCredentialSource) Type ¶ added in v0.9.0
func (ts *TargetCredentialSource) Type() CredentialSourceType
Type returns the type of the credential source (library or static)
type TargetHostSet ¶
type TargetHostSet struct { *store.TargetHostSet // contains filtered or unexported fields }
func NewTargetHostSet ¶
func NewTargetHostSet(targetId, hostSetId string, _ ...Option) (*TargetHostSet, error)
NewTargetHostSet creates a new in memory target host set. No options are currently supported.
func (*TargetHostSet) Clone ¶
func (t *TargetHostSet) Clone() interface{}
Clone creates a clone of the target host set
func (*TargetHostSet) SetTableName ¶
func (t *TargetHostSet) SetTableName(n string)
SetTableName sets the tablename and satisfies the ReplayableMessage interface. If the caller attempts to set the name to "" the name will be reset to the default name.
func (*TargetHostSet) TableName ¶
func (t *TargetHostSet) TableName() string
TableName returns the tablename to override the default gorm table name
type TargetSet ¶
TargetSet is returned from most repo operations as the target's host set.
func (*TargetSet) HostCatalogId ¶ added in v0.5.0
HostCatalogId returns the ID of the catalog containing the set
type VetCredentialSourcesFunc ¶ added in v0.9.0
type VetCredentialSourcesFunc func(context.Context, []*CredentialLibrary, []*StaticCredential) error
VetCredentialSourcesFunc is a function that checks the given CredentialLibraries and StaticCredentials to ensure that they are valid for a Target subtype.
type VetForUpdateFunc ¶ added in v0.9.0
VetForUpdateFunc is a function that checks the given Target and field mask paths are valid and be used to update a target in the Repository.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package targettest provides a test target subtype for use by the target package.
|
Package targettest provides a test target subtype for use by the target package. |
Package tcp provides a Target subtype for a TCP Target.
|
Package tcp provides a Target subtype for a TCP Target. |