echoadapter

package module
v0.1.2-1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package echoadapter provides an RBAC middleware for Echo v5.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(enforcer *rbacgo.Enforcer, opts ...Option) echo.MiddlewareFunc

Middleware builds an Echo middleware. Register it with:

e.Use(echoadapter.Middleware(enforcer, echoadapter.WithUserID(...)))

Types

type Option

type Option func(*Options)

Option mutates Options.

func WithDeniedHandler

func WithDeniedHandler(fn func(*echo.Context) error) Option

WithDeniedHandler overrides the default 403 handler.

func WithResourceAction

func WithResourceAction(fn func(*echo.Context) (string, string)) Option

WithResourceAction sets the function that derives (resource, action) from the request. Defaults to (URL path, HTTP method).

func WithUnauthorizedHandler

func WithUnauthorizedHandler(fn func(*echo.Context) error) Option

WithUnauthorizedHandler overrides the default 401 handler.

func WithUserID

func WithUserID(fn func(*echo.Context) (string, bool)) Option

WithUserID sets the function that extracts an authenticated subject ID from the request. Empty or missing IDs are treated as unauthenticated (401). Defaults to reading the X-User-ID header.

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options configures the middleware.

Jump to

Keyboard shortcuts

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