Documentation
¶
Overview ¶
Package auth
Index ¶
- Constants
- func AddContext(authEnabled bool) echo.MiddlewareFunc
- func Admin(opts AdminOpts) echo.MiddlewareFunc
- func AuthMiddleware(opts AuthMiddlewareOpts) echo.MiddlewareFunc
- func IsAdmin(c *echo.Context) bool
- func IsAuthenticated(c *echo.Context) bool
- func Middleware(opts MiddlewareOpts) []echo.MiddlewareFunc
- func RegisterRoutes(h *http.HTTP, host *local.Host, db *gorm.DB, conf *config.Config) error
- func SessionMiddleware() echo.MiddlewareFunc
- type AdminOpts
- type AuthMiddlewareOpts
- type CallbackRequest
- type CreateTokenRequest
- type CreateTokenResponse
- type DeleteRequest
- type MiddlewareOpts
- type ProtectedRoute
- type ProtectedRoutes
Constants ¶
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 IsAuthenticated ¶ added in v2.6.0
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 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 DeleteRequest ¶
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 ProtectedRoutes ¶ added in v2.2.4
type ProtectedRoutes []ProtectedRoute