Documentation ¶
Overview ¶
Package authorizer defines authorization interface.
Index ¶
- func NewAuthorization(getter PolicyGetter) authorization.AuthorizationInterface
- type Authorization
- func (auth *Authorization) Create(policy *ladon.DefaultPolicy) error
- func (auth *Authorization) Delete(id string) error
- func (auth *Authorization) DeleteCollection(idList []string) error
- func (auth *Authorization) Get(id string) (*ladon.DefaultPolicy, error)
- func (auth *Authorization) List(username string) ([]*ladon.DefaultPolicy, error)
- func (auth *Authorization) LogGrantedAccessRequest(r *ladon.Request, p ladon.Policies, d ladon.Policies)
- func (auth *Authorization) LogRejectedAccessRequest(r *ladon.Request, p ladon.Policies, d ladon.Policies)
- func (auth *Authorization) Update(policy *ladon.DefaultPolicy) error
- type PolicyGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAuthorization ¶
func NewAuthorization(getter PolicyGetter) authorization.AuthorizationInterface
NewAuthorization create a new Authorization instance.
Types ¶
type Authorization ¶
type Authorization struct {
// contains filtered or unexported fields
}
Authorization implements authorization.AuthorizationInterface interface.
func (*Authorization) Create ¶
func (auth *Authorization) Create(policy *ladon.DefaultPolicy) error
Create create a policy. Return nil because we use mysql storage to store the policy.
func (*Authorization) Delete ¶
func (auth *Authorization) Delete(id string) error
Delete delete a policy by the given identifier. Return nil because we use mysql storage to store the policy.
func (*Authorization) DeleteCollection ¶
func (auth *Authorization) DeleteCollection(idList []string) error
DeleteCollection batch delete policies by the given identifiers. Return nil because we use mysql storage to store the policy.
func (*Authorization) Get ¶
func (auth *Authorization) Get(id string) (*ladon.DefaultPolicy, error)
Get returns the policy detail by the given identifier. Return nil because we use mysql storage to store the policy.
func (*Authorization) List ¶
func (auth *Authorization) List(username string) ([]*ladon.DefaultPolicy, error)
List returns all the policies under the username.
func (*Authorization) LogGrantedAccessRequest ¶
func (auth *Authorization) LogGrantedAccessRequest(r *ladon.Request, p ladon.Policies, d ladon.Policies)
LogGrantedAccessRequest write granted subject access to redis.
func (*Authorization) LogRejectedAccessRequest ¶
func (auth *Authorization) LogRejectedAccessRequest(r *ladon.Request, p ladon.Policies, d ladon.Policies)
LogRejectedAccessRequest write rejected subject access to redis.
func (*Authorization) Update ¶
func (auth *Authorization) Update(policy *ladon.DefaultPolicy) error
Update update a policy. Return nil because we use mysql storage to store the policy.
type PolicyGetter ¶
type PolicyGetter interface {
GetPolicy(key string) ([]*ladon.DefaultPolicy, error)
}
PolicyGetter defines function to get policy for a given user.