linkserver

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 37 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 linkserver holds what a shared Prism link server stores and answers: per repository and commit, where that repository references symbols other repositories declare, and what it declares itself.

A bundle carries locations, one line of source per reference, and declaration signatures. It carries no source bodies: answering "who uses this" for repositories that are not on a machine needs no more, and a server that never holds bodies is a smaller thing to protect.

Index

Constants

View Source
const DefaultKeep = 20

DefaultKeep is the retention default: 20 commits per repository.

View Source
const FormatVersion = 1

FormatVersion is the bundle format this build writes and the newest one a server accepts. 0 is the v1.3.x format, which had no format field.

View Source
const MaxLineRunes = 300

MaxLineRunes caps a source line shown next to a site. Real code lines are shorter (the longest in prism, grove and mason is 216 characters; 0.05% of grafana's lines exceed 300); a minified file or a hostile upload is not, and one such line used to put 200 KB into an answer.

View Source
const MaxRefsPerKey = 20000

MaxRefsPerKey is how many references to one symbol a bundle may carry. A real repository has far fewer; a bundle with more is refused at upload rather than flooding every answer about that symbol.

Variables

View Source
var (
	ErrNotFound    = errors.New("not found")
	ErrNotModified = errors.New("not modified")
	ErrConflict    = errors.New("changed by another writer")
)
View Source
var ErrNoConditionalWrites = errors.New("the store ignores conditional writes (If-Match / If-None-Match: *), " +
	"so replicas sharing it would lose each other's branch updates")

ErrNoConditionalWrites is a store that ignores If-Match / If-None-Match.

View Source
var ErrUnauthenticated = errors.New("missing, unknown, revoked or expired token")

ErrUnauthenticated is a missing, unknown, revoked or expired credential.

Functions

func AcceptedFormats

func AcceptedFormats() []int

AcceptedFormats lists the bundle formats this server stores.

func CleanLine

func CleanLine(s, near string) string

CleanLine makes text from another repository safe to print: control characters (terminal escape sequences among them) and bidirectional overrides are removed, tabs become spaces, and a line longer than MaxLineRunes is cut to a window around near (the referenced name) with "…" where it was cut.

func CleanName

func CleanName(s string, max int) string

CleanName cleans a short identifier-like field (a file path, an enclosing symbol) and caps it at max runes.

func ClientToken

func ClientToken() string

Token is the bearer token a client sends and a server requires: $PRISM_LINK_TOKEN. It is never read from a repository file, so it cannot be committed by accident.

func Copy

func Copy(ctx context.Context, src, dst Blob) (int, error)

Copy copies every object from src to dst: backup, restore, and moving a store between backends. It returns the number of objects copied.

func KeyLeaf

func KeyLeaf(key string) string

KeyLeaf is the last name segment of a key: go:mod/pkg#Type.Method -> Method.

func Push

func Push(ctx context.Context, server string, b Bundle) error

Push uploads a bundle.

func RepoName

func RepoName(remote, root string) string

RepoName turns a git remote URL into host/org/repo, falling back to the directory name for a repository with no remote.

func RevokeToken

func RevokeToken(p, id string) error

RevokeToken removes a token by id.

func Serve

func Serve(ctx context.Context, srv *Server, lc ListenConfig) error

Serve runs the public listener (and the ops listener) until ctx ends, then shuts down gracefully, letting requests in flight finish.

func VerifyConditionalWrites

func VerifyConditionalWrites(ctx context.Context, b Blob) error

VerifyConditionalWrites probes a store: a create-only write over an existing object and a write with a stale ETag must both be refused. Some S3 implementations accept the headers and ignore them (LocalStack 3.8, 2026-11-27); on such a store several replicas would overwrite each other's refs without an error.

Types

type Allow

type Allow func(repo string) bool

Allow reports whether a caller may read a repository; nil allows all.

type Authenticator

type Authenticator interface {
	Authenticate(r *http.Request) (*Principal, error)
	Describe() string
}

Authenticator turns a request's credential into a Principal.

type AzureBlob

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

AzureBlob is a Blob on an Azure Blob Storage container. PutIf uses If-Match / If-None-Match: *, so several replicas can share it.

func OpenAzure

func OpenAzure(ctx context.Context, c AzureConfig) (*AzureBlob, error)

OpenAzure checks the container is reachable with the credentials.

func (*AzureBlob) Delete

func (b *AzureBlob) Delete(ctx context.Context, key string) error

func (*AzureBlob) Describe

func (b *AzureBlob) Describe() string

func (*AzureBlob) Get

func (b *AzureBlob) Get(ctx context.Context, key, ifNoneMatch string) ([]byte, string, error)

func (*AzureBlob) List

func (b *AzureBlob) List(ctx context.Context, prefix string) ([]string, error)

func (*AzureBlob) Put

func (b *AzureBlob) Put(ctx context.Context, key string, data []byte) error

func (*AzureBlob) PutIf

func (b *AzureBlob) PutIf(ctx context.Context, key string, data []byte, ifMatch string) (string, error)

type AzureConfig

type AzureConfig struct {
	URL       string
	PathStyle bool
}

AzureConfig selects an Azure Blob Storage container (Azure, Azure Stack Hub, Azurite). URL is the container URL with an optional prefix: https://<account>.blob.core.windows.net/<container>[/<prefix>]. With PathStyle the account is the first path segment, as the Azurite emulator and some private endpoints use: http://host:10000/<account>/<container>.

Credentials, from the environment, first match wins:

  • AZURE_STORAGE_KEY: the account key (Shared Key signing)
  • AZURE_STORAGE_SAS_TOKEN: a SAS token for the container
  • AZURE_FEDERATED_TOKEN_FILE + AZURE_CLIENT_ID + AZURE_TENANT_ID: AKS workload identity
  • AZURE_CLIENT_SECRET + AZURE_CLIENT_ID + AZURE_TENANT_ID: a service principal
  • AZURE_USE_MANAGED_IDENTITY=1 (AZURE_CLIENT_ID optional): the VM's or App Service's managed identity through the instance metadata service

type Blob

type Blob interface {
	// Get returns the object and its ETag. With ifNoneMatch equal to the
	// current ETag it returns ErrNotModified; a missing object is ErrNotFound.
	Get(ctx context.Context, key, ifNoneMatch string) ([]byte, string, error)
	// Put writes an object unconditionally.
	Put(ctx context.Context, key string, data []byte) error
	// PutIf writes only if the object's ETag is still ifMatch; an empty
	// ifMatch means the object must not exist yet. A lost race is ErrConflict.
	PutIf(ctx context.Context, key string, data []byte, ifMatch string) (string, error)
	// List returns every key under prefix, sorted.
	List(ctx context.Context, prefix string) ([]string, error)
	// Delete removes an object; a missing one is not an error.
	Delete(ctx context.Context, key string) error
	// Describe names the backend for logs ("dir /var/lib/prism-links").
	Describe() string
}

Blob is the storage a Store runs on: named objects with an ETag, and a compare-and-swap write so several server replicas can move a repository's branches without losing each other's updates. Keys are slash-separated ("github.com~acme~app/refs.json").

type Bundle

type Bundle struct {
	Format   int                        `json:"format"`
	Repo     string                     `json:"repo"` // stable name: host/org/repo, or the directory name
	SHA      string                     `json:"sha"`
	Ref      string                     `json:"ref,omitempty"` // branch it was exported from
	Dirty    bool                       `json:"dirty,omitempty"`
	Created  string                     `json:"created"`
	Packages []groveeng.ManifestPackage `json:"packages"`
	Requires []Require                  `json:"requires"`
	Refs     []Site                     `json:"refs"`
	Defs     []Def                      `json:"defs"`
}

Bundle is one repository's link data at one commit.

func Build

func Build(ctx context.Context, root, repo, ref string) (Bundle, error)

Build reads the existing index and manifests under root into a bundle. repo and ref override what git reports; both may be empty. It fails when root has no index.

type ConsumersRequest

type ConsumersRequest struct {
	Keys []string `json:"keys"`
	// ExcludePackages: "ecosystem:name" of packages the asker already
	// covers locally (its own, and its linked checkouts'). A repository
	// declaring one is skipped, so a site is not reported twice.
	ExcludePackages []string `json:"excludePackages,omitempty"`
	// Refs picks a branch per repository; others use their default.
	Refs map[string]string `json:"refs,omitempty"`
	// Packages are the asker's own packages ("ecosystem:name", as its
	// manifests declare them). A consumer's requirement on one of them is
	// its pin, also where the symbol key's package and the manifest's
	// artifact are named differently (jvm:com.acme.lib vs maven:com.acme:lib).
	Packages []string `json:"packages,omitempty"`
}

ConsumersRequest asks who references keys.

type ConsumersResponse

type ConsumersResponse struct {
	Repos      []RepoSites `json:"repos"`
	Searched   int         `json:"searched"`
	Unreadable int         `json:"unreadable,omitempty"`
}

ConsumersResponse lists the repositories that reference the keys, and how many repositories were searched, so "none found" is distinguishable from "none uploaded". Unreadable counts repositories the caller's credential may not read: they were not searched, and the answer is incomplete.

func AskConsumers

func AskConsumers(ctx context.Context, server string, req ConsumersRequest) (ConsumersResponse, error)

AskConsumers asks a server who references keys.

type Def

type Def struct {
	Key       string `json:"key"`
	Kind      string `json:"kind"`
	Name      string `json:"name"`
	Signature string `json:"signature,omitempty"`
	File      string `json:"file"`
	Line      int    `json:"line"`
}

Def is one symbol a repository declares that others can reference.

type DefineAnswer

type DefineAnswer struct {
	Repos      []RepoDefs `json:"repos"`
	Unreadable int        `json:"unreadable,omitempty"`
}

DefineAnswer is a define reply: the declaring repositories, and how many uploaded repositories the caller's token may not read (not searched).

func AskDefine

func AskDefine(ctx context.Context, server, key string) (DefineAnswer, error)

AskDefine asks a server where key is declared.

func AskDefineName

func AskDefineName(ctx context.Context, server, name string) (DefineAnswer, error)

AskDefineName asks a server where a symbol with this name is declared.

type FSBlob

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

FSBlob stores objects as files under a directory. It serves one host: compare-and-swap holds a lock file per key, which is safe between the processes of one machine but not across machines sharing a network file system. Several replicas need the S3 backend.

func OpenFS

func OpenFS(dir string) (*FSBlob, error)

OpenFS returns a filesystem backend rooted at dir, creating it.

func (*FSBlob) Delete

func (b *FSBlob) Delete(_ context.Context, key string) error

func (*FSBlob) Describe

func (b *FSBlob) Describe() string

func (*FSBlob) Get

func (b *FSBlob) Get(_ context.Context, key, ifNoneMatch string) ([]byte, string, error)

func (*FSBlob) List

func (b *FSBlob) List(_ context.Context, prefix string) ([]string, error)

func (*FSBlob) Put

func (b *FSBlob) Put(_ context.Context, key string, data []byte) error

func (*FSBlob) PutIf

func (b *FSBlob) PutIf(ctx context.Context, key string, data []byte, ifMatch string) (string, error)

type GCSBlob

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

GCSBlob is a Blob on a GCS bucket through the JSON API. The ETag is the object generation; PutIf uses ifGenerationMatch (0: must not exist), so several replicas can share the bucket.

func OpenGCS

func OpenGCS(ctx context.Context, c GCSConfig) (*GCSBlob, error)

OpenGCS checks the bucket is reachable with the credentials.

func (*GCSBlob) Delete

func (b *GCSBlob) Delete(ctx context.Context, key string) error

func (*GCSBlob) Describe

func (b *GCSBlob) Describe() string

func (*GCSBlob) Get

func (b *GCSBlob) Get(ctx context.Context, key, ifNoneMatch string) ([]byte, string, error)

func (*GCSBlob) List

func (b *GCSBlob) List(ctx context.Context, prefix string) ([]string, error)

func (*GCSBlob) Put

func (b *GCSBlob) Put(ctx context.Context, key string, data []byte) error

func (*GCSBlob) PutIf

func (b *GCSBlob) PutIf(ctx context.Context, key string, data []byte, ifMatch string) (string, error)

type GCSConfig

type GCSConfig struct {
	URL      string
	Endpoint string // default https://storage.googleapis.com, or STORAGE_EMULATOR_HOST
}

GCSConfig selects a Google Cloud Storage bucket: gs://bucket[/prefix]. Credentials, first match wins:

  • STORAGE_EMULATOR_HOST: an emulator (fake-gcs-server), no credentials
  • GOOGLE_APPLICATION_CREDENTIALS: a service-account key file
  • otherwise the metadata server (GCE, GKE workload identity, Cloud Run)

type ListenConfig

type ListenConfig struct {
	Addr string // host:port
	// TLSCert and TLSKey turn on HTTPS. The files are re-read when they
	// change, so a certificate can be rotated without a restart.
	TLSCert, TLSKey string
	// ClientCA, with TLS, requires a client certificate signed by it (mTLS).
	ClientCA string
	// MaxConns caps concurrent connections; 0 means 512.
	MaxConns int
	// OpsAddr, when set, serves /health and /metrics over plain HTTP.
	OpsAddr string
}

ListenConfig is how the server listens.

type Metrics

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

Metrics counts requests for /metrics in the Prometheus text format.

type OpenAuth

type OpenAuth struct{}

OpenAuth lets every request in with full rights (--no-auth).

func (OpenAuth) Authenticate

func (OpenAuth) Authenticate(*http.Request) (*Principal, error)

func (OpenAuth) Describe

func (OpenAuth) Describe() string

type Options

type Options struct {
	// Keep is how many commits per repository retention keeps, newest
	// first; commits a branch points at are always kept. 0 keeps all.
	Keep int
}

Options tune a Store.

type Principal

type Principal struct {
	ID     string // token id; "shared" for PRISM_LINK_TOKEN, "anonymous" with --no-auth
	Name   string
	Upload []string // repository-name globs it may upload
	Read   []string // repository-name globs it may read
	Admin  bool     // may delete repositories and commits, and run retention
}

Principal is the caller a credential stands for.

func (*Principal) CanRead

func (p *Principal) CanRead(repo string) bool

CanRead reports whether p may read repo's sites and declarations.

func (*Principal) CanUpload

func (p *Principal) CanUpload(repo string) bool

CanUpload reports whether p may store bundles under repo.

type Problem

type Problem struct {
	Repo, Key, Issue string
}

Problem is one integrity finding from Check.

type ReopenFile

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

ReopenFile is an audit destination that reopens its file on Reopen (call it on SIGHUP after logrotate moves the file).

func OpenAuditFile

func OpenAuditFile(path string) (*ReopenFile, error)

OpenAuditFile opens path for appending.

func (*ReopenFile) Reopen

func (r *ReopenFile) Reopen() error

func (*ReopenFile) Write

func (r *ReopenFile) Write(p []byte) (int, error)

type RepoDefs

type RepoDefs struct {
	Repo string `json:"repo"`
	SHA  string `json:"sha"`
	Ref  string `json:"ref,omitempty"`
	Defs []Def  `json:"defs"`
}

RepoDefs is where one repository declares a key.

type RepoSites

type RepoSites struct {
	Repo     string `json:"repo"`
	SHA      string `json:"sha"`
	Ref      string `json:"ref,omitempty"`
	Created  string `json:"created"`
	Requires string `json:"requires,omitempty"` // the pin on the asked-about package, as written
	Sites    []Site `json:"sites"`
}

RepoSites is one repository's answer.

type RepoSummary

type RepoSummary struct {
	Repo    string            `json:"repo"`
	Refs    map[string]string `json:"refs"`
	Latest  string            `json:"latest"`
	Commits int               `json:"commits"`
}

RepoSummary is one row of GET /link/repos.

type Require

type Require struct {
	Manifest  string `json:"manifest"`
	Ecosystem string `json:"ecosystem"`
	Name      string `json:"name"`
	Version   string `json:"version,omitempty"`
	Local     bool   `json:"local,omitempty"`
}

Require is one dependency a repository declares, as uploaded. It is the manifest requirement without its machine-local parts: Grove's LocalPath is an absolute path on the machine that exported the bundle (a CI runner's workspace) and its Evidence line can quote one (a go.work use), so neither leaves the machine. Local says only that the dependency was built from a local directory, so the version is not what it was built against.

