casbin: github.com/casbin/casbin/persist Index | Files | Directories

package persist

import "github.com/casbin/casbin/persist"

Index

Package Files

adapter.go adapter_filtered.go batch_adapter.go watcher.go watcher_ex.go

func LoadPolicyLine Uses

func LoadPolicyLine(line string, m model.Model)

LoadPolicyLine loads a text line as a policy rule to model.

type Adapter Uses

type Adapter interface {
    // LoadPolicy loads all policy rules from the storage.
    LoadPolicy(model model.Model) error
    // SavePolicy saves all policy rules to the storage.
    SavePolicy(model model.Model) error

    // AddPolicy adds a policy rule to the storage.
    // This is part of the Auto-Save feature.
    AddPolicy(sec string, ptype string, rule []string) error
    // RemovePolicy removes a policy rule from the storage.
    // This is part of the Auto-Save feature.
    RemovePolicy(sec string, ptype string, rule []string) error
    // RemoveFilteredPolicy removes policy rules that match the filter from the storage.
    // This is part of the Auto-Save feature.
    RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
}

Adapter is the interface for Casbin adapters.

type BatchAdapter Uses

type BatchAdapter interface {
    Adapter
    // AddPolicies adds policy rules to the storage.
    // This is part of the Auto-Save feature.
    AddPolicies(sec string, ptype string, rules [][]string) error
    // RemovePolicies removes policy rules from the storage.
    // This is part of the Auto-Save feature.
    RemovePolicies(sec string, ptype string, rules [][]string) error
}

BatchAdapter is the interface for Casbin adapters with multiple add and remove policy functions.

type FilteredAdapter Uses

type FilteredAdapter interface {
    Adapter

    // LoadFilteredPolicy loads only policy rules that match the filter.
    LoadFilteredPolicy(model model.Model, filter interface{}) error
    // IsFiltered returns true if the loaded policy has been filtered.
    IsFiltered() bool
}

FilteredAdapter is the interface for Casbin adapters supporting filtered policies.

type Watcher Uses

type Watcher interface {
    // SetUpdateCallback sets the callback function that the watcher will call
    // when the policy in DB has been changed by other instances.
    // A classic callback is Enforcer.LoadPolicy().
    SetUpdateCallback(func(string)) error
    // Update calls the update callback of other instances to synchronize their policy.
    // It is usually called after changing the policy in DB, like Enforcer.SavePolicy(),
    // Enforcer.AddPolicy(), Enforcer.RemovePolicy(), etc.
    Update() error
    // Close stops and releases the watcher, the callback function will not be called any more.
    Close()
}

Watcher is the interface for Casbin watchers.

type WatcherEx Uses

type WatcherEx interface {
    Watcher
    // UpdateForAddPolicy calls the update callback of other instances to synchronize their policy.
    // It is called after Enforcer.AddPolicy()
    UpdateForAddPolicy(params ...string) error
    // UPdateForRemovePolicy calls the update callback of other instances to synchronize their policy.
    // It is called after Enforcer.RemovePolicy()
    UpdateForRemovePolicy(params ...string) error
    // UpdateForRemoveFilteredPolicy calls the update callback of other instances to synchronize their policy.
    // It is called after Enforcer.RemoveFilteredNamedGroupingPolicy()
    UpdateForRemoveFilteredPolicy(fieldIndex int, fieldValues ...string) error
    // UpdateForSavePolicy calls the update callback of other instances to synchronize their policy.
    // It is called after Enforcer.RemoveFilteredNamedGroupingPolicy()
    UpdateForSavePolicy(model model.Model) error
}

WatcherEx is the strengthen for Casbin watchers.

Directories

PathSynopsis
file-adapter

Package persist imports 2 packages (graph) and is imported by 40 packages. Updated 2020-07-02. Refresh now. Tools for package owners.