common

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthzListToMap

func AuthzListToMap(paths []string) map[string][]string

AuthzListToMap converts a list of resource-path strings (for example "/organization/org/project/proj" or legacy "/programs/org/projects/proj") to the wire-format org→projects map.

func AuthzMapFromScope

func AuthzMapFromScope(org, project string) map[string][]string

AuthzMapFromScope builds the wire-format authorizations map from an org and project. Empty project means org-wide access (value is empty slice).

func AuthzMapMatchesScope added in v0.2.8

func AuthzMapMatchesScope(authzMap map[string][]string, org, project string) bool

AuthzMapMatchesScope reports whether the authz map grants access for the given org and project. An empty project list in the map means org-wide access.

func AuthzMapToControlledAccess added in v0.2.8

func AuthzMapToControlledAccess(authzMap map[string][]string) []string

func AuthzMapToList

func AuthzMapToList(authzMap map[string][]string) []string

AuthzMapToList converts the wire-format org→projects map back to a list of canonical resource-path strings for internal storage.

func BuildDrsObjWithPrefix

func BuildDrsObjWithPrefix(fileName string, checksum string, size int64, drsId string, bucket string, org string, project string, prefix string) (*drsapi.DrsObject, error)

BuildDrsObjWithPrefix builds a DRS object with an S3 access URL derived from the provided bucket, org, project, and storage prefix.

func ControlledAccessToAuthzMap added in v0.2.8

func ControlledAccessToAuthzMap(claims []string) map[string][]string

func ConvertToCandidate

func ConvertToCandidate(obj *drsapi.DrsObject) drsapi.DrsObjectCandidate

ConvertToCandidate converts a DRS object to a registration candidate, stripping server-assigned fields (Id, SelfUri, timestamps).

func DrsObjectMatchesScope added in v0.2.8

func DrsObjectMatchesScope(obj *drsapi.DrsObject, org, project string) bool

func DrsUUID

func DrsUUID(org, project, hash string) string

DrsUUID generates a deterministic UUID for a DRS object from org, project, and hash.

func NormalizeAccessResource added in v0.2.8

func NormalizeAccessResource(raw string) string

NormalizeAccessResource converts GA4GH controlled_access URL claims and accepted resource path aliases into the canonical resource form used for privilege checks: /organization/<organization>[/project/<project>].

func NormalizeAccessResources added in v0.2.8

func NormalizeAccessResources(resources []string) []string

func NormalizeChecksum

func NormalizeChecksum(raw string) string

NormalizeChecksum trims whitespace and an optional sha256: prefix.

func NormalizeOid

func NormalizeOid(oid string) string

NormalizeOid strips an optional "sha256:" prefix, lowercases, and validates that the result is a 64-character hex string. Returns "" for invalid input.

func ResourcePath

func ResourcePath(org, project string) (string, error)

ResourcePath returns the canonical resource path for an org/project scope, e.g. "/organization/myorg/project/myproject".

func ResourceScope added in v0.2.8

func ResourceScope(resource string) (string, string, bool)

ResourceScope parses a canonical or raw access resource into (organization, project). It accepts "/organization/org", "/organization/org/project/proj", and legacy "/programs/org/projects/proj" alias forms.

func StoragePrefix

func StoragePrefix(org, project string) string

StoragePrefix returns the storage path prefix for an org/project scope (no leading slash), e.g. "programs/myorg/projects/myproject".

Types

type ObjectBuilder

type ObjectBuilder struct {
	Bucket        string
	Project       string
	Organization  string
	StoragePrefix string
	PathStyle     string
}

ObjectBuilder constructs DRS objects for a given bucket and project scope.

func NewObjectBuilder

func NewObjectBuilder(bucket, project string) ObjectBuilder

NewObjectBuilder creates an ObjectBuilder for the given bucket and project.

func (ObjectBuilder) Build

func (b ObjectBuilder) Build(fileName string, checksum string, size int64, drsId string) (*drsapi.DrsObject, error)

Build constructs a DRS object with the given file metadata.

Jump to

Keyboard shortcuts

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