type S3Blob

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

S3Blob is a Blob on an S3-compatible bucket. PutIf uses conditional writes (If-Match, If-None-Match: *), so several server replicas can share one bucket.

func OpenS3

func OpenS3(ctx context.Context, c S3Config) (*S3Blob, error)

OpenS3 checks the bucket is reachable with the credentials.

func (*S3Blob) Delete

func (b *S3Blob) Delete(ctx context.Context, key string) error

func (*S3Blob) Describe

func (b *S3Blob) Describe() string

func (*S3Blob) Get

func (b *S3Blob) Get(ctx context.Context, key, ifNoneMatch string) ([]byte, string, error)

func (*S3Blob) List

func (b *S3Blob) List(ctx context.Context, prefix string) ([]string, error)

func (*S3Blob) Put

func (b *S3Blob) Put(ctx context.Context, key string, data []byte) error

func (*S3Blob) PutIf

func (b *S3Blob) PutIf(ctx context.Context, key string, data []byte, ifMatch string) (string, error)

type S3Config

type S3Config struct {
	URL       string // s3://bucket[/prefix]
	Endpoint  string // default https://s3.<region>.amazonaws.com
	Region    string // default $AWS_REGION, else us-east-1
	PathStyle bool   // bucket in the path (MinIO), not the host name
}

