authorization

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CodeTypeMissingAccountId indicates that the accountId was not present on the context
	CodeTypeMissingAccountId errors.CodeType = "MISSING_ACCOUNT_ID"
	// CodeTypeMissingBrandId indicates that the brandId was not present on the context
	CodeTypeMissingBrandId errors.CodeType = "MISSING_BRAND_ID"
	// CodeTypeErrorExecutingAuthorizationQuery indicates that it was not possible to execute authorization client query
	CodeTypeErrorExecutingAuthorizationQuery errors.CodeType = "CANT_EXECUTE_AUTH_QUERY"
	// CodeTypeAccessDenied indicates that authorizatior client denied account access
	CodeTypeAccessDenied errors.CodeType = "ACCESS_DENIED"
)
View Source
const ContextKeyAllowedStores string = "allowed_stores"

ContextKeyAllowedStores is the context key that get and sets all accounts allowed stores

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountAuthorizator

type AccountAuthorizator struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

AccountAuthorizator is the struct responsible for create account authorizarion

func MustNewAccountAuthorizator

func MustNewAccountAuthorizator(
	logger infra.Logger,
	authClient infra.AuthorizatorClient,
	authorizatorTimeout time.Duration,
	resourceName string,
	resourseFilters []ResourseFilter,
) AccountAuthorizator

MustNewAccountAuthorizator constructs a new account authorization middleware. It panics if any error is found.

func NewAccountAuthorizator

func NewAccountAuthorizator(
	logger infra.Logger,
	authClient infra.AuthorizatorClient,
	authorizatorTimeout time.Duration,
	resourceName string,
	resourseFilters []ResourseFilter,
) (AccountAuthorizator, error)

NewAccountAuthorizator constructs a new account authorization middleware

func (AccountAuthorizator) Authorize

func (a AccountAuthorizator) Authorize(ctx *routing.Context) error

Authorize is the middleware responsible for calling the auth client and check if user is authorized to make the current request

type ResourseFilter

type ResourseFilter int

ResourseFilter defines a type that represents a resource filter as an integer

const (
	// StoreFilter means a numeric representation of the stores filter
	StoreFilter ResourseFilter = iota
)

func (ResourseFilter) String

func (s ResourseFilter) String() string

String returns the equivalent string of the Resource filters integers

Jump to

Keyboard shortcuts

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