Documentation
¶
Overview ¶
package authz provides Casbin-based authorization.
Index ¶
- type Enforcer
- func (e *Enforcer) Enforce(user umodels.User, obj, act string) (bool, error)
- func (e *Enforcer) EnforceConversationAccess(user umodels.User, conversation cmodels.Conversation) (bool, error)
- func (e *Enforcer) EnforceMediaAccess(user umodels.User, model string) (bool, error)
- func (e *Enforcer) InvalidateAllCache()
- func (e *Enforcer) InvalidateUserCache(userID int)
- func (e *Enforcer) LoadPermissions(user umodels.User) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Enforcer ¶
type Enforcer struct {
// contains filtered or unexported fields
}
Enforcer is a wrapper around Casbin enforcer.
func NewEnforcer ¶
NewEnforcer initializes a new Enforcer with the hardcoded model
func (*Enforcer) Enforce ¶
Enforce checks if a user has permission to perform an action on an object.
func (*Enforcer) EnforceConversationAccess ¶
func (e *Enforcer) EnforceConversationAccess(user umodels.User, conversation cmodels.Conversation) (bool, error)
EnforceConversationAccess determines if a user has access to a specific conversation based on their permissions. Requires basic "read" permission AND one of the following conditions: 1. User has the "read_all" permission, allowing access to all conversations. 2. User has the "read_assigned" permission and is the assigned user. 3. User has the "read_team_inbox" permission and is part of the assigned team, with the conversation NOT assigned to any user. 4. User has the "read_unassigned" permission and the conversation is not assigned to any user or team. Returns true if access is granted, false otherwise. In case of an error while checking permissions returns false and the error.
func (*Enforcer) EnforceMediaAccess ¶
EnforceMediaAccess checks for read access on linked model to media.
func (*Enforcer) InvalidateAllCache ¶
func (e *Enforcer) InvalidateAllCache()
InvalidateAllCache clears the entire permissions cache.
func (*Enforcer) InvalidateUserCache ¶
InvalidateUserCache removes user from permsCache to be called when user permissions change.