S3Config selects an S3-compatible bucket (AWS S3, MinIO, Ceph, GCS interoperability). Credentials come from the environment: AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN, or web identity (AWS_ROLE_ARN + AWS_WEB_IDENTITY_TOKEN_FILE, as EKS IRSA sets).

type Server

type Server struct {
	Metrics *Metrics
	// contains filtered or unexported fields
}

Server is the link server's HTTP layer.

func NewServer

func NewServer(s *Store, o ServerOptions) *Server

NewServer wraps a store.

func (*Server) Handler

func (srv *Server) Handler() http.Handler

Handler is the public API.

func (*Server) OpsHandler

func (srv *Server) OpsHandler() http.Handler

OpsHandler serves /health and /metrics for probes and scraping, without credentials: bind it to a private address.

type ServerOptions

type ServerOptions struct {
	Auth Authenticator
	// Audit receives one JSON line per request; nil discards.
	Audit io.Writer
	// Log receives server events; nil discards.
	Log *slog.Logger
	// Rate is requests per second per credential (burst 2x); 0 disables.
	Rate float64
	// MaxBundleBytes caps an upload; 0 means 64 MiB.
	MaxBundleBytes int64
	// TrustProxy takes the client address from X-Forwarded-For.
	TrustProxy bool
}

ServerOptions configure the HTTP front of a Store.

