Documentation ¶
Index ¶
- func ConcatStrings(base string, append ...string) string
- type AuthenticationConfig
- type Client
- type DatabaseConfig
- type DatabaseFailureError
- type DefaultResourcePermissions
- type DefaultsConfig
- type Handler
- type HashAlgorithm
- type Identifier
- type Method
- type NetworkConfig
- type NotFoundError
- type PermissionInheritance
- type Permissions
- type Request
- type Resource
- type ResourceIdentifier
- func (resId *ResourceIdentifier) HasParent() bool
- func (resId *ResourceIdentifier) Identifier() string
- func (resId *ResourceIdentifier) Parent() (parentId ResourceIdentifier, err error)
- func (resId *ResourceIdentifier) Serialize() string
- func (resId *ResourceIdentifier) String() string
- func (resId *ResourceIdentifier) Url() string
- func (resId *ResourceIdentifier) VariableValues() map[string]string
- type ResourceType
- type Response
- type ResponseJson
- func (response *ResponseJson) Data(key string, value interface{})
- func (response *ResponseJson) Header(head string, value string)
- func (response *ResponseJson) ReplyClientError(code string, message string)
- func (response *ResponseJson) ReplyCreated()
- func (response *ResponseJson) ReplyCustom(status int)
- func (response *ResponseJson) ReplyCustomError(status int, code string, message string)
- func (response *ResponseJson) ReplyForbidden(message string)
- func (response *ResponseJson) ReplyNotFound(message string)
- func (response *ResponseJson) ReplyNotImplemented(message string)
- func (response *ResponseJson) ReplyServerError(code string, message string)
- func (response *ResponseJson) Status() int
- func (response *ResponseJson) String() *[]byte
- type SecurityConfig
- type Service
- func (service *Service) AssignOwner(resourceId ResourceIdentifier, userId Identifier) (err error)
- func (service *Service) AssignPermissions(resourceId ResourceIdentifier, user interface{}, permissions Permissions) (err error)
- func (service *Service) CreateUser(username string, password string) (assignedId Identifier, err error)
- func (service *Service) FindUserById(identifier Identifier) (account UserAccount, err error)
- func (service *Service) FindUserByUsername(username string) (account UserAccount, err error)
- func (service *Service) GetPermissionsFor(resourceId ResourceIdentifier, user interface{}) (permissions Permissions, err error)
- func (service *Service) GetResourceIdentifier(identifier string, variables map[string]string) (resourceId ResourceIdentifier, err error)
- func (service *Service) ResolvePermissionsFor(resourceId ResourceIdentifier, user interface{}) (isOwner bool, permissions Permissions, err error)
- func (service *Service) RevokePermissions(resourceId ResourceIdentifier, user interface{}) (err error)
- func (service *Service) Run()
- func (service *Service) Shutdown()
- type ServiceConfig
- type TargetUser
- type UserAccount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConcatStrings ¶
Types ¶
type AuthenticationConfig ¶
AuthenticationConfig bundles authentication related configurations.
type Client ¶
type Client struct {
Identifier *Identifier
}
type DatabaseConfig ¶
AuthenticationConfig bundles database related configurations.
type DatabaseFailureError ¶
type DatabaseFailureError struct {
// contains filtered or unexported fields
}
DatabaseFailureError represents error cases where either the database is unreachable or the database query was faulty.
func (DatabaseFailureError) Error ¶
func (err DatabaseFailureError) Error() string
type DefaultResourcePermissions ¶
type DefaultResourcePermissions struct { UserPermissions Permissions GuestPermissions Permissions Inheritance PermissionInheritance }
type DefaultsConfig ¶
DefaultsConfig bundles default values and directories.
type HashAlgorithm ¶
type HashAlgorithm int
const ( HS256 HashAlgorithm = iota HS384 HS512 RS256 RS384 RS512 ES256 ES384 ES512 )
type Identifier ¶
type Identifier struct {
// contains filtered or unexported fields
}
func GenerateUniqueIdentifier ¶
func GenerateUniqueIdentifier() Identifier
func (*Identifier) Bytes ¶
func (identifier *Identifier) Bytes() []byte
func (*Identifier) FromBytes ¶
func (identifier *Identifier) FromBytes(str []byte)
func (*Identifier) FromString ¶
func (identifier *Identifier) FromString(str string)
func (*Identifier) String ¶
func (identifier *Identifier) String() string
type NetworkConfig ¶
NetworkConfig bundles network related configurations.
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
NotFoundError represents error cases where the requested object was not found.
func (NotFoundError) Error ¶
func (err NotFoundError) Error() string
type PermissionInheritance ¶
type Permissions ¶
type Permissions struct { Create bool Read bool Update bool Delete bool Patch bool ReadHeaders bool ReadOptions bool Purge bool Copy bool Move bool Link bool Unlink bool Lock bool Unlock bool ReadProperties bool UpdateProperties bool CreateCollection bool }
func (*Permissions) AllowAll ¶
func (perm *Permissions) AllowAll()
func (*Permissions) Deserialize ¶
func (perm *Permissions) Deserialize(mask uint32)
func (*Permissions) ForbidAll ¶
func (perm *Permissions) ForbidAll()
func (*Permissions) Serialize ¶
func (perm *Permissions) Serialize() (mask uint32)
type Resource ¶
type Resource struct { Permissions DefaultResourcePermissions Handlers map[Method]Handler Name string Parent string MaxUploadSize int64 Type ResourceType Pattern string }
type ResourceIdentifier ¶
type ResourceIdentifier struct {
// contains filtered or unexported fields
}
func (*ResourceIdentifier) HasParent ¶
func (resId *ResourceIdentifier) HasParent() bool
func (*ResourceIdentifier) Identifier ¶
func (resId *ResourceIdentifier) Identifier() string
func (*ResourceIdentifier) Parent ¶
func (resId *ResourceIdentifier) Parent() ( parentId ResourceIdentifier, err error, )
func (*ResourceIdentifier) Serialize ¶
func (resId *ResourceIdentifier) Serialize() string
func (*ResourceIdentifier) String ¶
func (resId *ResourceIdentifier) String() string
func (*ResourceIdentifier) Url ¶
func (resId *ResourceIdentifier) Url() string
func (*ResourceIdentifier) VariableValues ¶
func (resId *ResourceIdentifier) VariableValues() map[string]string
type Response ¶
type Response interface { String() *[]byte Status() int Header(string, string) //server side error ReplyServerError(string, string) ReplyNotImplemented(string) //client side error ReplyClientError(string, string) ReplyForbidden(string) ReplyNotFound(string) //success ReplyCreated() //custom ReplyCustom(int) ReplyCustomError(int, string, string) }
type ResponseJson ¶
type ResponseJson struct {
// contains filtered or unexported fields
}
func (*ResponseJson) Data ¶
func (response *ResponseJson) Data(key string, value interface{})
func (*ResponseJson) Header ¶
func (response *ResponseJson) Header(head string, value string)
func (*ResponseJson) ReplyClientError ¶
func (response *ResponseJson) ReplyClientError(code string, message string)
func (*ResponseJson) ReplyCreated ¶
func (response *ResponseJson) ReplyCreated()
func (*ResponseJson) ReplyCustom ¶
func (response *ResponseJson) ReplyCustom(status int)
func (*ResponseJson) ReplyCustomError ¶
func (response *ResponseJson) ReplyCustomError(status int, code string, message string)
func (*ResponseJson) ReplyForbidden ¶
func (response *ResponseJson) ReplyForbidden(message string)
func (*ResponseJson) ReplyNotFound ¶
func (response *ResponseJson) ReplyNotFound(message string)
func (*ResponseJson) ReplyNotImplemented ¶
func (response *ResponseJson) ReplyNotImplemented(message string)
func (*ResponseJson) ReplyServerError ¶
func (response *ResponseJson) ReplyServerError(code string, message string)
func (*ResponseJson) Status ¶
func (response *ResponseJson) Status() int
func (*ResponseJson) String ¶
func (response *ResponseJson) String() *[]byte
type SecurityConfig ¶
type SecurityConfig struct { Https bool Certificate string PrivateKey string HashAlgorithm HashAlgorithm }
SecurityConfig bundles security related configurations.
type Service ¶
type Service struct { Config configuration // contains filtered or unexported fields }
The Service type represents an actual apperix service.
func CreateService ¶
func CreateService(conf ServiceConfig) ( service *Service, )
CreateService constructs and returns an initialized apperix service.
CAUTION: Faulty configuration will cause panic!
func (*Service) AssignOwner ¶
func (service *Service) AssignOwner( resourceId ResourceIdentifier, userId Identifier, ) ( err error, )
AssignOwner transfers ownership of the given resource to the given user. The new owner will be defined in case there is yet no one owning the given resource.
func (*Service) AssignPermissions ¶
func (service *Service) AssignPermissions( resourceId ResourceIdentifier, user interface{}, permissions Permissions, ) ( err error, )
AssignPermissions assigns provided permissions for the given user on the given resource. Already registered entries will be overwritten.
NOTICE: The user argument accepts both a certain user identifier or an abstract user like other users (OTHERS) and guests (GUESTS).
CAUTION: passing user identifier of unsupported type will cause panic!
func (*Service) CreateUser ¶
func (service *Service) CreateUser( username string, password string, ) ( assignedId Identifier, err error, )
CreateUser registeres a new user account identified by the given username and returns its generated unique identifier. The given password will later be associated with the given username and encrypted using a cryptographic hash function. An error will be returned in either of the cases: 1) Either username, password or both do not match minimal requirements. 2) The given username is already taken by another account.
func (*Service) FindUserById ¶
func (service *Service) FindUserById( identifier Identifier, ) ( account UserAccount, err error, )
FindUserById returns a user account identified by the given identifier. An error will be returned in case no user was found.
func (*Service) FindUserByUsername ¶
func (service *Service) FindUserByUsername( username string, ) ( account UserAccount, err error, )
FindUserByUsername returns a user account identified by the given username. An error will be returned in case no user was found.
func (*Service) GetPermissionsFor ¶
func (service *Service) GetPermissionsFor( resourceId ResourceIdentifier, user interface{}, ) ( permissions Permissions, err error, )
GetPermissionsFor returns directly assigned permissions and inheritance flags for the user and resource. Its not recommended to use this method to get actual permissions of a user for the final resource as it doesnt resolve permissions by taking the inherited ones into account, to resolve final permissions use ResolvePermissionsFor instead.
CAUTION: passing user identifier of unsupported type will cause panic!
func (*Service) GetResourceIdentifier ¶
func (service *Service) GetResourceIdentifier( identifier string, variables map[string]string, ) ( resourceId ResourceIdentifier, err error, )
GetResourceIdentifier returns a resource identifier object representing the resource given its identifier and path of variable values. An error will be returned in the following 3 cases: 1) the identifier is not registered therefore invalid. 2) one or multiple required variable values are missing. 3) one or multiple required variable values do not match assigned pattern.
func (*Service) ResolvePermissionsFor ¶
func (service *Service) ResolvePermissionsFor( resourceId ResourceIdentifier, user interface{}, ) ( isOwner bool, permissions Permissions, err error, )
ResolvePermissionsFor returns actual permissions of the given user for the given resource resolving inherited permissions.
CAUTION: passing user identifier of unsupported type will cause panic!
func (*Service) RevokePermissions ¶
func (service *Service) RevokePermissions( resourceId ResourceIdentifier, user interface{}, ) ( err error, )
RevokePermissions revokes permission entries for for the given user on the given resource.
NOTICE: The user argument accepts both a certain user identifier or an abstract user like other users (OTHERS) and guests (GUESTS).
CAUTION: passing user identifier of unsupported type will cause panic!
type ServiceConfig ¶
type ServiceConfig struct { Name string Database DatabaseConfig Authentication AuthenticationConfig Network NetworkConfig Security SecurityConfig Defaults DefaultsConfig Resources map[string]Resource }
ServiceConfig bundles all required configuration bundles.
type TargetUser ¶
type TargetUser int
The TargetUser type represents an enumeration of special users like: OTHERS and GUESTS. Just like certain user identifiers these special users can be used for identification.
const ( OTHERS TargetUser = iota GUESTS )
type UserAccount ¶
type UserAccount struct { Identifier Identifier Username string Password string }
The UserAccount type represents bundled information about a user registered in the apperix service.