middleware

package
v0.0.0-...-802508d Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const AdminEmailKey = "adminEmail"

AdminEmailKey holds the signed-in admin's email on the request context.

View Source
const AdminHeader = "X-CS-Admin"

AdminHeader must be sent with every admin API call. Browsers cannot add a custom header to a cross-site request without a CORS preflight, which this server does not grant with credentials, so it blocks cross-site forgery.

View Source
const (
	AuthHeaderName = "Authorization"
)
View Source
const ProjectHeader = "X-CS-Project"

Variables

This section is empty.

Functions

func AdminAPIMiddleware

func AdminAPIMiddleware() echo.MiddlewareFunc

AdminAPIMiddleware guards the JSON admin endpoints.

func AdminDownloadMiddleware

func AdminDownloadMiddleware() echo.MiddlewareFunc

AdminDownloadMiddleware guards admin file downloads.

It deliberately skips the X-CS-Admin header that AdminAPIMiddleware demands: a browser download is a plain navigation and cannot add headers, so the signed-in session is the only check available. Nothing here changes state, so there is nothing for a forged request to abuse. Failures are JSON because this endpoint returns files, not pages.

func AdminPageMiddleware

func AdminPageMiddleware() echo.MiddlewareFunc

AdminPageMiddleware lets admins through to the admin page. Visitors who are not signed in go to the login page; signed-in non-admins see a 403 page.

func AuthLoginMiddleware

func AuthLoginMiddleware() echo.MiddlewareFunc

AuthLoginMiddleware

This middleware will redirect to profile from auth page if user is already logged in

func AuthMiddleware

func AuthMiddleware() echo.MiddlewareFunc

AuthMiddleware

This middleware where will redirect to login page if user is not logged in.

func DeadlineMiddleware

func DeadlineMiddleware() echo.MiddlewareFunc

DeadlineMiddleware

This middleware will check if the registration deadline has passed.

func DrainBody

func DrainBody() echo.MiddlewareFunc

DrainBody reads and discards whatever is left of the request body once the handler has returned.

Go's HTTP server closes the connection when a handler answers without consuming the whole body, and nginx - which is still streaming an upload to us at that moment - reports the truncated connection as a 502. Draining the rest first lets the client finish sending, so the real status (for example 401 when the session has expired) reaches the browser instead of a blank "Bad Gateway".

Attach it innermost, after the handler, on routes that accept large bodies.

func ProjectRequestMiddleware

func ProjectRequestMiddleware() echo.MiddlewareFunc

JSON plus a custom header prevents a third-party form from submitting links with the user's session. This is the same CSRF pattern as the admin API; session and team ownership are still checked by the handler.

Types

This section is empty.

Jump to

Keyboard shortcuts

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