type SharedToken

type SharedToken string

SharedToken is the v1.3 model: one secret with every right.

func (SharedToken) Authenticate

func (t SharedToken) Authenticate(r *http.Request) (*Principal, error)

func (SharedToken) Describe

func (SharedToken) Describe() string

type Site

type Site struct {
	Key  string `json:"key"`
	File string `json:"file"`
	From string `json:"from"`
	Line int    `json:"line"`
	Col  int    `json:"col,omitempty"`
	Text string `json:"text,omitempty"`
	Test bool   `json:"test,omitempty"`
}

Site is one place a repository references another's symbol.

type Stats

type Stats struct {
	Repositories, CachedBundles, CachedBytes int
}

Stats is what the metrics endpoint reports about the store.

type Store

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

Store keeps one bundle per repository and commit, and a small refs object per repository mapping each branch to the commit last uploaded from it. A commit's bundle never changes meaning; only refs move.

Queries are answered from memory: the catalog of every repository's refs is loaded at open and refreshed (Refresh, or Run in the background), and the bundles queries read are cached by commit. A replica sees its own uploads at once and other replicas' after the next refresh.

func Open

func Open(dir string) (*Store, error)

Open returns a store on a filesystem directory, creating it, with the default retention.

func OpenStore

func OpenStore(ctx context.Context, b Blob, o Options) (*Store, error)

