server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 127 Imported by: 0

Documentation

Overview

Package server builds the single chi router that serves every JFrog path prefix: /artifactory, /access, /event, /router, /jfconnect and /v2. Flat CRUD families come from the generated strict servers; item paths and protocol handlers are hand-written and mounted first (decision 0002).

Index

Constants

View Source
const DefaultRedirectTTL = 5 * time.Minute

DefaultRedirectTTL is how long a signed download URL stays valid when Config.Redirect sets no TTL.

Variables

This section is empty.

Functions

func New

func New(cfg Config) http.Handler

New returns the fully wired handler.

func OriginalContentType

func OriginalContentType(ctx context.Context) string

OriginalContentType returns the vendor media type a client sent before normalizeContentType rewrote it, or "" when the client sent a plain type.

func RegisterDebianSnapshotWork

func RegisterDebianSnapshotWork(q *work.Queue, cfg Config) error

RegisterDebianSnapshotWork must run before Queue.Run. The queued credential reference is checked against current credentials and permissions on every attempt, including retries after a restart.

Types

type AQLLimits

type AQLLimits struct {
	// MaxResults caps the rows of every query, its own limit included; zero
	// means no cap.
	MaxResults int
	// ScanFactor multiplies a non-admin query's limit, so that limit can
	// still be met once rows the caller may not read are dropped. Below 1
	// is 1. A request's scan-factor header above 1 overrides it.
	ScanFactor int
	// Timeout cancels a query's database work after this long, and
	// StreamTimeout one sent with a stream: true header; zero means no
	// timeout. The answer is then 408.
	Timeout, StreamTimeout time.Duration
}

AQLLimits bounds POST /api/search/aql (decision 0012).

type Config

