Documentation
¶
Index ¶
- Constants
- func AdminAPIMiddleware() echo.MiddlewareFunc
- func AdminDownloadMiddleware() echo.MiddlewareFunc
- func AdminPageMiddleware() echo.MiddlewareFunc
- func AuthLoginMiddleware() echo.MiddlewareFunc
- func AuthMiddleware() echo.MiddlewareFunc
- func DeadlineMiddleware() echo.MiddlewareFunc
- func DrainBody() echo.MiddlewareFunc
- func ProjectRequestMiddleware() echo.MiddlewareFunc
Constants ¶
const AdminEmailKey = "adminEmail"
AdminEmailKey holds the signed-in admin's email on the request context.
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.
const (
AuthHeaderName = "Authorization"
)
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.