Documentation
¶
Index ¶
- func DeriveCredentialID(bucket, provider, region, endpoint, accessKey string) string
- func NormalizedStoragePrefixes(scopes []Scope) []string
- type BucketConfiguration
- type Credential
- type CredentialAdmin
- type CredentialReader
- type Dependencies
- type PutRequest
- type Scope
- type ScopeDeletionPolicy
- type ScopeStore
- type Service
- func (s *Service) CreateBucketScope(ctx context.Context, scope *Scope) error
- func (s *Service) CreateScopeForBucket(ctx context.Context, credentialID, organization, projectID, path string) error
- func (s *Service) DeleteBucket(ctx context.Context, bucket string) error
- func (s *Service) DeleteBucketScope(ctx context.Context, organization, projectID, credentialID, pathPrefix string) error
- func (s *Service) DeleteS3Credential(ctx context.Context, bucket string) error
- func (s *Service) DeleteScope(ctx context.Context, ...) error
- func (s *Service) GetS3Credential(ctx context.Context, bucket string) (*Credential, error)
- func (s *Service) ListBucketScopes(ctx context.Context) ([]Scope, error)
- func (s *Service) ListS3Credentials(ctx context.Context) ([]Credential, error)
- func (s *Service) ListVisibleBuckets(ctx context.Context) (map[string]VisibleBucket, error)
- func (s *Service) ListVisibleProjectScopes(ctx context.Context, organization, project string) ([]VisibleProjectScope, error)
- func (s *Service) ListVisibleScopes(ctx context.Context, routeCredentialID string) ([]VisibleScope, error)
- func (s *Service) LookupBucketScope(ctx context.Context, organization, project string) (Scope, bool, error)
- func (s *Service) Put(ctx context.Context, request PutRequest) error
- func (s *Service) ResolveStorageScope(ctx context.Context, organization, project string) (StorageScope, error)
- func (s *Service) SaveS3Credential(ctx context.Context, cred *Credential) error
- type StorageScope
- type StorageScopeError
- type StorageScopeErrorKind
- type VisibilityQuery
- type VisibilityRow
- type VisibleBucket
- type VisibleProjectScope
- type VisibleScope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeriveCredentialID ¶
DeriveCredentialID returns a stable internal ID derived from the non-secret credential identity. SecretKey is intentionally excluded so credential rotation does not change the identity.
func NormalizedStoragePrefixes ¶ added in v0.4.2
NormalizedStoragePrefixes trims scope path prefixes and collapses nested entries while preserving their effective order.
Types ¶
type BucketConfiguration ¶ added in v0.4.2
type BucketConfiguration struct {
Credential Credential
Organization string
ProjectID string
PathPrefix string
}
BucketConfiguration is the persisted bucket aggregate. A credential and its scope are required together when a bucket PUT changes both records.
type Credential ¶
type Credential struct {
CredentialID string `db:"credential_id"`
Bucket string `db:"bucket"`
Provider string `db:"provider"`
Region string `db:"region"`
AccessKey string `db:"access_key"`
SecretKey string `db:"secret_key"`
Endpoint string `db:"endpoint"`
}
Credential represents the s3_credential table and the provider credentials consumed by storage implementations. SecretKey is never part of derived identity, but remains available to the provider after decryption.
type CredentialAdmin ¶
type CredentialAdmin interface {
SaveS3Credential(ctx context.Context, cred *Credential) error
SaveBucketConfiguration(ctx context.Context, configuration BucketConfiguration) error
DeleteBucketScopeConfiguration(ctx context.Context, scope Scope) ([]string, error)
DeleteBucketCredential(ctx context.Context, bucket string, authorize ScopeDeletionPolicy) ([]string, error)
DeleteS3Credential(ctx context.Context, bucket string) error
}
CredentialAdmin owns credential creation and deletion.
type CredentialReader ¶
type CredentialReader interface {
GetS3Credential(ctx context.Context, bucket string) (*Credential, error)
ListS3Credentials(ctx context.Context) ([]Credential, error)
}
CredentialReader reads configured bucket credentials.
type Dependencies ¶
type Dependencies struct {
Credentials CredentialReader
CredentialAdmin CredentialAdmin
Scopes ScopeStore
Visibility VisibilityQuery
}
Dependencies are the repository and visibility ports required by Service.
type PutRequest ¶ added in v0.4.2
type PutRequest struct {
Bucket string
Organization string
ProjectID string
Provider *string
Region *string
AccessKey *string
SecretKey *string
Endpoint *string
Path *string
}
PutRequest contains the optional credential fields accepted by the bucket write endpoint. Nil fields inherit an existing credential when one is selected by its physical bucket or derived credential ID.
type Scope ¶
type Scope struct {
Organization string `db:"organization"`
ProjectID string `db:"project_id"`
CredentialID string `db:"credential_id"`
Bucket string `db:"bucket"`
PathPrefix string `db:"path_prefix"`
}
Scope maps a Gen3 organization/project resource to a bucket credential.
type ScopeDeletionPolicy ¶ added in v0.4.3
ScopeDeletionPolicy checks every scope attached to a credential while the repository holds its content-write transaction.
type ScopeStore ¶
type ScopeStore interface {
CreateBucketScope(ctx context.Context, scope *Scope) error
GetBucketScope(ctx context.Context, organization, projectID string) (*Scope, error)
ListBucketScopes(ctx context.Context) ([]Scope, error)
}
ScopeStore owns bucket-scope lifecycle and lookup.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns bucket credential and scope policy. Repository adapters remain responsible for SQL, encryption, auditing, and transaction semantics.
func NewService ¶
func NewService(deps Dependencies, invalidator cacheInvalidator) (*Service, error)
NewService validates and constructs the bucket service. A nil invalidator is a supported no-op configuration.
func (*Service) CreateBucketScope ¶
CreateBucketScope persists a scope.
func (*Service) CreateScopeForBucket ¶ added in v0.4.2
func (s *Service) CreateScopeForBucket(ctx context.Context, credentialID, organization, projectID, path string) error
CreateScopeForBucket resolves a physical or credential alias, normalizes its path against the physical bucket, applies scope-write authorization, and persists the canonical scope.
func (*Service) DeleteBucket ¶ added in v0.4.2
DeleteBucket checks every attached scope in the same write transaction that removes the shared credential and scopes.
func (*Service) DeleteBucketScope ¶
func (s *Service) DeleteBucketScope(ctx context.Context, organization, projectID, credentialID, pathPrefix string) error
DeleteBucketScope deletes the requested scope and removes its credential after the last scope is gone.
func (*Service) DeleteS3Credential ¶
DeleteS3Credential resolves aliases before mutation, then invalidates all known aliases only after the repository confirms deletion.
func (*Service) DeleteScope ¶ added in v0.4.2
func (s *Service) DeleteScope(ctx context.Context, routeCredentialID, organization, projectID, pathPrefix string) error
DeleteScope selects exactly one matching scope before delegating the destructive repository operation. Alias matching is case-insensitive while organization, project, and normalized path retain their exact semantics.
func (*Service) GetS3Credential ¶
GetS3Credential resolves a credential by its canonical ID or legacy physical bucket alias according to the repository compatibility contract.
func (*Service) ListBucketScopes ¶
ListBucketScopes delegates scope enumeration without changing repository order or adapter-owned normalization.
func (*Service) ListS3Credentials ¶
func (s *Service) ListS3Credentials(ctx context.Context) ([]Credential, error)
ListS3Credentials returns configured credentials in repository order. The first returned credential remains the default bucket selection.
func (*Service) ListVisibleBuckets ¶
ListVisibleBuckets assembles configured credentials, explicit scopes, and object-derived rows supplied by persistence.
func (*Service) ListVisibleProjectScopes ¶ added in v0.4.2
func (s *Service) ListVisibleProjectScopes(ctx context.Context, organization, project string) ([]VisibleProjectScope, error)
ListVisibleProjectScopes returns authorized scopes for a requested organization/project pair. Organization output follows the request, even when the stored scope uses different casing.
func (*Service) ListVisibleScopes ¶ added in v0.4.2
func (s *Service) ListVisibleScopes(ctx context.Context, routeCredentialID string) ([]VisibleScope, error)
ListVisibleScopes returns authorized scopes matching a bucket or credential alias. Provider lookup intentionally uses the canonical credential ID only; an absent credential preserves the historical s3 URL fallback.
func (*Service) LookupBucketScope ¶
func (s *Service) LookupBucketScope(ctx context.Context, organization, project string) (Scope, bool, error)
LookupBucketScope returns a normalized scope. Not-found errors are represented as an absent scope so callers can compose organization and project scopes.
func (*Service) Put ¶ added in v0.4.2
func (s *Service) Put(ctx context.Context, request PutRequest) error
Put applies bucket credential and optional scope policy.
func (*Service) ResolveStorageScope ¶ added in v0.4.2
func (s *Service) ResolveStorageScope(ctx context.Context, organization, project string) (StorageScope, error)
ResolveStorageScope resolves the organization/project hierarchy to one physical S3 bucket and its effective prefix. Organization-level and project-level scopes are composed in lookup order, preserving the existing project-prefix behavior.
func (*Service) SaveS3Credential ¶
func (s *Service) SaveS3Credential(ctx context.Context, cred *Credential) error
SaveS3Credential persists a credential before invalidating every identity alias that could key a provider signer.
type StorageScope ¶ added in v0.4.2
type StorageScope struct {
Provider string
Bucket string
Prefix string
Prefixes []string
Credential Credential
}
StorageScope is the resolved physical target for an organization/project scope. It contains no caller authorization state. Callers authorize the resource before asking the bucket service to resolve it.
type StorageScopeError ¶ added in v0.4.2
type StorageScopeError struct {
Kind StorageScopeErrorKind
Message string
Cause error
}
StorageScopeError preserves the public message while allowing an adapter at another boundary to classify the resolution failure without importing its error type.
func (*StorageScopeError) Error ¶ added in v0.4.2
func (e *StorageScopeError) Error() string
func (*StorageScopeError) Unwrap ¶ added in v0.4.2
func (e *StorageScopeError) Unwrap() error
type StorageScopeErrorKind ¶ added in v0.4.2
type StorageScopeErrorKind string
const ( StorageScopeInvalidInput StorageScopeErrorKind = "invalid_input" StorageScopeNotFound StorageScopeErrorKind = "scope_not_found" StorageScopeCredentialMissing StorageScopeErrorKind = "credential_missing" StorageScopeUnsupported StorageScopeErrorKind = "unsupported" )
type VisibilityQuery ¶
type VisibilityQuery interface {
ListBucketVisibilityRows(ctx context.Context, resources []string, includeUnscoped, restrictToResources bool) ([]VisibilityRow, error)
}
VisibilityQuery supplies the object projection used to resolve bucket visibility.
type VisibilityRow ¶
VisibilityRow is the minimum storage projection needed to build bucket visibility responses without hydrating full objects.
type VisibleBucket ¶
type VisibleBucket struct {
Credential Credential
Programs []string
}
VisibleBucket is the credential and resource projection exposed to callers that need to authorize access to a physical bucket.