type Config struct {
	// RequestLimits owns shared request rates and this process's concurrency
	// permits. Nil disables limits for embedders; the application wires them.
	RequestLimits *apilimit.Service
	// RemoteHTTP owns repository-scoped connection pools. The application closes
	// it after draining requests; source adapters resolve credentials per revision.
	RemoteHTTP *remote.Pool
	// Keys derives the key for short-lived Terraform download URLs.
	Keys *crypt.Keyring
	// BaseURL is the operator-configured public base URL; empty means derive
	// it from the request. Override and X-Forwarded-* headers take precedence.
	BaseURL string
	// CompatVersion is the Artifactory version reported to clients; it gates
	// client features, so it is configuration rather than the build version.
	CompatVersion string
	// Revision is the real artifactweave build identifier.
	Revision string
	// Logger receives access and panic logs; nil falls back to slog.Default so
	// tests and library users need not wire one.
	Logger *slog.Logger
	// RemoteSources is the direct remote read boundary. Nil preserves cache-only
	// behavior; production activation belongs to the adapter tickets. Native
	// protocols opt in separately through their pkgroute.Source map.
	RemoteSources *source.Service
	// RegistrySources opts Docker, OCI and OCI Helm into authenticated remote reads.
	RegistrySources *source.Service
	// Store is the metadata store and Blobs the blob store that the content
	// handlers read and write. ColdBlobs is the archive tier, nil when none
	// is configured.
	Store     store.Store
	Blobs     blob.Store
	ColdBlobs blob.Store
	// GC is the garbage collector the runtime schedules; POST
	// /api/system/storage/gc runs the same one. Nil builds one per request,
	// for tests.
	GC *gc.Collector
	// BlobLocation describes the hot blob store in the storage summary.
	BlobLocation usage.Location
	// Auth verifies credentials. Nil serves every route without
	// authentication, which only tests do: such a handler has no store and
	// answers just the system endpoints and the stubs.
	Auth *auth.Authenticator
	// Mirrors administers the blob mirrors; nil when no tier is a mirror.
	Mirrors Mirrors
	// RemoteStatus serves artifactweave-only, administrator-only diagnostics.
	RemoteStatus func(context.Context, string, string) (remote.SmartStatus, error)
	// Multipart serves the JFrog CLI's multipart upload protocol; nil
	// reports it unsupported, so the CLI uploads in one request.
	Multipart *multipart.Service
	// Tokens issues, refreshes and revokes access tokens for the token API;
	// nil answers that API 501.
	Tokens *token.Service
	// AllowBasicAuthTokens lets a password sent with Basic create tokens
	// through POST /access/api/v1/tokens (token.allow_basic_auth); the zero
	// value refuses it, as Artifactory 7.x does by default.
	AllowBasicAuthTokens bool
	// PasswordHash is the cost of passwords the security API sets; the zero
	// value is production's. Only Go code can choose another: tests use a
	// tiny cost.
	PasswordHash auth.HashParams
	// Redirect tunes downloadRedirect and cdnRedirect (decision 0029).
	Redirect Redirect
	// FolderDownloadMaxConcurrent is how many folder archive downloads run
	// at once (download.folder.max_concurrent_requests); zero means
	// Artifactory's 10.
	FolderDownloadMaxConcurrent int
	// AQL bounds AQL searches; the zero value has no cap. Its MaxResults
	// caps the GET searches too.
	AQL AQLLimits
	// Search limits what the GET searches return; the zero value limits
	// nothing.
	Search SearchLimits
	// DockerSubdomainMatch turns on the Docker subdomain method
	// (docker.subdomain_match): <repo>.<BaseURL host>/v2/... addresses repo.
	DockerSubdomainMatch bool
	// AllowDuplicateBuildEntries accepts a build-info publish whose module
	// lists one file twice (build.block_duplicate_entries false); the zero
	// value refuses it, as Artifactory 7.x does by default.
	AllowDuplicateBuildEntries bool
	// EnforceIdenticalChecksumDeploy makes a checksum deploy over a file
	// with the same content need the delete permission
	// (deploy.enforce_permission_check_on_identical_checksum_deploy); the
	// zero value lets it through with deploy alone, as Artifactory 7.x does
	// by default.
	EnforceIdenticalChecksumDeploy bool
	// NPMLoginTokenExpiry is how long a token from npm login lasts
	// (npm.login_token_expiry); zero means decision 0034's default.
	NPMLoginTokenExpiry time.Duration
	// NPMMaxPublishSize caps an npm publish request (npm.max_publish_size);
	// zero means decision 0034's default.
	NPMMaxPublishSize int64
	// GlobalEnvironmentLimit caps the global environments, DEV and PROD
	// included (environments.global_limit); zero means
	// roles.DefaultGlobalEnvironmentLimit.
	GlobalEnvironmentLimit int
	// Work is the runtime's work queue, which formats ask for derived work
	// (decision 0033). Nil writes that work to the store's queue directly,
	// where the workers find it on their next poll.
	Work *work.Queue
	// Formats returns a package type's format; nil means
	// FormatSettings.For. Only tests set it, to substitute formats that
	// record their hooks.
	Formats func(repo.PackageType) format.Handler
	// FormatSettings are the formats' server-wide options, such as
	// npm.tag_latest_by_publish; the zero value is each format's default.
	FormatSettings formats.Settings
	// CranArchiveMoverEnabled enables the administrator-only legacy archive
	// migration API. Its zero value leaves migration disabled.
	CranArchiveMoverEnabled bool
	HuggingFaceXetEnabled   bool
	// Protocols are mounted through the router kit after the built-in ones
	// (protocols). Only tests set it, to mount a test-only protocol.
	Protocols []pkgroute.Protocol
}

Config is what the router needs from the application configuration.

type MirrorStatus

type MirrorStatus struct {
	Tier string
	mirror.Status
}

MirrorStatus is one tier's mirror: "blob" or "cold_blob".

type Mirrors

type Mirrors interface {
	// Optimize asks every mirror for an immediate repair pass.
	Optimize()
	// Status returns each mirror's status.
	Status(ctx context.Context) ([]MirrorStatus, error)
}

Mirrors is what the storage endpoints need from the runtime's blob mirrors (#18).

type Redirect

type Redirect struct {
	// MinSize is the smallest file that redirects; zero redirects every file.
	// A descriptor's downloadRedirectConfig.fileMinimumSize, once applied,
	// takes its place.
	MinSize int64
	// TTL is how long a signed URL stays valid once handed out; zero means
	// DefaultRedirectTTL.
	TTL time.Duration
	// CDNMaxSize is the largest file sent to the CDN; a larger one goes to
	// storage under downloadRedirect and streams otherwise. Zero means no
	// limit. The application sets cdn.CloudFrontMaxSize when the blob store
	// has a CloudFront distribution.
	CDNMaxSize int64
}

Redirect tunes the download redirect policy.

type SearchLimits

type SearchLimits struct {
	// UserQueryLimit caps the results anonymous callers get, and every
	// non-admin's when LimitInternalUsers is set; zero means no cap.
	UserQueryLimit int
	// LimitInternalUsers applies UserQueryLimit to signed-in non-admins too.
	LimitInternalUsers bool
}