OpenStore returns a store on any backend and loads its catalog.

func (*Store) Check

func (s *Store) Check(ctx context.Context) (repos, bundles int, problems []Problem, err error)

Check reads every stored object and reports refs that point at missing or unreadable bundles, unreadable refs, and bundles stored under the wrong repository.

func (*Store) Consumers

func (s *Store) Consumers(req ConsumersRequest) ConsumersResponse

Consumers answers a ConsumersRequest from every stored repository.

func (*Store) ConsumersFor

func (s *Store) ConsumersFor(ctx context.Context, req ConsumersRequest, allow Allow) ConsumersResponse

ConsumersFor answers from the repositories allow permits.

func (*Store) Define

func (s *Store) Define(key string) []RepoDefs

Define returns the declarations of key across repositories.

func (*Store) DefineFor

func (s *Store) DefineFor(ctx context.Context, key, name string, allow Allow) ([]RepoDefs, int)

DefineFor answers Define (key) or DefineName (name) from the repositories allow permits, and counts those it hid.

func (*Store) DefineName

func (s *Store) DefineName(name string) []RepoDefs

DefineName returns the declarations whose qualified name, or last name segment, is name: for a caller that has a name but no package for it.

func (*Store) DeleteCommit

func (s *Store) DeleteCommit(ctx context.Context, repo, sha string) error

