middleware

package
v1.9.10-0...-1ccd1c0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const SecureSessionCookieName = "_nginx_ui_secure_session"
View Source
const SecureSessionVerifiedKey = "SecureSessionVerified"

Variables

View Source
var (
	ErrInvalidRequestFormat = e.New(40000, "invalid request format")
	ErrDecryptionFailed     = e.New(40001, "decryption failed")
	ErrFormParseFailed      = e.New(40002, "form parse failed")
	ErrDisabledInDemo       = e.New(40300, "this action is disabled in demo mode")
)

Functions

func AuthRequired

func AuthRequired() gin.HandlerFunc

AuthRequired is a middleware that checks if the user is authenticated

func AuthRequiredWS

func AuthRequiredWS() gin.HandlerFunc

AuthRequiredWS is a WebSocket-specific auth middleware that does NOT read cookies. This prevents CSWSH attacks by requiring explicit token passing via header or query param.

func CORS

func CORS() gin.HandlerFunc

func CacheJs

func CacheJs() gin.HandlerFunc

CacheJs is a middleware that send header to client to cache js file

func CheckWebSocketOrigin

func CheckWebSocketOrigin(r *http.Request) bool

CheckWebSocketOrigin validates browser origins for WebSocket upgrade requests. Authenticated node-to-node traffic is always allowed, regardless of the Origin header, because proxied requests carry the browser's original Origin which won't match the downstream node's host.

func DemoReadOnly

func DemoReadOnly() gin.HandlerFunc

DemoReadOnly blocks state-changing methods in demo mode while leaving reads intact. Use it on cosy CRUD groups where the listing is worth showing but the writes are not worth accepting.

func EncryptedForm

func EncryptedForm() gin.HandlerFunc

EncryptedForm handles multipart/form-data with encrypted fields while preserving file uploads

func EncryptedParams

func EncryptedParams() gin.HandlerFunc

func EnsureSecureSessionCookie

func EnsureSecureSessionCookie(c *gin.Context)

EnsureSecureSessionCookie makes sure the session-binding cookie exists.

func IPWhiteList

func IPWhiteList() gin.HandlerFunc

func Proxy

func Proxy() gin.HandlerFunc

func ProxyWs

func ProxyWs() gin.HandlerFunc

func RejectInDemo

func RejectInDemo() gin.HandlerFunc

RejectInDemo blocks a route outright when the node runs in demo mode.

It is meant for routes whose side effects escape the container: ACME issuance against a real CA, backup upload to object storage, outbound webhooks, process restart, and settings writes that could redirect any of the above. Local CRUD (sites, streams, configs) is deliberately left open, because the demo container runs on ephemeral disk and restores itself.

Note this is not redundant with RequireSecureSession: that middleware is a pass-through for users with no OTP, 2FA or passkey, and demo mode refuses TOTP enrollment, so the demo user can never trigger it.

func RequireInteractiveUser

func RequireInteractiveUser() gin.HandlerFunc

RequireInteractiveUser prevents a verified node principal from invoking controller-administration APIs intended only for a logged-in administrator.

func RequireSecureSession

func RequireSecureSession() gin.HandlerFunc

func SecureSessionCookie

func SecureSessionCookie() gin.HandlerFunc

SecureSessionCookie sets an HttpOnly SameSite=Lax cookie when serving the SPA. This cookie acts as a CSRF-proof session binding for the short token endpoint.

func ServeStatic

func ServeStatic() gin.HandlerFunc

func SetupAuthRequired

func SetupAuthRequired() gin.HandlerFunc

SetupAuthRequired authorizes first-run setup requests with the one-time install secret.

Types

type ServerFileSystemType

type ServerFileSystemType struct {
	http.FileSystem
}

func (ServerFileSystemType) Exists

func (f ServerFileSystemType) Exists(prefix string, _path string) bool

Jump to

Keyboard shortcuts

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