本文整理匯總了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
}