Documentation
¶
Index ¶
- type Authenticator
- type Authorization
- type ConditionABAC
- type IAuthStore
- type IAuthValidator
- type IAuthenticationManager
- type IAuthorization
- type IAuthorizationManager
- type IResourceInfo
- type IStore
- type IStoreWrapper
- type IUserAuthInfo
- type PolicyABAC
- type ResourceInfoABAC
- func (r2 *ResourceInfoABAC) GetAction() string
- func (r2 *ResourceInfoABAC) GetControlType() string
- func (r2 *ResourceInfoABAC) GetMethod() string
- func (r2 *ResourceInfoABAC) GetPath() string
- func (r2 *ResourceInfoABAC) IsAccessGranted(userPolicy PolicyABAC, policies []PolicyABAC) bool
- func (r2 *ResourceInfoABAC) IsUserPermitted(user IUserAuthInfo) error
- type ResourceInfoRBAC
- type StoreWrapper
- type UserAuthInfo
- type UserAuthInfoABAC
- type UserAuthInfoRBAC
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
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 IAuthStore ¶
type IAuthStore interface {
GetStore() IStore
}
type IAuthValidator ¶
type IAuthenticationManager ¶
type IAuthorization ¶
type IAuthorizationManager ¶
type IAuthorizationManager interface {
GetAuthorization() IAuthorization
}
type IResourceInfo ¶
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
Click to show internal directories.
Click to hide internal directories.