Documentation
¶
Index ¶
- Constants
- func DefaultModel() string
- func NewAuthorizer(cfg *authzv1.Authorizer, opts ...Option) (authz.Authorizer, error)
- type Authorizer
- type Option
- func WithFileModel(path string) Option
- func WithLogger(logger log.Logger) Option
- func WithModel(m casbinmodel.Model) Option
- func WithNameModel(name string) Option
- func WithPolicyAdapter(p persist.Adapter) Option
- func WithStringModel(str string) Option
- func WithWatcher(w persist.Watcher) Option
- func WithWildcardItem(item string) Option
- type Options
Constants ¶
const (
DefaultWildcardItem = "*"
)
Variables ¶
This section is empty.
Functions ¶
func DefaultModel ¶
func DefaultModel() string
DefaultModel returns the default Casbin model string.
func NewAuthorizer ¶
func NewAuthorizer(cfg *authzv1.Authorizer, opts ...Option) (authz.Authorizer, error)
NewAuthorizer creates a new Authorizer instance.
Types ¶
type Authorizer ¶
type Authorizer struct {
*Options
// contains filtered or unexported fields
}
Authorizer is a struct that implements the Authorizer interface.
type Option ¶
func WithFileModel ¶
WithFileModel sets the Casbin model from a file path. It panics if the model cannot be created from the file.
func WithLogger ¶ added in v1.3.0
WithLogger sets the logger for the authorizer.
func WithModel ¶
func WithModel(m casbinmodel.Model) Option
WithModel sets the Casbin model for the Authorizer.
func WithNameModel ¶
WithNameModel sets the Casbin model by its predefined name. It panics if the named model cannot be found or created.
func WithPolicyAdapter ¶
WithPolicyAdapter sets the Casbin policy adapter.
func WithStringModel ¶
WithStringModel sets the Casbin model from a string. It panics if the model cannot be created from the string.
func WithWatcher ¶
WithWatcher sets the Casbin watcher for dynamic policy updates.
func WithWildcardItem ¶
WithWildcardItem sets the wildcard item for domain matching.
type Options ¶
Options holds configuration for the Casbin Authorizer, used with optionutil. All fields are unexported to enforce configuration via functional options, ensuring a controlled and validated setup process.
func FromOptions ¶
FromOptions creates a new Options struct by applying the given functional options.
func NewOptions ¶ added in v1.2.0
func NewOptions(cfg *authzv1.Authorizer, opts ...Option) (*Options, error)
NewOptions creates a new Options object from the given configuration and functional options.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package adapter implements the functions, types, and interfaces for the module.
|
Package adapter implements the functions, types, and interfaces for the module. |
|
internal
|
|
|
model
Package model embedding the model files for Casbin.
|
Package model embedding the model files for Casbin. |
|
policy
Package policy embedding the policy files for Casbin.
|
Package policy embedding the policy files for Casbin. |