SearchLimits bounds the GET searches, as Artifactory's artifactory.search.userQueryLimit and limitAnonymousUsersOnly do.

Directories

Path Synopsis
Package agentpackages serves the APM v1 registry protocol on Agent Packages local and federated repositories.
Package agentpackages serves the APM v1 registry protocol on Agent Packages local and federated repositories.
Package aieditorextensions serves the VS Code gallery API for read-only remote extension repositories.
Package aieditorextensions serves the VS Code gallery API for read-only remote extension repositories.
Package ansible serves Galaxy v3 collection requests through the shared package protocol, source and item boundaries.
Package ansible serves Galaxy v3 collection requests through the shared package protocol, source and item boundaries.
Package apierror renders errors with the response profile each client expects.
Package apierror renders errors with the response profile each client expects.
Package baseurl resolves the public base URL a response must embed.
Package baseurl resolves the public base URL a response must embed.
Package bazelmodules serves the Bazel index registry protocol.
Package bazelmodules serves the Bazel index registry protocol.
Package bower serves the Bower registry and bower-art-resolver 2.0 protocol.
Package bower serves the Bower registry and bower-art-resolver 2.0 protocol.
Package cargo serves the HTTP sparse registry and Cargo web API.
Package cargo serves the HTTP sparse registry and Cargo web API.
Package chef serves the Chef Supermarket cookbook protocol.
Package chef serves the Chef Supermarket cookbook protocol.
Package cocoapods serves the current CocoaPods CDN protocol through /artifactory/api/pods/{repoKey}.
Package cocoapods serves the current CocoaPods CDN protocol through /artifactory/api/pods/{repoKey}.
Package composer serves Composer 1 local catalogs and Composer 2 metadata through the native Artifactory Composer URL.
Package composer serves Composer 1 local catalogs and Composer 2 metadata through the native Artifactory Composer URL.
Package conan serves the Conan revision protocol at /artifactory/api/conan.
Package conan serves the Conan revision protocol at /artifactory/api/conan.
Package conda serves the native Conda channel protocol.
Package conda serves the native Conda channel protocol.
Package docker serves the registry protocol, the OCI Distribution Specification v1.1 with Docker's extensions, for docker, oci and helmoci repositories (decisions 0003 and 0031).
Package docker serves the registry protocol, the OCI Distribution Specification v1.1 with Docker's extensions, for docker, oci and helmoci repositories (decisions 0003 and 0031).
Package gems serves RubyGems and Bundler's native repository protocol.
Package gems serves RubyGems and Bundler's native repository protocol.
gen
access
Package access provides primitives to interact with the openapi HTTP API.
Package access provides primitives to interact with the openapi HTTP API.
artifactory
Package artifactory provides primitives to interact with the openapi HTTP API.
Package artifactory provides primitives to interact with the openapi HTTP API.
distribution
Package distribution provides primitives to interact with the openapi HTTP API.
Package distribution provides primitives to interact with the openapi HTTP API.
event
Package event provides primitives to interact with the openapi HTTP API.
Package event provides primitives to interact with the openapi HTTP API.
grid
Package grid provides primitives to interact with the openapi HTTP API.
Package grid provides primitives to interact with the openapi HTTP API.
pfed
Package pfed provides primitives to interact with the openapi HTTP API.
Package pfed provides primitives to interact with the openapi HTTP API.
worker
Package worker provides primitives to interact with the openapi HTTP API.
Package worker provides primitives to interact with the openapi HTTP API.
Package gitlfs serves Git LFS batch and basic object transfers.
Package gitlfs serves Git LFS batch and basic object transfers.
Package golang serves Go module repositories at /artifactory/api/go/{repoKey}/ through the router kit (decisions 0032 and 0035): the GOPROXY reads the go command makes, and the deploys of jf go-publish.
Package golang serves Go module repositories at /artifactory/api/go/{repoKey}/ through the router kit (decisions 0032 and 0035): the GOPROXY reads the go command makes, and the deploys of jf go-publish.
Package helm serves classic Helm repositories under /api/helm/.
Package helm serves classic Helm repositories under /api/helm/.
Package hex serves the signed Hex registry v2 protocol.
Package hex serves the signed Hex registry v2 protocol.
Package huggingface serves the native Hugging Face Hub client protocol for model and dataset repositories using Artifactory's current ML layout.
Package huggingface serves the native Hugging Face Hub client protocol for model and dataset repositories using Artifactory's current ML layout.
Package jetbrainsplugins serves the JetBrains Marketplace host protocol for remote JetBrains Plugins repositories.
Package jetbrainsplugins serves the JetBrains Marketplace host protocol for remote JetBrains Plugins repositories.
Package luarocks serves local and federated LuaRocks repositories through the native flat rocks-server URL and the native upload API.
Package luarocks serves local and federated LuaRocks repositories through the native flat rocks-server URL and the native upload API.
Package machinelearning implements the FrogML SDK's Artifactory model transaction and manifest API on local and one-node federated repositories.
Package machinelearning implements the FrogML SDK's Artifactory model transaction and manifest API on local and one-node federated repositories.
Package nimmodel serves the documented NGC metadata and model-resource URLs through a remote NIM repository.
Package nimmodel serves the documented NGC metadata and model-resource URLs through a remote NIM repository.
Package nix serves the native Nix HTTP binary-cache protocol.
Package nix serves the native Nix HTTP binary-cache protocol.
Package npm serves the npm registry of npm repositories at /artifactory/api/npm/{repoKey}/ (decision 0034), mounted through the router kit (decision 0032).
Package npm serves the npm registry of npm repositories at /artifactory/api/npm/{repoKey}/ (decision 0034), mounted through the router kit (decision 0032).
Package nuget serves NuGet's protocols on NuGet repositories (decision 0038), mounted through the router kit (decision 0032): the v3 API under /artifactory/api/nuget/v3/{repoKey}/ (V3) and, under /artifactory/api/nuget/{repoKey}/, the v2 Atom feed and the push, delete and relist the v3 index's PackagePublish names (V2).
Package nuget serves NuGet's protocols on NuGet repositories (decision 0038), mounted through the router kit (decision 0032): the v3 API under /artifactory/api/nuget/v3/{repoKey}/ (V3) and, under /artifactory/api/nuget/{repoKey}/, the v2 Atom feed and the push, delete and relist the v3 index's PackagePublish names (V2).
Package pkgroute is the router kit for package formats with a protocol of their own: npm and Go in P7, then PyPI, NuGet, Helm and Terraform (decision 0032).
Package pkgroute is the router kit for package formats with a protocol of their own: npm and Go in P7, then PyPI, NuGet, Helm and Terraform (decision 0032).
Package pub serves the hosted Dart pub protocol through Artifactory's /artifactory/api/pub/{repo} URL.
Package pub serves the hosted Dart pub protocol through Artifactory's /artifactory/api/pub/{repo} URL.
Package puppet serves the Forge v3 module protocol.
Package puppet serves the Forge v3 module protocol.
Package pypi serves PyPI repositories at /artifactory/api/pypi/{repoKey}/ through the router kit (decisions 0032 and 0037): the simple repository API that pip, uv and Poetry install from, in HTML (PEP 503) and, when pypi.simple_json is on, JSON (PEP 691), with the wheels' core metadata files (PEP 658) when pypi.core_metadata is on, and the files themselves through the item routes' download, so redirects, Range and download counts apply to them as to any file.
Package pypi serves PyPI repositories at /artifactory/api/pypi/{repoKey}/ through the router kit (decisions 0032 and 0037): the simple repository API that pip, uv and Poetry install from, in HTML (PEP 503) and, when pypi.simple_json is on, JSON (PEP 691), with the wheels' core metadata files (PEP 658) when pypi.core_metadata is on, and the files themselves through the item routes' download, so redirects, Range and download counts apply to them as to any file.
Package skills serves the local ClawHub-compatible Skills publish API.
Package skills serves the local ClawHub-compatible Skills publish API.
Package swift serves the Swift Package Registry API on Artifactory's /artifactory/api/swift/{repo} prefix.
Package swift serves the Swift Package Registry API on Artifactory's /artifactory/api/swift/{repo} prefix.
Package terraform serves Terraform's discovery and module registry through the package router kit (decision 0040).
Package terraform serves Terraform's discovery and module registry through the package router kit (decision 0040).
Package terraformbackend serves the TFE-shaped API used by Terraform's remote backend (decision 0041).
Package terraformbackend serves the TFE-shaped API used by Terraform's remote backend (decision 0041).
Package vagrant serves the native Vagrant box catalog at Artifactory's prefix.
Package vagrant serves the native Vagrant box catalog at Artifactory's prefix.
Package vcs implements the remote-only Artifactory VCS archive protocol.
Package vcs implements the remote-only Artifactory VCS archive protocol.

Jump to

Keyboard shortcuts

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