Documentation
¶
Overview ¶
Package middleware provides HTTP middleware for AppView, including authentication (session-based for web UI, token-based for registry), identity resolution (handle/DID to PDS endpoint), and hold discovery for routing blobs to storage endpoints.
Index ¶
- func ExtractAuthMethod(next http.Handler) http.Handler
- func GetGlobalAuthorizer() auth.HoldAuthorizer
- func GetUser(r *http.Request) *db.User
- func GoImport(modulePath, repoURL string) func(http.Handler) http.Handler
- func OptionalAuth(store *db.SessionStore, database *sql.DB) func(http.Handler) http.Handler
- func RequireAuth(store *db.SessionStore, database *sql.DB) func(http.Handler) http.Handler
- func RetryAfterMiddleware(next http.Handler) http.Handler
- func SetGlobalAuthorizer(authorizer auth.HoldAuthorizer)
- func SetGlobalDatabase(database storage.HoldDIDLookup)
- func SetGlobalLabelChecker(checker LabelChecker)
- func SetGlobalManifestRefChecker(checker storage.ManifestReferenceChecker)
- func SetGlobalRefresher(refresher *oauth.Refresher)
- func SetGlobalWebhookDispatcher(dispatcher storage.PushWebhookDispatcher)
- func WithUser(r *http.Request, user *db.User) *http.Request
- type LabelChecker
- type NamespaceResolver
- func (nr *NamespaceResolver) BlobStatter() distribution.BlobStatter
- func (nr *NamespaceResolver) Blobs() distribution.BlobEnumerator
- func (nr *NamespaceResolver) Repositories(ctx context.Context, repos []string, last string) (int, error)
- func (nr *NamespaceResolver) Repository(ctx context.Context, name reference.Named) (distribution.Repository, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractAuthMethod ¶
ExtractAuthMethod is an HTTP middleware that extracts the auth method and puller DID from the JWT Authorization header and stores them in the request context for later use by the registry middleware. Also stores the HTTP method for routing decisions (GET/HEAD = pull, PUT/POST = push).
func GetGlobalAuthorizer ¶
func GetGlobalAuthorizer() auth.HoldAuthorizer
GetGlobalAuthorizer returns the global authorizer instance Used by components that need to clear denial cache (e.g., EnsureCrewMembership)
func GoImport ¶ added in v0.1.3
GoImport serves the `<meta name="go-import">` tag required by `go install` / `go get` to resolve the vanity path `atcr.io/...` to the source repository.
Go tooling requests `https://atcr.io/<subpath>?go-get=1` and expects an HTML document with a meta tag of the form:
<meta name="go-import" content="<root> <vcs> <repo-url>">
The meta tag must be present on every subpath under the module root, so this runs as middleware at the top of the chain and short-circuits any request carrying `?go-get=1`.
func OptionalAuth ¶
OptionalAuth is middleware that optionally includes user if authenticated
func RequireAuth ¶
RequireAuth is middleware that requires authentication
func RetryAfterMiddleware ¶ added in v0.1.3
RetryAfterMiddleware installs a per-request RetryAfterCarrier in the request context and wraps the response writer so deeper handlers (e.g., the manifest store, when an upstream PDS returns 429) can cause a Retry-After header to be emitted on 429 responses.
func SetGlobalAuthorizer ¶
func SetGlobalAuthorizer(authorizer auth.HoldAuthorizer)
SetGlobalAuthorizer sets the authorizer instance during initialization Must be called before the registry starts serving requests
func SetGlobalDatabase ¶
func SetGlobalDatabase(database storage.HoldDIDLookup)
SetGlobalDatabase sets the database instance during initialization Must be called before the registry starts serving requests
func SetGlobalLabelChecker ¶ added in v0.1.3
func SetGlobalLabelChecker(checker LabelChecker)
SetGlobalLabelChecker sets the label checker instance during initialization
func SetGlobalManifestRefChecker ¶
func SetGlobalManifestRefChecker(checker storage.ManifestReferenceChecker)
SetGlobalManifestRefChecker sets the manifest reference checker during initialization
func SetGlobalRefresher ¶
SetGlobalRefresher sets the OAuth refresher instance during initialization Must be called before the registry starts serving requests
func SetGlobalWebhookDispatcher ¶
func SetGlobalWebhookDispatcher(dispatcher storage.PushWebhookDispatcher)
SetGlobalWebhookDispatcher sets the push webhook dispatcher during initialization Must be called before the registry starts serving requests
Types ¶
type LabelChecker ¶ added in v0.1.3
LabelChecker checks whether content has been taken down via ATProto labels.
type NamespaceResolver ¶
type NamespaceResolver struct {
distribution.Namespace
// contains filtered or unexported fields
}
NamespaceResolver wraps a namespace and resolves names
func (*NamespaceResolver) BlobStatter ¶
func (nr *NamespaceResolver) BlobStatter() distribution.BlobStatter
BlobStatter delegates to underlying namespace
func (*NamespaceResolver) Blobs ¶
func (nr *NamespaceResolver) Blobs() distribution.BlobEnumerator
Blobs delegates to underlying namespace
func (*NamespaceResolver) Repositories ¶
func (nr *NamespaceResolver) Repositories(ctx context.Context, repos []string, last string) (int, error)
Repositories delegates to underlying namespace
func (*NamespaceResolver) Repository ¶
func (nr *NamespaceResolver) Repository(ctx context.Context, name reference.Named) (distribution.Repository, error)
Repository resolves the repository name and delegates to underlying namespace Handles names like: - atcr.io/alice/myimage → resolve alice to DID - atcr.io/did:plc:xyz123/myimage → use DID directly