Documentation ¶
Index ¶
- type Adapter
- func (a *Adapter) AddPolicy(sec string, ptype string, rule []string) error
- func (a *Adapter) LoadPolicy(cmodel model.Model) error
- func (a *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (a *Adapter) RemovePolicy(sec string, ptype string, rule []string) error
- func (a *Adapter) SavePolicy(cmodel model.Model) error
- type CasbinRule
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter represents a Cloud Spanner-based adapter for policy storage.
func NewAdapter ¶
NewAdapter creates an Adapter instance. Use the "projects/{project}/instances/{instance}/databases/{db}" format for 'db'. Instance creation is not supported. If database creation is not skipped, it will attempt to create the database. If table creation is not skipped, it will attempt to create the table as well.
func (*Adapter) AddPolicy ¶
AddPolicy adds a policy rule to the storage. Part of the auto-save feature.
func (*Adapter) LoadPolicy ¶
LoadPolicy loads policy from database. Implements casbin Adapter interface.
func (*Adapter) RemoveFilteredPolicy ¶
func (a *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
RemoveFilteredPolicy removes policy rules that match the filter from the storage. Part of the auto-save feature.
func (*Adapter) RemovePolicy ¶
RemovePolicy removes a policy rule from the storage. Part of the auto-save feature.
type CasbinRule ¶
type CasbinRule struct { PType string `spanner:"ptype"` V0 string `spanner:"v0"` V1 string `spanner:"v1"` V2 string `spanner:"v2"` V3 string `spanner:"v3"` V4 string `spanner:"v4"` V5 string `spanner:"v5"` }
func (CasbinRule) ToString ¶
func (c CasbinRule) ToString() string
type Option ¶ added in v0.2.0
type Option interface {
Apply(*Adapter)
}
func WithDatabaseAdminClient ¶ added in v0.2.0
func WithDatabaseAdminClient(c *dbv1.DatabaseAdminClient) Option
WithDatabaseAdminClient sets the adapter's database client. If not provided, an internal client is created using the environment's default credentials.
func WithSkipDatabaseCreation ¶ added in v0.2.0
WithSkipDatabaseCreation allows caller to skip the database creation.
func WithSkipTableCreation ¶ added in v0.2.0
WithSkipTableCreation allows caller to skip the table creation.
func WithSpannerClient ¶ added in v0.2.0
WithSpannerClient sets the adapter's Spanner client. If not provided, an internal client is created using the environment's default credentials.
func WithTableName ¶ added in v0.2.0
WithTableName sets adapter's internal table name. Default is 'casbin_rule'.