Skip to content

Commit 35995ff

Browse files
committed
Iter
1 parent bf1522b commit 35995ff

File tree

7 files changed

+533
-12
lines changed

7 files changed

+533
-12
lines changed

.golangci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ linters-settings:
4141
pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v0
4242
- alias: pbAuthorizationV0
4343
pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v0/definition
44+
- alias: pbImplAuthorizationV1
45+
pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v1
46+
- alias: pbAuthorizationV1
47+
pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v1/definition
48+
- alias: pShared
49+
pkg: github.com/arangodb/kube-arangodb/pkg/permissions/shared
4450
- alias: pbImplConfigV1
4551
pkg: github.com/arangodb/kube-arangodb/integrations/config/v1
4652
- alias: pbConfigV1
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2025 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package definition
22+
23+
import (
24+
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
25+
"github.com/arangodb/kube-arangodb/pkg/util"
26+
)
27+
28+
func (x *AuthorizationV1PermissionRequest) Validate() error {
29+
if x == nil {
30+
x = &AuthorizationV1PermissionRequest{}
31+
}
32+
33+
return shared.WithErrors(
34+
shared.PrefixResourceErrorFunc("user", func() error {
35+
return validateActionName(x.User)
36+
}),
37+
shared.PrefixResourceError("roles", shared.ValidateList(x.Roles, func(s string) error {
38+
return validateActionName(s)
39+
})),
40+
shared.PrefixResourceErrorFunc("action", func() error {
41+
return validateActionName(x.Action)
42+
}),
43+
shared.PrefixResourceErrorFunc("resource", func() error {
44+
return shared.ValidateRequiredNotEmpty(&x.Resource)
45+
}),
46+
)
47+
}
48+
49+
func (x *AuthorizationV1PermissionRequest) Hash() string {
50+
if x == nil {
51+
return ""
52+
}
53+
return util.SHA256FromStringMap(map[string]string{
54+
"user": util.SHA256FromString(x.GetUser()),
55+
"roles": util.SHA256FromStringArray(x.GetRoles()...),
56+
"action": util.SHA256FromString(x.GetAction()),
57+
"resource": util.SHA256FromString(x.GetResource()),
58+
})
59+
}

integrations/authorization/v1/definition/permission.pb.go

Lines changed: 289 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)