本文整理汇总了Golang中launchpad/net/juju-core/state/apiserver/common.Authorizer.AuthOwner方法的典型用法代码示例。如果您正苦于以下问题:Golang Authorizer.AuthOwner方法的具体用法?Golang Authorizer.AuthOwner怎么用?Golang Authorizer.AuthOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/juju-core/state/apiserver/common.Authorizer
的用法示例。
在下文中一共展示了Authorizer.AuthOwner方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewAgentAPI
// NewAgentAPI returns an object implementing the machine agent API
// with the given authorizer representing the currently logged in client.
func NewAgentAPI(st *state.State, auth common.Authorizer) (*AgentAPI, error) {
if !auth.AuthMachineAgent() {
return nil, common.ErrPerm
}
getCanChange := func() (common.AuthFunc, error) {
// TODO(go1.1): method expression
return func(tag string) bool {
return auth.AuthOwner(tag)
}, nil
}
return &AgentAPI{
st: st,
auth: auth,
PasswordChanger: common.NewPasswordChanger(st, getCanChange),
}, nil
}
示例2: NewMachinerAPI
// NewMachinerAPI creates a new instance of the Machiner API.
func NewMachinerAPI(st *state.State, resources *common.Resources, authorizer common.Authorizer) (*MachinerAPI, error) {
if !authorizer.AuthMachineAgent() {
return nil, common.ErrPerm
}
getCanRead := func() (common.AuthFunc, error) {
return func(tag string) bool {
// TODO(go1.1): method expression
return authorizer.AuthOwner(tag)
}, nil
}
return &MachinerAPI{
LifeGetter: common.NewLifeGetter(st, getCanRead),
st: st,
resources: resources,
auth: authorizer,
}, nil
}