accesskey

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2026 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Overview

Package accesskey provides the S3 access-key business logic for the REST API: creation (key-pair generation + tenant→access-key delegation issuance), listing, retrieval, and revocation. It returns the known errors in errors.go so handlers can map them to HTTP responses; unexpected failures are returned wrapped for the handler to log.

Index

Constants

View Source
const (
	TenantNotFoundErrorName    = "TenantNotFound"
	InvalidNameErrorName       = "InvalidAccessKeyName"
	NoPermissionsErrorName     = "NoPermissions"
	InvalidPermissionErrorName = "InvalidPermission"
	UnknownBucketErrorName     = "UnknownBucket"
	NameConflictErrorName      = "AccessKeyNameConflict"
	AccessKeyNotFoundErrorName = "AccessKeyNotFound"
)

Error names for the access-key service's known errors, exported so callers can match on the stable Name() of a serialized failure.

Variables

View Source
var (
	// ErrTenantNotFound is returned when no tenant exists for the external id.
	ErrTenantNotFound = errors.New(TenantNotFoundErrorName, "tenant not found")
	// ErrInvalidName is returned when the access key name is empty or too long.
	ErrInvalidName = errors.New(InvalidNameErrorName, "name must be between 1 and 100 characters")
	// ErrNoPermissions is returned when no permissions are requested.
	ErrNoPermissions = errors.New(NoPermissionsErrorName, "at least one permission is required")
	// ErrInvalidPermission is returned when a requested permission is unknown.
	ErrInvalidPermission = errors.New(InvalidPermissionErrorName, "unknown permission")
	// ErrUnknownBucket is returned when a requested bucket name is not one of the
	// tenant's buckets.
	ErrUnknownBucket = errors.New(UnknownBucketErrorName, "unknown bucket")
	// ErrNameConflict is returned when an access key with the same name already
	// exists for the tenant.
	ErrNameConflict = errors.New(NameConflictErrorName, "an access key with this name already exists")
	// ErrAccessKeyNotFound is returned when the access key does not exist (or
	// belongs to another tenant, or the id is unparseable).
	ErrAccessKeyNotFound = errors.New(AccessKeyNotFoundErrorName, "access key not found")
)

Known errors returned by the access-key Service. Handlers map these to HTTP status codes with errors.Is; anything else is an unexpected (500-class) failure. ErrInvalidPermission and ErrUnknownBucket are wrapped with the offending value at the return site so the message names it.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements S3 access-key operations shared by the REST handlers.

func New

func New(
	logger *zap.Logger,
	tenants tenant.Store,
	accessKeys accesskeystore.Store,
	buckets bucket.Store,
	delegations delegationstore.Store,
	secrets vault.Vault,
) *Service

New constructs the access-key service.

func (*Service) Create

func (s *Service) Create(ctx context.Context, externalID, name string, permissions, bucketNames []string, expiresAt *time.Time) (accesskeystore.Record, string, error)

Create creates an S3 access key for the tenant and issues the tenant→access-key delegations for the requested permissions (scoped to the named buckets, or tenant-wide when none are given). It returns the stored record and the secret access key (the one time it is exposed).

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, externalID, accessKeyID string) error

Delete revokes an access key belonging to the tenant: removing its delegations, vault key, and record. Sending UCAN revocations to a revocation service is out of scope (no such service exists yet, as with Sprue deprovisioning).

func (*Service) Get

func (s *Service) Get(ctx context.Context, externalID, accessKeyID string) (accesskeystore.Record, map[did.DID]string, error)

Get returns a single access key belonging to the tenant, and a DID→name map for its buckets.

func (*Service) List

func (s *Service) List(ctx context.Context, externalID string) ([]accesskeystore.Record, map[did.DID]string, error)

List returns the tenant's access keys and a DID→name map for the buckets they reference (for rendering).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL