scopes

package
v1.95.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TenancyPartition

func TenancyPartition(ctx context.Context) func(db *gorm.DB) *gorm.DB

TenancyPartition applies tenant and partition filtering to database queries.

Behavior:

  • If no claims in context: returns unscoped db (for cross-tenant services)
  • If skip tenancy enabled: returns unscoped db (for backend services processing across tenants)
  • For internal systems: claims are auto-enriched with secondary claims tenancy data
  • tenant_id is a single value; partition_id may be a list (claim.GetPartitionIDs()) so principals that legitimately span multiple partitions (a SACCO operator with access to several branches, an analyst aggregating across groups) see rows from every partition they belong to. Single-partition callers behave as before — the list has one element and the SQL becomes a degenerate IN (?).
  • Empty tenant_id will match only records with empty tenant_id (no cross-tenant leakage)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL