importmeta

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package importmeta lets administrators preserve origin metadata when migrating artifacts from another repository manager.

An upload may carry the header X-OA-Import-Created-At (RFC 3339) holding the time the artifact was originally created. The header is honored only for principals holding the global "manage" permission; for everyone else it is silently ignored, so ordinary clients can never back-date or forward-date their uploads. An authorized request with a malformed or future timestamp is rejected with 400.

Middleware resolves the header once per request and stores the verdict in the request context; upload handlers read it with CreatedAt.

Index

Constants

View Source
const HeaderCreatedAt = "X-Oa-Import-Created-At"

HeaderCreatedAt carries the origin creation time of an uploaded artifact.

Variables

This section is empty.

Functions

func CreatedAt

func CreatedAt(ctx context.Context) time.Time

CreatedAt returns the origin creation time authorized for this request, or the zero time when there is none and the upload should be stamped "now".

func Middleware

func Middleware(authz Authorizer) func(http.Handler) http.Handler

Middleware resolves X-OA-Import-Created-At for every request that carries it. It must run after authentication so the principal is in the context.

func WithCreatedAt

func WithCreatedAt(ctx context.Context, t time.Time) context.Context

WithCreatedAt returns a context carrying an origin creation time. It is for the middleware and for tests; request handlers only read it.

Types

type Authorizer

type Authorizer interface {
	Evaluate(ctx context.Context, principal auth.Principal, repoName, artifactPath, action string) (bool, error)
}

Authorizer is the part of auth.Evaluator the middleware needs.

Jump to

Keyboard shortcuts

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