Documentation ¶
Index ¶
- Constants
- func CanAccess(db *gorm.DB, FeatureKey string, r *http.Request) bool
- type BeuboMiddleware
- func (bmw *BeuboMiddleware) Auth(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func (bmw *BeuboMiddleware) Plugin(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func (bmw *BeuboMiddleware) Site(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- func (bmw *BeuboMiddleware) Whitelist(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
- type Throttle
- type ThrottleClient
Constants ¶
const ( // UserContextKey is used to fetch and store the user struct from context UserContextKey key = "user" // SiteContextKey is used to fetch and store the site struct from context SiteContextKey key = "site" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BeuboMiddleware ¶
BeuboMiddleware holds parameters relevant to Beubo middlewares
func (*BeuboMiddleware) Auth ¶
func (bmw *BeuboMiddleware) Auth(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Auth checks if a user is authenticated and performs redirects if needed. The user struct is set to the request context if authenticated.
func (*BeuboMiddleware) Plugin ¶
func (bmw *BeuboMiddleware) Plugin(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Plugin allows plugins to perform actions as a middleware
func (*BeuboMiddleware) Site ¶
func (bmw *BeuboMiddleware) Site(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Site determines if the domain is an existing site and performs relevant actions based on this
func (*BeuboMiddleware) Whitelist ¶
func (bmw *BeuboMiddleware) Whitelist(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Whitelist checks the ip whitelist configuration. If ip whitelisting is enabled, it ensures the ip is whitelisted when accessing administrator pages
type Throttle ¶
type Throttle struct { IPs map[string]ThrottleClient Mu *sync.RWMutex Rate rate.Limit Burst int Cleanup time.Duration }
Throttle holds relevant parameters for configuring how the throttle middleware behaves
func (Throttle) Throttle ¶
func (t Throttle) Throttle(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Throttle prevents multiple repeated requests in a certain time period
type ThrottleClient ¶
ThrottleClient holds info about an ip such as it's rate limiter and the last time a request was made