This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/server/store/extension_perm_iface.go
Jeffrey Smith 11fd8c1e57 step 1: rename module chat-switchboard → switchboard-core
- go.mod module name
- All 714 import references across 289 Go files
- VERSION: 0.1.0
- CI DB names: switchboard_core_{ci,dev,test}
- Docker image: gobha/switchboard-core
- Test fixtures: JWT issuer, repo names
- .env.example, docker-compose container name
- Compiles clean (go build exit 0)
2026-03-25 19:48:04 -04:00

37 lines
1.4 KiB
Go

package store
import (
"context"
"switchboard-core/models"
)
// ExtensionPermissionStore manages declared and granted permissions for packages.
type ExtensionPermissionStore interface {
// DeclareForPackage upserts the declared permissions from a manifest.
// Any permissions in the DB for this package that are NOT in the
// provided list are deleted (manifest is the source of truth).
// Existing grants are preserved on upsert.
DeclareForPackage(ctx context.Context, packageID string, permissions []string) error
// ListForPackage returns all declared permissions for a package.
ListForPackage(ctx context.Context, packageID string) ([]models.ExtensionPermission, error)
// GrantedForPackage returns only granted permissions for a package.
// Used at runtime to determine which modules to inject.
GrantedForPackage(ctx context.Context, packageID string) ([]string, error)
// Grant marks a permission as granted by an admin.
Grant(ctx context.Context, packageID, permission, grantedBy string) error
// Revoke removes a grant (sets granted=false).
Revoke(ctx context.Context, packageID, permission string) error
// GrantAll grants all declared permissions for a package.
GrantAll(ctx context.Context, packageID, grantedBy string) error
// DeleteForPackage removes all permission rows for a package.
// Called when a package is uninstalled.
DeleteForPackage(ctx context.Context, packageID string) error
}