add authorizer

This commit is contained in:
Serge Zaitsev
2025-12-23 15:55:39 +01:00
parent 45f665d203
commit b3589300b3
2 changed files with 25 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
package app
import (
"context"
"k8s.io/apiserver/pkg/authorization/authorizer"
)
func GetAuthorizer() authorizer.Authorizer {
return authorizer.AuthorizerFunc(func(
ctx context.Context, attr authorizer.Attributes,
) (authorized authorizer.Decision, reason string, err error) {
if !attr.IsResourceRequest() {
return authorizer.DecisionNoOpinion, "", nil
}
// Any authenticated user can access the API
return authorizer.DecisionAllow, "", nil
})
}
+5
View File
@@ -12,6 +12,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest"
restclient "k8s.io/client-go/rest"
@@ -82,6 +83,10 @@ func RegisterAppInstaller(
return installer, nil
}
func (a *AnnotationAppInstaller) GetAuthorizer() authorizer.Authorizer {
return annotationapp.GetAuthorizer()
}
func (a *AnnotationAppInstaller) GetLegacyStorage(requested schema.GroupVersionResource) apiserverrest.Storage {
kind := annotationV0.AnnotationKind()
gvr := schema.GroupVersionResource{