authorizer func: pass through context

Signed-off-by: Monis Khan <mok@vmware.com>

Kubernetes-commit: 8f00e918d84a76ea43d76a8d5b96c3f2535afa99
This commit is contained in:
Monis Khan 2021-04-09 09:33:46 -04:00 committed by Kubernetes Publisher
parent db0339edde
commit e14444ffc5
2 changed files with 4 additions and 3 deletions

View File

@ -71,10 +71,10 @@ type Authorizer interface {
Authorize(ctx context.Context, a Attributes) (authorized Decision, reason string, err error)
}
type AuthorizerFunc func(a Attributes) (Decision, string, error)
type AuthorizerFunc func(ctx context.Context, a Attributes) (Decision, string, error)
func (f AuthorizerFunc) Authorize(ctx context.Context, a Attributes) (Decision, string, error) {
return f(a)
return f(ctx, a)
}
// RuleResolver provides a mechanism for resolving the list of rules that apply to a given user within a namespace.

View File

@ -17,6 +17,7 @@ limitations under the License.
package path
import (
"context"
"fmt"
"strings"
@ -46,7 +47,7 @@ func NewAuthorizer(alwaysAllowPaths []string) (authorizer.Authorizer, error) {
}
}
return authorizer.AuthorizerFunc(func(a authorizer.Attributes) (authorizer.Decision, string, error) {
return authorizer.AuthorizerFunc(func(ctx context.Context, a authorizer.Attributes) (authorizer.Decision, string, error) {
if a.IsResourceRequest() {
return authorizer.DecisionNoOpinion, "", nil
}