mid

package
v0.0.0-...-c624722 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package mid provides context support.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidID = errors.New("ID is not in its proper form")

ErrInvalidID represents a condition where the id is not a uuid.

Functions

func Basic

func Basic(ctx context.Context, ath *auth.Auth, userBus *userbus.Business, authorization string) (eauth.UID, *auth.Claims, error)

Basic processes basic authentication logic.

func Bearer

func Bearer(ctx context.Context, ath *auth.Auth, authorization string) (eauth.UID, *auth.Claims, error)

Bearer processes JWT authentication logic.

func GetHome

func GetHome(ctx context.Context) (homebus.Home, error)

GetHome returns the home from the context.

func GetProduct

func GetProduct(ctx context.Context) (productbus.Product, error)

GetProduct returns the product from the context.

func GetUser

func GetUser(ctx context.Context) (userbus.User, error)

GetUser extracts the user from the context.

func GetUserID

func GetUserID(ctx context.Context) (uuid.UUID, error)

GetUserID extracts the user id from the context.

func Metrics

Metrics sets the basic counters and guages.

func Panics

func Panics(v *metrics.Values, req middleware.Request, next middleware.Next) (resp middleware.Response)

Panics handles panics that occur when processing a request.

Types

type AuthInfo

type AuthInfo struct {
	Claims auth.Claims
	UserID uuid.UUID
	Rule   string
}

AuthInfo defines the information required to perform an authorization.

func Authorize

Authorize checks the user making the request is an admin or user.

func AuthorizeHome

func AuthorizeHome(homeBus *homebus.Business, req middleware.Request) (AuthInfo, middleware.Request, error)

AuthorizeHome checks the user making the call has specified a home id on the route that matches the claims.

func AuthorizeProduct

func AuthorizeProduct(productBus *productbus.Business, req middleware.Request) (AuthInfo, middleware.Request, error)

AuthorizeProduct checks the user making the call has specified a product id on the route that matches the claims.

func AuthorizeUser

func AuthorizeUser(userBus *userbus.Business, req middleware.Request) (AuthInfo, middleware.Request, error)

AuthorizeUser checks the user making the call has specified a user id on the route that matches the claims.

Jump to

Keyboard shortcuts

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