Documentation
¶
Index ¶
- Variables
- func IsDuplicateKeyError(err error) bool
- func IsForeignKeyViolation(err error) bool
- func WrapDuplicateKeyError(err error, context string) error
- func WrapForeignKeyError(err error, context string) error
- type Storage
- func (s *Storage) AddAllowedApp(ctx context.Context, groupID string, appID string) error
- func (s *Storage) AddAllowedApps(ctx context.Context, groupID string, appIDs []string) error
- func (s *Storage) AddAllowedGroupsForApp(ctx context.Context, appID string, groupIDs []string) error
- func (s *Storage) AddUsersToGroup(ctx context.Context, groupID string, userIDs []string) error
- func (s *Storage) CreateGroup(ctx context.Context, group *types.Group) (*types.Group, error)
- func (s *Storage) DeleteGroup(ctx context.Context, id string) error
- func (s *Storage) GetAllowedApps(ctx context.Context, groupID string) ([]string, error)
- func (s *Storage) GetAllowedGroupsForApp(ctx context.Context, appID string) ([]string, error)
- func (s *Storage) GetGroup(ctx context.Context, id string) (*types.Group, error)
- func (s *Storage) GetGroupsForUser(ctx context.Context, userID string) ([]*types.Group, error)
- func (s *Storage) ListGroups(ctx context.Context) ([]*types.Group, error)
- func (s *Storage) ListUsersInGroup(ctx context.Context, groupID string) ([]string, error)
- func (s *Storage) RemoveAllAllowedGroupsForApp(ctx context.Context, appID string) ([]string, error)
- func (s *Storage) RemoveAllowedApp(ctx context.Context, groupID string, appID string) error
- func (s *Storage) RemoveAllowedApps(ctx context.Context, groupID string) ([]string, error)
- func (s *Storage) RemoveUsersFromGroup(ctx context.Context, groupID string, users []string) error
- func (s *Storage) UpdateGroup(ctx context.Context, id string, group *types.Group) (*types.Group, error)
- func (s *Storage) UpdateGroupsForUser(ctx context.Context, userID string, groupIDs []string) error
- type StorageInterface
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("resource not found") ErrDuplicateKey = errors.New("duplicate key violation") ErrForeignKeyViolation = errors.New("foreign key violation") )
Sentinel errors for storage operations.
Functions ¶
func IsDuplicateKeyError ¶
IsDuplicateKeyError checks if the error is a PostgreSQL unique constraint violation.
func IsForeignKeyViolation ¶
IsForeignKeyViolation checks if the error is a PostgreSQL foreign key violation.
func WrapDuplicateKeyError ¶
WrapDuplicateKeyError wraps a duplicate key error with context about which constraint was violated.
func WrapForeignKeyError ¶
WrapForeignKeyError wraps a foreign key violation with context.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func NewStorage ¶
func NewStorage(c db.DBClientInterface, tracer tracing.TracingInterface, monitor monitoring.MonitorInterface, logger logging.LoggerInterface) *Storage
func (*Storage) AddAllowedApp ¶
AddAllowedApp adds a single application to the allowed list for a group.
func (*Storage) AddAllowedApps ¶
AddAllowedApps adds multiple applications to the allowed list for a group.
func (*Storage) AddAllowedGroupsForApp ¶
func (s *Storage) AddAllowedGroupsForApp(ctx context.Context, appID string, groupIDs []string) error
AddAllowedGroupsForApp adds multiple groups to the allowed list for an application.
func (*Storage) AddUsersToGroup ¶
AddUsersToGroup adds multiple users to a group.
func (*Storage) CreateGroup ¶
CreateGroup inserts a new group into the database.
func (*Storage) DeleteGroup ¶
DeleteGroup removes a group from the database.
func (*Storage) GetAllowedApps ¶
GetAllowedApps retrieves all application IDs allowed for a specific group.
func (*Storage) GetAllowedGroupsForApp ¶
GetAllowedGroupsForApp retrieves all group IDs that are allowed to access a specific application.
func (*Storage) GetGroupsForUser ¶
GetGroupsForUser retrieves all groups that a user belongs to.
func (*Storage) ListGroups ¶
ListGroups retrieves all groups from the database.
func (*Storage) ListUsersInGroup ¶
ListUsersInGroup retrieves all user IDs that are members of a group.
func (*Storage) RemoveAllAllowedGroupsForApp ¶
RemoveAllAllowedGroupsForApp removes all groups from the allowed list for an application and returns the removed group IDs.
func (*Storage) RemoveAllowedApp ¶
RemoveAllowedApp removes a single application from the allowed list for a group.
func (*Storage) RemoveAllowedApps ¶
RemoveAllowedApps removes all applications from the allowed list for a group and returns the removed app IDs.
func (*Storage) RemoveUsersFromGroup ¶
RemoveUsersFromGroup removes specific users from a group.
func (*Storage) UpdateGroup ¶
func (s *Storage) UpdateGroup(ctx context.Context, id string, group *types.Group) (*types.Group, error)
UpdateGroup updates an existing group's mutable fields.
func (*Storage) UpdateGroupsForUser ¶
UpdateGroupsForUser replaces all group memberships for a user with the specified groups. It deduplicates the provided group IDs, removes any memberships not in the list, and upserts the remaining memberships to preserve history.
type StorageInterface ¶
type StorageInterface interface {
// Group CRUD operations
ListGroups(ctx context.Context) ([]*types.Group, error)
CreateGroup(ctx context.Context, group *types.Group) (*types.Group, error)
GetGroup(ctx context.Context, id string) (*types.Group, error)
UpdateGroup(ctx context.Context, id string, group *types.Group) (*types.Group, error)
DeleteGroup(ctx context.Context, id string) error
// Group membership operations
AddUsersToGroup(ctx context.Context, groupID string, userIDs []string) error
ListUsersInGroup(ctx context.Context, groupID string) ([]string, error)
RemoveUsersFromGroup(ctx context.Context, groupID string, users []string) error
// User-centric group operations
GetGroupsForUser(ctx context.Context, userID string) ([]*types.Group, error)
UpdateGroupsForUser(ctx context.Context, userID string, groupIDs []string) error
// Application authorization operations
GetAllowedApps(ctx context.Context, groupID string) ([]string, error)
AddAllowedApp(ctx context.Context, groupID string, appID string) error
AddAllowedApps(ctx context.Context, groupID string, appIDs []string) error
RemoveAllowedApp(ctx context.Context, groupID string, appID string) error
RemoveAllowedApps(ctx context.Context, groupID string) ([]string, error)
// Group-centric application authorization operations
AddAllowedGroupsForApp(ctx context.Context, appID string, groupIDs []string) error
GetAllowedGroupsForApp(ctx context.Context, appID string) ([]string, error)
RemoveAllAllowedGroupsForApp(ctx context.Context, appID string) ([]string, error)
}