middleware

package
v0.36.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HasUsers bool
)

Functions

func ApiAuth

func ApiAuth(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionCopyFiles added in v0.19.0

func ApiPermissionCopyFiles(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionDownloadAuditLogs added in v0.24.0

func ApiPermissionDownloadAuditLogs(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionLinkUsers added in v0.34.0

func ApiPermissionLinkUsers(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionManageGroups

func ApiPermissionManageGroups(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionManageMCPServers added in v0.29.0

func ApiPermissionManageMCPServers(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionManageRoles

func ApiPermissionManageRoles(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionManageScripts added in v0.23.0

func ApiPermissionManageScripts(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionManageTemplates

func ApiPermissionManageTemplates(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionManageUsers

func ApiPermissionManageUsers(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionManageUsersOrSelf

func ApiPermissionManageUsersOrSelf(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionManageUsersOrSpaces

func ApiPermissionManageUsersOrSpaces(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionManageVariables

func ApiPermissionManageVariables(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionManageVolumes

func ApiPermissionManageVolumes(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionRunCommands added in v0.19.0

func ApiPermissionRunCommands(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionTransferSpaces

func ApiPermissionTransferSpaces(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionUseMCPServer added in v0.19.0

func ApiPermissionUseMCPServer(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionUsePools added in v0.28.0

func ApiPermissionUsePools(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionUseSpaces

func ApiPermissionUseSpaces(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionUseTunnels

func ApiPermissionUseTunnels(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionUseWebAssistant added in v0.19.0

func ApiPermissionUseWebAssistant(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionViewAuditLogs

func ApiPermissionViewAuditLogs(next http.HandlerFunc) http.HandlerFunc

func ApiPermissionViewClusterInfo

func ApiPermissionViewClusterInfo(next http.HandlerFunc) http.HandlerFunc

func CookieSecure added in v0.34.4

func CookieSecure(r *http.Request, cfg *config.ServerConfig) bool

CookieSecure reports whether the web session cookie should carry the Secure attribute: knot terminates TLS itself, or the request arrived encrypted — directly (r.TLS) or behind a proxy that advertises the frontend scheme (X-Forwarded-Proto). A spoofed X-Forwarded-Proto can only ever add Secure, never remove it, so honouring the header is safe. It must stay conditional: plain-HTTP deployments (TLS terminated elsewhere or none) would have a Secure cookie rejected by the browser, breaking sessions — and a Secure deletion cookie is likewise ignored on plain HTTP, which would break logout.

func DeleteSessionCookie

func DeleteSessionCookie(w http.ResponseWriter, r *http.Request)

func GetBearerToken

func GetBearerToken(w http.ResponseWriter, r *http.Request) string

func GetSessionFromCookie

func GetSessionFromCookie(r *http.Request) (*model.Session, error)

func HandlerToHandlerFunc added in v0.23.0

func HandlerToHandlerFunc(h http.Handler) http.HandlerFunc

HandlerToHandlerFunc converts an http.Handler to an http.HandlerFunc This is useful when you need to use an http.Handler with middleware that expects http.HandlerFunc

func Initialize

func Initialize()

func MCPServerContext added in v0.23.0

func MCPServerContext(mcpServer *mcp.Server, scriptToolsProvider ScriptToolsProvider, skillProviders SkillProviders) func(http.Handler) http.Handler

MCPServerContext adds the MCP server and request-scoped script tools and skills to the request context

func OptionalWebAuth added in v0.23.7

func OptionalWebAuth(next http.HandlerFunc) http.HandlerFunc

OptionalWebAuth injects the authenticated user into the context if a valid session cookie is present, but never redirects — unauthenticated requests pass through with no user in context.

func TokenScopesRequired added in v0.28.0

func TokenScopesRequired(next http.HandlerFunc) http.HandlerFunc

TokenScopesRequired wraps a handler with token-scope enforcement. If the request was authenticated via a scoped API token (i.e. the token in context has a non-empty Scopes slice), the request path must be covered by at least one of the token's scopes. Tokens with no scopes (nil/empty — the default for all pre-scopes tokens) are unrestricted. Session cookies and agent tokens bypass this check entirely.

func WebAuth

func WebAuth(next http.HandlerFunc) http.HandlerFunc

Types

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type ScriptToolsProvider added in v0.23.0

type ScriptToolsProvider func(ctx context.Context, user *model.User) []mcp.ToolProvider

ScriptToolsProvider is a callback function that returns the request-scoped ToolProviders for script tools. Returned as a slice — not merged into one mcp.NewMultiProvider — so each stays individually visible to mcp.GetToolProviders(ctx): a provider that also implements an optional interface (e.g. lmchatkit.SourcedToolProvider) needs to be discoverable by type assertion, which a MultiProvider wrapper would hide.

type SkillProviders added in v0.36.0

type SkillProviders func(ctx context.Context, user *model.User) (skills mcp.SkillProvider, resources mcp.ResourceProvider)

SkillProviders is a callback function that returns the request-scoped skills surface for a user: entries for skills/list and skills/get, plus the resource reads those entries point at (the same object usually, hence the two returns). Either may be nil when the user has no skills.

Jump to

Keyboard shortcuts

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