auth

package
v2.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 19 Imported by: 0 modules, 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

Overview

Package auth

Index

Constants

View Source
const (
	SessionCookieName      = "__Host-speedtest-session"
	APITokenSecurityScheme = "api_token"
	SessionSecurityScheme  = "session"
)

Variables

This section is empty.

Functions

func AddContext added in v2.4.1

func AddContext(authEnabled bool) echo.MiddlewareFunc

func Admin

func Admin(opts AdminOpts) echo.MiddlewareFunc

func AuthMiddleware

func AuthMiddleware(opts AuthMiddlewareOpts) echo.MiddlewareFunc

func IsAdmin added in v2.4.1

func IsAdmin(c *echo.Context) bool

func IsAuthenticated added in v2.6.0

func IsAuthenticated(c *echo.Context) bool

func Middleware added in v2.6.0

func Middleware(opts MiddlewareOpts) []echo.MiddlewareFunc

Middleware returns the authentication middleware in the order used by the API. Authentication context is always available; request authentication and administrator authorisation are only needed when auth is enabled.

func RegisterRoutes

func RegisterRoutes(
	h *http.HTTP,
	host *local.Host,
	db *gorm.DB,
	conf *config.Config,
) error

func SessionMiddleware

func SessionMiddleware() echo.MiddlewareFunc

Types

type AdminOpts added in v2.2.4

type AdminOpts struct {
	Routes ProtectedRoutes
}

type AuthMiddlewareOpts

type AuthMiddlewareOpts struct {
	// Routes are a slice of routes that MUST be authenticated
	Routes ProtectedRoutes

	Service    actorInvoker
	TokenRepo  tokenRepo
	AdminGroup string
}

type CallbackRequest

type CallbackRequest struct {
	Code  string `query:"code"`
	State string `query:"state"`
	Error string `query:"error"`
}

CallbackRequest contains the authorization code and CSRF state returned by the OIDC issuer. The auth actor validates and exchanges the code.

type CreateTokenRequest

type CreateTokenRequest struct {
	Name string `json:"name" description:"The name to identify the token by" validate:"required,min=5,max=255"`
}

type CreateTokenResponse

type CreateTokenResponse struct {
	Token  auth.Token `json:"token"`
	Secret string     `json:"secret"`
}

type DeleteRequest

type DeleteRequest struct {
	ID uuid.UUID `path:"id" param:"id"`
}

type MiddlewareOpts added in v2.6.0

type MiddlewareOpts struct {
	Enabled bool

	Service     actorInvoker
	TokenRepo   tokenRepo
	AdminGroup  string
	Routes      ProtectedRoutes
	AdminRoutes ProtectedRoutes
}

MiddlewareOpts configures the API authentication middleware stack.

type ProtectedRoute added in v2.2.4

type ProtectedRoute struct {
	Method string
	Path   string
}

type ProtectedRoutes added in v2.2.4

type ProtectedRoutes []ProtectedRoute

func (ProtectedRoutes) Contains added in v2.2.4

func (p ProtectedRoutes) Contains(c *echo.Context) bool

Jump to

Keyboard shortcuts

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