middleware

package
v1.9.6 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const OrganizationIdContextKey = "organizationId"
View Source
const ProjectContextKey = "project"
View Source
const ProjectIdContextKey = "project_id"
View Source
const UserEmailContextKey = "userEmail"
View Source
const UserIdContextKey = "userId"
View Source
const UserOrgRoleContextKey = "userOrgRole"

Variables

View Source
var (
	CORSReport    = cors("POST, OPTIONS", "Content-Type, Content-Encoding, Authorization", "", "")
	MCPCors       = cors("GET, POST, DELETE, OPTIONS", mcpAllowHeaders, "Mcp-Session-Id, WWW-Authenticate", "600")
	WellKnownCors = cors("GET, OPTIONS", mcpAllowHeaders, "", "600")
	OAuthCors     = cors("POST, OPTIONS", mcpAllowHeaders, "", "600")
)
View Source
var ErrInvalidBearer = errors.New("invalid bearer token")
View Source
var ErrProjectIdNotInContext = errors.New("projectId not found in context - ensure RequireProjectAccess middleware is applied")
View Source
var RequireAdminAccess gin.HandlerFunc
View Source
var RequireProjectAccess gin.HandlerFunc

RequireProjectAccess middleware validates that the authenticated user has access to the requested project. A user can access a project if they are a member of the project's organization. This middleware should be applied AFTER UseAppAuth.

View Source
var RequireWriteAccess gin.HandlerFunc

RequireWriteAccess middleware checks if the user has write access to the project's organization. It blocks access for users with 'readonly' role. This middleware should be applied AFTER UseAppAuth.

View Source
var UseAppAuth func(c *gin.Context)
View Source
var UseClientAuth func(c *gin.Context)
View Source
var UseSourceMapAuth func(c *gin.Context)

Functions

func GetOrganizationId

func GetOrganizationId(c *gin.Context) int

func GetProjectId

func GetProjectId(c *gin.Context) (uuid.UUID, error)

GetProjectId retrieves the project ID from the Gin context

func GetUserEmail

func GetUserEmail(c *gin.Context) string

func GetUserId

func GetUserId(c *gin.Context) int

func GetUserOrgRole

func GetUserOrgRole(c *gin.Context) string

func IngestAdmission added in v1.9.5

func IngestAdmission(c *gin.Context)

func InitRequireAdminAccess

func InitRequireAdminAccess()

func InitRequireProjectAccess

func InitRequireProjectAccess()

func InitRequireWriteAccess

func InitRequireWriteAccess()

func InitUseAppAuth

func InitUseAppAuth()

func InitUseClientAuth

func InitUseClientAuth()

func InitUseSourceMapAuth

func InitUseSourceMapAuth()

func RateLimitPerIP added in v1.8.14

func RateLimitPerIP(maxRequests int, window time.Duration) gin.HandlerFunc

RateLimitPerIP returns a fixed-window per-IP rate limiter for unauthenticated endpoints that persist state per request (e.g. the device-authorize endpoint, which inserts a main-DB row per call). Buckets live in memory; stale ones are swept on each request, so the map stays bounded by the number of distinct IPs seen within one window.

func Transactional

func Transactional(c *gin.Context)

func UseGzip

func UseGzip(c *gin.Context)

Types

type BearerIdentity added in v1.8.15

type BearerIdentity struct {
	UserId  int
	Email   string
	Expires time.Time
}

func AuthenticateBearer added in v1.8.15

func AuthenticateBearer(tokenString string) (*BearerIdentity, error)

Jump to

Keyboard shortcuts

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