- 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)
37 lines
1.4 KiB
Go
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
|
|
}
|