Documentation
¶
Index ¶
- func CompareRevision(a, b string) int
- func LoadSeedFiles(root string) ([]rules.SeedFile, error)
- func LoadSeedFilesFromFS(fsys fs.FS, root string) ([]rules.SeedFile, error)
- func TokenizeRevision(s string) []revisionToken
- func ValidateSeedFile(f rules.SeedFile) error
- type CompiledPath
- type ResourceMapper
- type ResourceMapperInterface
- type RuleMatcher
- type RuleMatcherInterface
- type RuleSeeder
- type TupleResolver
- type TupleResolverInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareRevision ¶ added in v1.0.0
CompareRevision compares two revision strings using a natural-order comparator. Returns -1 if a < b, 0 if a == b, and 1 if a > b.
func LoadSeedFiles ¶ added in v1.0.0
LoadSeedFiles recursively scans the root directory for any rules.yaml files.
func LoadSeedFilesFromFS ¶ added in v1.0.0
LoadSeedFilesFromFS recursively scans the given fs.FS starting at root for any rules.yaml files.
func TokenizeRevision ¶ added in v1.0.0
func TokenizeRevision(s string) []revisionToken
TokenizeRevision splits a revision string into its constituent numeric or letter tokens, treating any non-alphanumeric character as a boundary separator.
func ValidateSeedFile ¶ added in v1.0.0
ValidateSeedFile validates the content of a SeedFile against structural requirements.
Types ¶
type CompiledPath ¶ added in v1.0.0
func CompileMatch ¶ added in v1.0.0
func CompileMatch(match string) (CompiledPath, error)
CompileMatch compiles a match path pattern into a CompiledPath structure.
type ResourceMapper ¶
type ResourceMapper struct {
// contains filtered or unexported fields
}
ResourceMapper implements the full pipeline: lookup → match → resolve.
func NewResourceMapper ¶
func NewResourceMapper(repo repository.RuleRepository, matcher RuleMatcherInterface, resolver TupleResolverInterface) *ResourceMapper
NewResourceMapper creates a new ResourceMapper.
func (*ResourceMapper) Map ¶
func (rm *ResourceMapper) Map(ctx context.Context, userID, method, path string) ([]client.ClientBatchCheckItem, *rules.RuleWithTuples, error)
Map takes an HTTP method and path, looks up candidate rules from the database, matches the first applicable rule, resolves its tuple, and returns the result.
type ResourceMapperInterface ¶
type ResourceMapperInterface interface {
Map(ctx context.Context, userID, method, path string) ([]client.ClientBatchCheckItem, *rules.RuleWithTuples, error)
}
type RuleMatcher ¶
type RuleMatcher struct{}
RuleMatcher matches an incoming path against a set of candidate rules.
func (*RuleMatcher) Match ¶
func (m *RuleMatcher) Match(candidates []*rules.RuleWithTuples, path string) (*rules.RuleWithTuples, error)
Match iterates over candidates (already sorted by priority ASC from the query) and returns the first rule whose path_regex matches the given path.
type RuleMatcherInterface ¶
type RuleMatcherInterface interface {
Match(candidates []*rules.RuleWithTuples, path string) (*rules.RuleWithTuples, error)
}
type RuleSeeder ¶ added in v1.0.0
type RuleSeeder struct {
// contains filtered or unexported fields
}
func NewRuleSeeder ¶ added in v1.0.0
func NewRuleSeeder(db postgres.DBClientInterface, repo *repository.PostgresRuleRepository) *RuleSeeder
func (*RuleSeeder) SeedService ¶ added in v1.0.0
func (s *RuleSeeder) SeedService(ctx context.Context, file rules.SeedFile) (inserted bool, skipped bool, err error)
SeedService runs the seeding process for a single service SeedFile.
type TupleResolver ¶
type TupleResolver struct{}
TupleResolver resolves a RuleWithTuples + regex match into an OpenFGA Tuple.
func NewTupleResolver ¶
func NewTupleResolver() *TupleResolver
NewTupleResolver creates a new TupleResolver.
func (*TupleResolver) Resolve ¶
func (r *TupleResolver) Resolve(userID string, rule *rules.RuleWithTuples, matches rules.RegexMatches) ([]*rules.Tuple, error)
Resolve builds an openfga Tuple from the rule tuple specifications, substituting dynamic object_resource_id values (wrapped in braces like "{groupId}") with the corresponding capture group value from the regex match.
type TupleResolverInterface ¶
type TupleResolverInterface interface {
Resolve(userID string, rule *rules.RuleWithTuples, matches rules.RegexMatches) ([]*rules.Tuple, error)
}