auth

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator struct {
	Loader    IStoreWrapper
	Validator IAuthValidator
}

func NewAuthenticator

func NewAuthenticator(validator IAuthValidator, loader IStoreWrapper) *Authenticator

func (*Authenticator) Check

func (a *Authenticator) Check(ctx *fiber.Ctx) error

type Authorization

type Authorization struct {
	Loader IStoreWrapper
}

func NewAuthorization

func NewAuthorization(loader IStoreWrapper) (*Authorization, error)

func (*Authorization) Check

func (a *Authorization) Check(user IUserAuthInfo, method string, path string) error

type ConditionABAC

type ConditionABAC struct {
	Attribute string
	Operator  string
	Value     any
}

type IAuthStore

type IAuthStore interface {
	GetStore() IStore
}

type IAuthValidator

type IAuthValidator interface {
	Name() string
	GetValue() string
	ValidateKey(ctx *fiber.Ctx) error
	VerifyUser(ctx *fiber.Ctx, userKey string, userInfo IUserAuthInfo) (bool, error)
}

type IAuthenticationManager

type IAuthenticationManager interface {
	GetAuthenticatonHandler() fiber.Handler
}

type IAuthorization

type IAuthorization interface {
	port.Library

	Check(user IUserAuthInfo, method string, path string) error
}

type IAuthorizationManager

type IAuthorizationManager interface {
	GetAuthorization() IAuthorization
}

type IResourceInfo

type IResourceInfo interface {
	GetAction() string
	GetMethod() string
	GetPath() string
	GetControlType() string // 'RBAC' or 'ABAC'
	IsUserPermitted(user IUserAuthInfo) error
}

type IStore

type IStore interface {
	GetUserAuthInfo(ctx *fiber.Ctx, validator IAuthValidator) (IUserAuthInfo, error)
	GetResourceInfo(method string, path string) (IResourceInfo, error)
}

type IStoreWrapper

type IStoreWrapper interface {
	CheckUser(ctx *fiber.Ctx, validator IAuthValidator) error
	GetLoadedUser() IUserAuthInfo

	CheckResource(method string, path string) (bool, error)
	GetLoadedResource() IResourceInfo
}

type IUserAuthInfo

type IUserAuthInfo interface {
	GetControlType() string // 'RBAC' or 'ABAC'
}

type PolicyABAC

type PolicyABAC struct {
	Effect    string // 'Allow' or 'Deny'
	Action    string
	Condition []ConditionABAC // condition with 'AND' operator (Nested and OR operation not supported yet)
}

type ResourceInfoABAC

type ResourceInfoABAC struct {
	Action            string       `mapstructure:"action"`
	Path              string       `mapstructure:"path"`
	Method            string       `mapstructure:"method"`
	PermittedPolicies []PolicyABAC `mapstructure:"policies"`
}

func (*ResourceInfoABAC) GetAction

func (r2 *ResourceInfoABAC) GetAction() string

func (*ResourceInfoABAC) GetControlType

func (r2 *ResourceInfoABAC) GetControlType() string

func (*ResourceInfoABAC) GetMethod

func (r2 *ResourceInfoABAC) GetMethod() string

func (*ResourceInfoABAC) GetPath

func (r2 *ResourceInfoABAC) GetPath() string

func (*ResourceInfoABAC) IsAccessGranted

func (r2 *ResourceInfoABAC) IsAccessGranted(userPolicy PolicyABAC, policies []PolicyABAC) bool

func (*ResourceInfoABAC) IsUserPermitted

func (r2 *ResourceInfoABAC) IsUserPermitted(user IUserAuthInfo) error

type ResourceInfoRBAC

type ResourceInfoRBAC struct {
	Action         string   `mapstructure:"action"`
	Path           string   `mapstructure:"path"`
	Method         string   `mapstructure:"method"`
	PermittedRoles []string `mapstructure:"permissions"`
}

func (*ResourceInfoRBAC) GetAction

func (r1 *ResourceInfoRBAC) GetAction() string

func (*ResourceInfoRBAC) GetControlType

func (r1 *ResourceInfoRBAC) GetControlType() string

func (*ResourceInfoRBAC) GetMethod

func (r1 *ResourceInfoRBAC) GetMethod() string

func (*ResourceInfoRBAC) GetPath

func (r1 *ResourceInfoRBAC) GetPath() string

func (*ResourceInfoRBAC) IsUserPermitted

func (r1 *ResourceInfoRBAC) IsUserPermitted(user IUserAuthInfo) error

type StoreWrapper

type StoreWrapper struct {
	Store    IStore
	User     IUserAuthInfo
	Resource IResourceInfo
}

func NewStoreWrapper

func NewStoreWrapper(store IStore) *StoreWrapper

func (*StoreWrapper) CheckResource

func (u *StoreWrapper) CheckResource(method string, path string) (bool, error)

func (*StoreWrapper) CheckUser

func (u *StoreWrapper) CheckUser(ctx *fiber.Ctx, validator IAuthValidator) error

func (*StoreWrapper) GetLoadedResource

func (u *StoreWrapper) GetLoadedResource() IResourceInfo

func (*StoreWrapper) GetLoadedUser

func (u *StoreWrapper) GetLoadedUser() IUserAuthInfo

type UserAuthInfo

type UserAuthInfo struct {
}

type UserAuthInfoABAC

type UserAuthInfoABAC struct {
	UserAuthInfo
	UserId   string       `mapstructure:"key"`      // used by Api Key and JWT
	Username *string      `mapstructure:"user"`     // used by Basic Auth
	Password *string      `mapstructure:"password"` // used by Basic Auth
	Groups   []string     `mapstructure:"groups"`   // used by JWT Auth
	Policies []PolicyABAC `mapstructure:"policies"`
}

func (*UserAuthInfoABAC) GetControlType

func (u2 *UserAuthInfoABAC) GetControlType() string

func (*UserAuthInfoABAC) GetUserID

func (u2 *UserAuthInfoABAC) GetUserID() string

type UserAuthInfoRBAC

type UserAuthInfoRBAC struct {
	UserId   string   `mapstructure:"key"`         // used by Api Key and JWT
	Username *string  `mapstructure:"user"`        // used by Basic Auth
	Password *string  `mapstructure:"password"`    // used by Basic Auth
	Groups   []string `mapstructure:"groups"`      // used by JWT Auth
	Roles    []string `mapstructure:"permissions"` // combination of roles from all user groups owned by user
}

func (*UserAuthInfoRBAC) GetControlType

func (u1 *UserAuthInfoRBAC) GetControlType() string

func (*UserAuthInfoRBAC) GetUserID

func (u1 *UserAuthInfoRBAC) GetUserID() string

Jump to

Keyboard shortcuts

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