DeleteCommit removes one commit's bundle. Branches that pointed at it are removed too, so answers fall back to the repository's other branches or its latest remaining upload.

func (*Store) DeleteRepo

func (s *Store) DeleteRepo(ctx context.Context, repo string) (int, error)

DeleteRepo removes everything stored for a repository.

func (*Store) Describe

func (s *Store) Describe() string

Describe names the backend and the number of repositories.

func (*Store) Handler

func (s *Store) Handler(token string) http.Handler

Handler serves the store over HTTP with one shared token (the v1.3 model); an empty token serves everyone. Server builds the full handler with per-token scopes, audit, limits and metrics.

func (*Store) Prune

func (s *Store) Prune(ctx context.Context, repo string, keep int) ([]string, error)

Prune deletes a repository's commits beyond the newest keep that no branch points at, and returns the commits it deleted. Bundles stored before history was recorded (v1.3.x) are listed from the backend and counted as oldest.

func (*Store) Put

func (s *Store) Put(b Bundle) error

Put stores a bundle and moves its branch to it. The refs update is a compare-and-swap, retried when another writer moved them first.

func (*Store) PutContext

func (s *Store) PutContext(ctx context.Context, b Bundle) error

PutContext is Put with a context.

func (*Store) Refresh

func (s *Store) Refresh(ctx context.Context) error

Refresh re-reads every repository's refs from the backend. Unchanged refs cost a conditional read; cached bundles no ref points at any more are dropped.

func (*Store) Repos

func (s *Store) Repos() []RepoSummary

Repos lists the catalog.

func (*Store) Run

func (s *Store) Run(ctx context.Context, every time.Duration, onErr func(error))

Run warms the cache, then refreshes the catalog (and warms what changed) every interval until ctx ends. Errors are passed to onErr (a log) and the next tick retries.

func (*Store) Stats

func (s *Store) Stats() Stats

func (*Store) Warm

func (s *Store) Warm(ctx context.Context)

Warm loads every repository's default bundle into memory, eight at a time, so the first queries after a start or a refresh do not wait on the backend (2.7 s for 1,000 cold bundles from S3 in the load test).

type Token

type Token struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	Hash    string   `json:"hash"` // "sha256:<hex>" of the secret
	Upload  []string `json:"upload,omitempty"`
	Read    []string `json:"read,omitempty"`
	Admin   bool     `json:"admin,omitempty"`
	Created string   `json:"created"`
	Expires string   `json:"expires,omitempty"` // RFC 3339; empty never expires
}

Token is one entry of a token file. The secret itself is never stored.

func CreateToken

func CreateToken(p string, spec TokenSpec) (string, Token, error)

CreateToken adds a token to the file (creating it) and returns the secret, which is shown once and stored only as a hash.

func ListTokens

func ListTokens(p string) ([]Token, error)

ListTokens returns the file's tokens (no secrets: only hashes are stored).

type TokenFileAuth

type TokenFileAuth struct {

	// Fallback, when set, also accepts the shared PRISM_LINK_TOKEN.
	Fallback Authenticator
	// contains filtered or unexported fields
}

TokenFileAuth authenticates against a token file, re-reading it when it changes, so a created or revoked token takes effect without a restart.

func OpenTokenFile

func OpenTokenFile(p string) (*TokenFileAuth, error)

OpenTokenFile reads a token file; it must exist and parse.

func (*TokenFileAuth) Authenticate

func (a *TokenFileAuth) Authenticate(r *http.Request) (*Principal, error)

func (*TokenFileAuth) Describe

func (a *TokenFileAuth) Describe() string

type TokenSpec

type TokenSpec struct {
	Name    string
	Upload  []string
	Read    []string
	Admin   bool
	Expires time.Duration // 0: never
}

TokenSpec is what a new token may do.

Directories

Path Synopsis
Command loadtest drives a running Prism link server with synthetic repositories and concurrent queries, and reports latency percentiles.
Command loadtest drives a running Prism link server with synthetic repositories and concurrent queries, and reports latency percentiles.

Jump to

Keyboard shortcuts

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