middleware

package
v0.0.0-...-391b224 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const APIGroupExtension = "x-api-group"

Variables

This section is empty.

Functions

func APIGroupFromContext

func APIGroupFromContext(c *gin.Context) string

func CORS

func CORS() gin.HandlerFunc

CORS returns the gin CORS middleware for the api service. A preflight is answered and the chain stopped, since no route serves OPTIONS.

func CheckTeamAccessForRoute

func CheckTeamAccessForRoute(c *gin.Context, team *types.Team) error

CheckTeamAccessForRoute applies CheckTeamBanned, the api blocked-team allowlist and the read-only member check to a late-resolved team.

func EnforceBlockedTeam

func EnforceBlockedTeam() gin.HandlerFunc

EnforceBlockedTeam returns the gin middleware for the api service, configured with the api-specific blocked-team allowlist.

func EnforceReadOnlyMember

func EnforceReadOnlyMember() gin.HandlerFunc

EnforceReadOnlyMember returns the gin middleware for the api service, configured with the api-specific denied reads.

func InitLaunchDarklyContext

func InitLaunchDarklyContext(c *gin.Context)

func LabelMetricsWithTeam

func LabelMetricsWithTeam() gin.HandlerFunc

LabelMetricsWithTeam puts the authenticated team, its cluster and byoc (true for every cluster but the local one) on the request's metrics through the gin keys the metrics middleware reads once the chain has run, so the team the auth middleware resolves further down still labels the request.

func ReadRequestBody

func ReadRequestBody(limit int64) gin.HandlerFunc

ReadRequestBody reads the whole request body, up to limit bytes, before the request validator runs, and answers a body it cannot read itself: 413 when it is over the limit, else 400. The validator reads a routed request's body before authenticating anyway, so reading it here first adds only a copy in memory. A request no route matches gets 404, and nothing reads its body.

func RefuseDeletedProject

func RefuseDeletedProject(isProjectDeleted func(ctx context.Context, projectID uuid.UUID) (bool, error)) gin.HandlerFunc

RefuseDeletedProject answers 404 to a write addressed to a deleted project. A deleted project keeps its team row, so without this the handlers would still find it and apply the write.

func WithAPIGroup

WithAPIGroup records the validator's matched API group in Gin after authentication succeeds.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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