casbin: github.com/casbin/casbin/persist/file-adapter Index | Files

package fileadapter

import "github.com/casbin/casbin/persist/file-adapter"

Index

Package Files

adapter.go adapter_filtered.go adapter_mock.go

type Adapter Uses

type Adapter struct {
    // contains filtered or unexported fields
}

Adapter is the file adapter for Casbin. It can load policy from file or save policy to file.

func NewAdapter Uses

func NewAdapter(filePath string) *Adapter

NewAdapter is the constructor for Adapter.

func (*Adapter) AddPolicies Uses

func (a *Adapter) AddPolicies(sec string, ptype string, rules [][]string) error

AddPolicies adds policy rules to the storage.

func (*Adapter) AddPolicy Uses

func (a *Adapter) AddPolicy(sec string, ptype string, rule []string) error

AddPolicy adds a policy rule to the storage.

func (*Adapter) LoadPolicy Uses

func (a *Adapter) LoadPolicy(model model.Model) error

LoadPolicy loads all policy rules from the storage.

func (*Adapter) RemoveFilteredPolicy Uses

func (a *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error

RemoveFilteredPolicy removes policy rules that match the filter from the storage.

func (*Adapter) RemovePolicies Uses

func (a *Adapter) RemovePolicies(sec string, ptype string, rules [][]string) error

RemovePolicies removes policy rules from the storage.

func (*Adapter) RemovePolicy Uses

func (a *Adapter) RemovePolicy(sec string, ptype string, rule []string) error

RemovePolicy removes a policy rule from the storage.

func (*Adapter) SavePolicy Uses

func (a *Adapter) SavePolicy(model model.Model) error

SavePolicy saves all policy rules to the storage.

type AdapterMock Uses

type AdapterMock struct {
    // contains filtered or unexported fields
}

AdapterMock is the file adapter for Casbin. It can load policy from file or save policy to file.

func NewAdapterMock Uses

func NewAdapterMock(filePath string) *AdapterMock

NewAdapterMock is the constructor for AdapterMock.

func (*AdapterMock) AddPolicies Uses

func (a *AdapterMock) AddPolicies(sec string, ptype string, rules [][]string) error

AddPolicies removes policy rules from the storage.

func (*AdapterMock) AddPolicy Uses

func (a *AdapterMock) AddPolicy(sec string, ptype string, rule []string) error

AddPolicy adds a policy rule to the storage.

func (*AdapterMock) GetMockErr Uses

func (a *AdapterMock) GetMockErr() error

GetMockErr returns a mock error or nil

func (*AdapterMock) LoadPolicy Uses

func (a *AdapterMock) LoadPolicy(model model.Model) error

LoadPolicy loads all policy rules from the storage.

func (*AdapterMock) RemoveFilteredPolicy Uses

func (a *AdapterMock) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error

RemoveFilteredPolicy removes policy rules that match the filter from the storage.

func (*AdapterMock) RemovePolicies Uses

func (a *AdapterMock) RemovePolicies(sec string, ptype string, rules [][]string) error

RemovePolicies removes policy rules from the storage.

func (*AdapterMock) RemovePolicy Uses

func (a *AdapterMock) RemovePolicy(sec string, ptype string, rule []string) error

RemovePolicy removes a policy rule from the storage.

func (*AdapterMock) SavePolicy Uses

func (a *AdapterMock) SavePolicy(model model.Model) error

SavePolicy saves all policy rules to the storage.

func (*AdapterMock) SetMockErr Uses

func (a *AdapterMock) SetMockErr(errorToSet string)

SetMockErr sets string to be returned by of the mock during testing

type Filter Uses

type Filter struct {
    P   []string
    G   []string
}

Filter defines the filtering rules for a FilteredAdapter's policy. Empty values are ignored, but all others must match the filter.

type FilteredAdapter Uses

type FilteredAdapter struct {
    *Adapter
    // contains filtered or unexported fields
}

FilteredAdapter is the filtered file adapter for Casbin. It can load policy from file or save policy to file and supports loading of filtered policies.

func NewFilteredAdapter Uses

func NewFilteredAdapter(filePath string) *FilteredAdapter

NewFilteredAdapter is the constructor for FilteredAdapter.

func (*FilteredAdapter) IsFiltered Uses

func (a *FilteredAdapter) IsFiltered() bool

IsFiltered returns true if the loaded policy has been filtered.

func (*FilteredAdapter) LoadFilteredPolicy Uses

func (a *FilteredAdapter) LoadFilteredPolicy(model model.Model, filter interface{}) error

LoadFilteredPolicy loads only policy rules that match the filter.

func (*FilteredAdapter) LoadPolicy Uses

func (a *FilteredAdapter) LoadPolicy(model model.Model) error

LoadPolicy loads all policy rules from the storage.

func (*FilteredAdapter) SavePolicy Uses

func (a *FilteredAdapter) SavePolicy(model model.Model) error

SavePolicy saves all policy rules to the storage.

Package fileadapter imports 9 packages (graph) and is imported by 6 packages. Updated 2020-04-17. Refresh now. Tools for package owners.