Documentation
¶
Index ¶
- Constants
- Variables
- func AuthUserDisplay(ctx WithAuthUser) string
- func EncodeAndSetBearer(ctx AuthContext, enc AuthParameterEncryption, obj interface{}) error
- func GetAndDecodeBearer(ctx AuthContext, enc AuthParameterEncryption, obj interface{}) (bool, error)
- func GetAuthBearer(ctx AuthContext) string
- func SetAuthBearer(ctx AuthContext, value string)
- func Tenancy(ctx UserContext) string
- type Aggregation
- type Auth
- type AuthBase
- func (a *AuthBase) AttachToErrorManager(errManager generic_error.ErrorManager)
- func (a *AuthBase) Config() interface{}
- func (a *AuthBase) EndpointsConfig() EndpointsAuthConfig
- func (a *AuthBase) HandleRequest(ctx AuthContext, path string, access access_control.AccessType) error
- func (a *AuthBase) Init(cfg config.Config, log logger.Logger, vld validator.Validator, ...) error
- func (a *AuthBase) Manager() AuthManager
- type AuthBaseConfig
- type AuthContext
- type AuthDataAccessor
- type AuthHandler
- type AuthHandlerBase
- func (a *AuthHandlerBase) ErrorDescriptions() map[string]string
- func (a *AuthHandlerBase) ErrorProtocolCodes() map[string]int
- func (a *AuthHandlerBase) Handlers() []AuthHandler
- func (a *AuthHandlerBase) Init(protocol string)
- func (a *AuthHandlerBase) Protocol() string
- func (a *AuthHandlerBase) SetAuthManager(manager AuthManager)
- type AuthManager
- type AuthManagerBase
- func (a *AuthManagerBase) ErrorDescriptions() map[string]string
- func (a *AuthManagerBase) ErrorProtocolCodes() map[string]int
- func (a *AuthManagerBase) Handle(ctx AuthContext, schema string) error
- func (a *AuthManagerBase) Handlers() HandlerStore
- func (a *AuthManagerBase) Init(cfg config.Config, log logger.Logger, vld validator.Validator, ...) error
- func (a *AuthManagerBase) Schemas() HandlerStore
- type AuthParameterEncryption
- type AuthParameterEncryptionBase
- func (a *AuthParameterEncryptionBase) Config() interface{}
- func (a *AuthParameterEncryptionBase) CurrentTag() string
- func (a *AuthParameterEncryptionBase) DecodeAuthParameter(ctx AuthContext, name string, value string, obj interface{}, tag ...string) (bool, error)
- func (a *AuthParameterEncryptionBase) EncodeAuthParameter(ctx AuthContext, name string, obj interface{}) (string, error)
- func (a *AuthParameterEncryptionBase) Encrypt(ctx op_context.Context, obj interface{}) (string, error)
- func (a *AuthParameterEncryptionBase) GetAuthParameter(ctx AuthContext, authMethodProtocol string, name string, obj interface{}, ...) (bool, error)
- func (a *AuthParameterEncryptionBase) Init(cfg config.Config, log logger.Logger, vld validator.Validator, ...) error
- func (a *AuthParameterEncryptionBase) SetAuthParameter(ctx AuthContext, authMethodProtocol string, name string, obj interface{}, ...) error
- type AuthParameterEncryptionBaseConfig
- type AuthSchema
- func (a *AuthSchema) Aggregation() Aggregation
- func (a *AuthSchema) AppendHandlers(handler ...AuthHandler)
- func (a *AuthSchema) Config() interface{}
- func (s *AuthSchema) Construct()
- func (a *AuthSchema) Handle(ctx AuthContext) (bool, error)
- func (a *AuthSchema) Handlers() []AuthHandler
- func (a *AuthSchema) Init(cfg config.Config, log logger.Logger, vld validator.Validator, ...) error
- func (a *AuthSchema) InitSchema(log logger.Logger, cfg config.Config, vld validator.Validator, ...) error
- func (a *AuthSchema) Protocol() string
- func (a *AuthSchema) SetAggregation(aggregation Aggregation)
- type AuthSchemaConfig
- type ContextWithAuthUser
- type EndpointSchema
- type EndpointsAuth
- type EndpointsAuthConfig
- type EndpointsAuthConfigBase
- func (e *EndpointsAuthConfigBase) AddSchema(path string, access access_control.AccessType, schema string)
- func (e *EndpointsAuthConfigBase) Init(cfg config.Config, log logger.Logger, vld validator.Validator, ...) error
- func (e *EndpointsAuthConfigBase) Schema(path string, access access_control.AccessType) (string, bool)
- type ExpireToken
- type HandlerFactory
- type HandlerStore
- type HandlerStoreBase
- type NoAuth
- type NoAuthMethod
- type Session
- type SessionBase
- type TenancyUserContext
- type User
- type UserBase
- type UserContext
- type UserContextBase
- type WithAuth
- type WithAuthBase
- type WithAuthUser
- type WithUser
- type WithUserBase
Constants ¶
View Source
const ( ErrorCodeInvalidAuthSchema string = "invalid_auth_schema" ErrorCodeUnsupportedAuthMethod string = "unknown_auth_method" )
View Source
const AggregationProtocol = "aggregation"
View Source
const AuthorizationBearer = "bearer"
View Source
const AuthorizationHeader = "authorization"
View Source
const NoAuthProtocol = "noauth"
Variables ¶
View Source
var ErrorDescriptions = map[string]string{ ErrorCodeUnauthorized: "Request is not authorized", ErrorCodeInvalidAuthSchema: "Invalid authorization schema", ErrorCodeUnsupportedAuthMethod: "Unsupported authorization method", }
View Source
var ErrorHttpCodes = map[string]int{ ErrorCodeUnauthorized: http.StatusUnauthorized, ErrorCodeInvalidAuthSchema: http.StatusInternalServerError, ErrorCodeUnsupportedAuthMethod: http.StatusUnauthorized, }
Functions ¶
func AuthUserDisplay ¶
func AuthUserDisplay(ctx WithAuthUser) string
func EncodeAndSetBearer ¶
func EncodeAndSetBearer(ctx AuthContext, enc AuthParameterEncryption, obj interface{}) error
func GetAndDecodeBearer ¶
func GetAndDecodeBearer(ctx AuthContext, enc AuthParameterEncryption, obj interface{}) (bool, error)
func GetAuthBearer ¶
func GetAuthBearer(ctx AuthContext) string
func SetAuthBearer ¶
func SetAuthBearer(ctx AuthContext, value string)
func Tenancy ¶
func Tenancy(ctx UserContext) string
Types ¶
type Aggregation ¶
type Aggregation = string
const ( And Aggregation = "and" Or Aggregation = "or" )
type Auth ¶
type Auth interface {
generic_error.ErrorDefinitions
HandleRequest(ctx AuthContext, path string, access access_control.AccessType) error
}
type AuthBase ¶
type AuthBase struct {
AuthBaseConfig
// contains filtered or unexported fields
}
func (*AuthBase) AttachToErrorManager ¶
func (a *AuthBase) AttachToErrorManager(errManager generic_error.ErrorManager)
func (*AuthBase) EndpointsConfig ¶
func (a *AuthBase) EndpointsConfig() EndpointsAuthConfig
func (*AuthBase) HandleRequest ¶
func (a *AuthBase) HandleRequest(ctx AuthContext, path string, access access_control.AccessType) error
func (*AuthBase) Manager ¶
func (a *AuthBase) Manager() AuthManager
type AuthBaseConfig ¶
type AuthBaseConfig struct {
DEFAULT_SCHEMA string `default:"check_token"`
}
type AuthContext ¶
type AuthContext interface {
UserContext
Session
GetSessionParameter(key string) string
SetSessionParameter(key string, value string)
LoadSessionParameters(parameters map[string]string)
StoreSessionParameters() map[string]string
GetRequestContent() []byte
CheckRequestContent(smsMessage *string, skipSms *bool) error
GetRequestPath() string
GetRequestMethod() string
GetResourceId(resourceType string) api.ResourceId
ResourceIds() api.ResourceIds
GetTenancyId() string
GetRequestClientIp() string
GetRequestUserAgent() string
SetAuthParameter(authMethodProtocol string, key string, value string, directKeyName ...bool)
GetAuthParameter(authMethodProtocol string, key string, directKeyName ...bool) string
}
type AuthDataAccessor ¶
type AuthHandler ¶
type AuthHandler interface {
common.WithName
Protocol() string
Handle(ctx AuthContext) (bool, error)
Init(cfg config.Config, log logger.Logger, vld validator.Validator, configPath ...string) error
Handlers() []AuthHandler
SetAuthManager(manager AuthManager)
ErrorDescriptions() map[string]string
ErrorProtocolCodes() map[string]int
}
type AuthHandlerBase ¶
type AuthHandlerBase struct {
common.WithNameBase
// contains filtered or unexported fields
}
func (*AuthHandlerBase) ErrorDescriptions ¶
func (a *AuthHandlerBase) ErrorDescriptions() map[string]string
func (*AuthHandlerBase) ErrorProtocolCodes ¶
func (a *AuthHandlerBase) ErrorProtocolCodes() map[string]int
func (*AuthHandlerBase) Handlers ¶
func (a *AuthHandlerBase) Handlers() []AuthHandler
func (*AuthHandlerBase) Init ¶
func (a *AuthHandlerBase) Init(protocol string)
func (*AuthHandlerBase) Protocol ¶
func (a *AuthHandlerBase) Protocol() string
func (*AuthHandlerBase) SetAuthManager ¶
func (a *AuthHandlerBase) SetAuthManager(manager AuthManager)
type AuthManager ¶
type AuthManager interface {
Handle(ctx AuthContext, schema string) error
ErrorDescriptions() map[string]string
ErrorProtocolCodes() map[string]int
Handlers() HandlerStore
Schemas() HandlerStore
}
type AuthManagerBase ¶
type AuthManagerBase struct {
// contains filtered or unexported fields
}
func (*AuthManagerBase) ErrorDescriptions ¶
func (a *AuthManagerBase) ErrorDescriptions() map[string]string
func (*AuthManagerBase) ErrorProtocolCodes ¶
func (a *AuthManagerBase) ErrorProtocolCodes() map[string]int
func (*AuthManagerBase) Handle ¶
func (a *AuthManagerBase) Handle(ctx AuthContext, schema string) error
func (*AuthManagerBase) Handlers ¶
func (a *AuthManagerBase) Handlers() HandlerStore
func (*AuthManagerBase) Init ¶
func (a *AuthManagerBase) Init(cfg config.Config, log logger.Logger, vld validator.Validator, handlerFactory HandlerFactory, configPath ...string) error
func (*AuthManagerBase) Schemas ¶
func (a *AuthManagerBase) Schemas() HandlerStore
type AuthParameterEncryption ¶
type AuthParameterEncryption interface {
Encrypt(ctx op_context.Context, obj interface{}) (string, error)
SetAuthParameter(ctx AuthContext, authMethodProtocol string, name string, obj interface{}, directKeyName ...bool) error
GetAuthParameter(ctx AuthContext, authMethodProtocol string, name string, obj interface{}, tag string, directKeyName ...bool) (bool, error)
DecodeAuthParameter(ctx AuthContext, name string, value string, obj interface{}, tag ...string) (bool, error)
EncodeAuthParameter(ctx AuthContext, name string, obj interface{}) (string, error)
CurrentTag() string
}
type AuthParameterEncryptionBase ¶
type AuthParameterEncryptionBase struct {
AuthParameterEncryptionBaseConfig
Serializer message.Serializer
StringCoding utils.StringCoding
}
func (*AuthParameterEncryptionBase) Config ¶
func (a *AuthParameterEncryptionBase) Config() interface{}
func (*AuthParameterEncryptionBase) CurrentTag ¶
func (a *AuthParameterEncryptionBase) CurrentTag() string
func (*AuthParameterEncryptionBase) DecodeAuthParameter ¶
func (a *AuthParameterEncryptionBase) DecodeAuthParameter(ctx AuthContext, name string, value string, obj interface{}, tag ...string) (bool, error)
func (*AuthParameterEncryptionBase) EncodeAuthParameter ¶
func (a *AuthParameterEncryptionBase) EncodeAuthParameter(ctx AuthContext, name string, obj interface{}) (string, error)
func (*AuthParameterEncryptionBase) Encrypt ¶
func (a *AuthParameterEncryptionBase) Encrypt(ctx op_context.Context, obj interface{}) (string, error)
func (*AuthParameterEncryptionBase) GetAuthParameter ¶
func (a *AuthParameterEncryptionBase) GetAuthParameter(ctx AuthContext, authMethodProtocol string, name string, obj interface{}, tag string, directKeyName ...bool) (bool, error)
func (*AuthParameterEncryptionBase) SetAuthParameter ¶
func (a *AuthParameterEncryptionBase) SetAuthParameter(ctx AuthContext, authMethodProtocol string, name string, obj interface{}, directKeyName ...bool) error
type AuthSchema ¶
type AuthSchema struct {
AuthHandlerBase
// contains filtered or unexported fields
}
func NewAuthSchema ¶
func NewAuthSchema() *AuthSchema
func (*AuthSchema) Aggregation ¶
func (a *AuthSchema) Aggregation() Aggregation
func (*AuthSchema) AppendHandlers ¶
func (a *AuthSchema) AppendHandlers(handler ...AuthHandler)
func (*AuthSchema) Config ¶
func (a *AuthSchema) Config() interface{}
func (*AuthSchema) Construct ¶
func (s *AuthSchema) Construct()
func (*AuthSchema) Handle ¶
func (a *AuthSchema) Handle(ctx AuthContext) (bool, error)
func (*AuthSchema) Handlers ¶
func (a *AuthSchema) Handlers() []AuthHandler
func (*AuthSchema) InitSchema ¶
func (a *AuthSchema) InitSchema(log logger.Logger, cfg config.Config, vld validator.Validator, handlerStore HandlerStore, configPath ...string) error
func (*AuthSchema) Protocol ¶
func (a *AuthSchema) Protocol() string
func (*AuthSchema) SetAggregation ¶
func (a *AuthSchema) SetAggregation(aggregation Aggregation)
type AuthSchemaConfig ¶
type ContextWithAuthUser ¶
type ContextWithAuthUser interface {
op_context.Context
WithAuthUser
}
type EndpointSchema ¶
type EndpointSchema struct {
ACCESS access_control.AccessType
HTTP_METHOD string
SCHEMA string
}
func (*EndpointSchema) Config ¶
func (e *EndpointSchema) Config() interface{}
type EndpointsAuth ¶
type EndpointsAuth interface {
Auth
Manager() AuthManager
EndpointsConfig() EndpointsAuthConfig
}
type EndpointsAuthConfig ¶
type EndpointsAuthConfig interface {
Schema(path string, accessType access_control.AccessType) (string, bool)
AddSchema(path string, access access_control.AccessType, schema string)
}
type EndpointsAuthConfigBase ¶
type EndpointsAuthConfigBase struct {
// contains filtered or unexported fields
}
func NewEndpointsAuthConfigBase ¶
func NewEndpointsAuthConfigBase() *EndpointsAuthConfigBase
func (*EndpointsAuthConfigBase) AddSchema ¶
func (e *EndpointsAuthConfigBase) AddSchema(path string, access access_control.AccessType, schema string)
func (*EndpointsAuthConfigBase) Schema ¶
func (e *EndpointsAuthConfigBase) Schema(path string, access access_control.AccessType) (string, bool)
type ExpireToken ¶
func (*ExpireToken) Expired ¶
func (e *ExpireToken) Expired() bool
func (*ExpireToken) SetTTL ¶
func (e *ExpireToken) SetTTL(seconds int)
type HandlerFactory ¶
type HandlerFactory interface {
Create(protocol string) (AuthHandler, error)
}
type HandlerStore ¶
type HandlerStore interface {
Handler(name string) (AuthHandler, error)
AddHandler(handler AuthHandler)
HandlerNames() []string
}
type HandlerStoreBase ¶
type HandlerStoreBase struct {
// contains filtered or unexported fields
}
func NewHandlerStore ¶
func NewHandlerStore() *HandlerStoreBase
func (*HandlerStoreBase) AddHandler ¶
func (h *HandlerStoreBase) AddHandler(handler AuthHandler)
func (*HandlerStoreBase) Handler ¶
func (h *HandlerStoreBase) Handler(name string) (AuthHandler, error)
func (*HandlerStoreBase) HandlerNames ¶
func (h *HandlerStoreBase) HandlerNames() []string
type NoAuth ¶
type NoAuth struct {
// contains filtered or unexported fields
}
func (*NoAuth) AttachToErrorManager ¶
func (a *NoAuth) AttachToErrorManager(errManager generic_error.ErrorManager)
func (*NoAuth) HandleRequest ¶
func (a *NoAuth) HandleRequest(ctx AuthContext, path string, access access_control.AccessType) error
type NoAuthMethod ¶
type NoAuthMethod struct {
AuthHandlerBase
}
func (*NoAuthMethod) Handle ¶
func (n *NoAuthMethod) Handle(ctx AuthContext) (bool, error)
func (*NoAuthMethod) SetAuthManager ¶
func (n *NoAuthMethod) SetAuthManager(manager AuthManager)
type SessionBase ¶
type SessionBase struct {
// contains filtered or unexported fields
}
func (*SessionBase) GetClientId ¶
func (u *SessionBase) GetClientId() string
func (*SessionBase) GetSessionId ¶
func (u *SessionBase) GetSessionId() string
func (*SessionBase) IsLoggedIn ¶
func (u *SessionBase) IsLoggedIn() bool
func (*SessionBase) SetClientId ¶
func (u *SessionBase) SetClientId(id string)
func (*SessionBase) SetSessionId ¶
func (u *SessionBase) SetSessionId(id string)
type TenancyUserContext ¶
type TenancyUserContext struct {
multitenancy.TenancyContextBase
User User
}
func (*TenancyUserContext) AuthUser ¶
func (u *TenancyUserContext) AuthUser() User
func (*TenancyUserContext) SetAuthUser ¶
func (u *TenancyUserContext) SetAuthUser(user User)
type UserBase ¶
type UserBase struct {
UserId string `gorm:"index"`
UserLogin string `gorm:"index"`
UserDisplay string `gorm:"index"`
UserTopic string `gorm:"index"`
UserBlocked bool `gorm:"index"`
}
func NewAuthUser ¶
type UserContext ¶
type UserContext interface {
multitenancy.TenancyContext
WithAuthUser
}
type UserContextBase ¶
type UserContextBase struct {
op_context.Context
User User
}
func NewUserContext ¶
func NewUserContext(fromCtx ...op_context.Context) *UserContextBase
func (*UserContextBase) AuthUser ¶
func (u *UserContextBase) AuthUser() User
func (*UserContextBase) SetAuthUser ¶
func (u *UserContextBase) SetAuthUser(user User)
type WithAuthBase ¶
type WithAuthBase struct {
// contains filtered or unexported fields
}
func (*WithAuthBase) Auth ¶
func (w *WithAuthBase) Auth() Auth
func (*WithAuthBase) Init ¶
func (w *WithAuthBase) Init(auth Auth)
type WithAuthUser ¶
type WithUserBase ¶
type WithUserBase struct {
UserId string `gorm:"index"`
UserLogin string `gorm:"index"`
UserDisplay string `gorm:"index"`
}
func (*WithUserBase) GetUserDisplay ¶
func (s *WithUserBase) GetUserDisplay() string
func (*WithUserBase) GetUserId ¶
func (s *WithUserBase) GetUserId() string
func (*WithUserBase) GetUserLogin ¶
func (s *WithUserBase) GetUserLogin() string
func (*WithUserBase) SetUser ¶
func (w *WithUserBase) SetUser(user User)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.