Skip to content

Commit 025694f

Browse files
authored
[Feature] [Platform] Authz v1 (#1840)
1 parent 59b20a5 commit 025694f

File tree

15 files changed

+856
-75
lines changed

15 files changed

+856
-75
lines changed

.protolint.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
lint:
22
rules:
33
all_default: true
4+
remove:
5+
- ENUM_FIELD_NAMES_PREFIX
6+
- ENUM_FIELD_NAMES_UPPER_SNAKE_CASE
7+
- ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH
48
rules_option:
59
max_line_length:
610
max_chars: 128

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- (Bugfix) Improve Wait Procedure on AF
66
- (Feature) (Platform) Generate GRPC Gateway Code
77
- (Feature) (Platform) Identity Endpoint
8+
- (Feature) (Platform) Authz V1 Types
89

910
## [1.2.46](https://github.com/arangodb/kube-arangodb/tree/1.2.46) (2025-02-24)
1011
- (Bugfix) Clean Phase change properly during upgrade

integrations/authentication/v1/definition/definition.pb.gw.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
"regexp"
25+
26+
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
27+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
28+
)
29+
30+
var (
31+
actionNameRE = regexp.MustCompile(`^[a-z]+(\.[a-z]+)*$`)
32+
)
33+
34+
func validateActionName(name string) error {
35+
if !actionNameRE.MatchString(name) {
36+
return errors.Errorf("Action `%s` does not match the regex", name)
37+
}
38+
39+
return nil
40+
}
41+
42+
var _ shared.ValidateInterface = &AuthorizationV1Policy{}
43+
44+
func (x *AuthorizationV1Action) Validate() error {
45+
if x == nil {
46+
return errors.Errorf("Actions is not allowed to be nil")
47+
}
48+
49+
return shared.WithErrors(
50+
shared.PrefixResourceError("action", validateActionName(x.Name)),
51+
shared.ValidateRequiredNotEmptyPath("description", &x.Description),
52+
shared.PrefixResourceError("subActions", shared.ValidateList(x.SubActions, func(s string) error {
53+
return validateActionName(s)
54+
})),
55+
)
56+
}
57+
58+
func (x AuthorizationV1Effect) Validate() error {
59+
switch x {
60+
case AuthorizationV1Effect_Allow, AuthorizationV1Effect_Deny:
61+
return nil
62+
}
63+
64+
return errors.Errorf("Invalid Effect value")
65+
}
66+
67+
func (x *AuthorizationV1Statement) Validate() error {
68+
if x == nil {
69+
return errors.Errorf("Statement is not allowed to be nil")
70+
}
71+
72+
return shared.WithErrors(
73+
shared.ValidateRequiredInterfacePath("effect", x.Effect),
74+
shared.ValidateRequiredNotEmptyPath("description", &x.Description),
75+
shared.PrefixResourceError("actions", shared.ValidateList(x.Actions, func(s string) error {
76+
return validateActionName(s)
77+
})),
78+
shared.PrefixResourceError("resources", shared.ValidateList(x.Resources, func(s string) error {
79+
return shared.ValidateRequiredNotEmpty(&s)
80+
})),
81+
)
82+
}
83+
84+
func (x *AuthorizationV1Policy) Validate() error {
85+
if x == nil {
86+
return errors.Errorf("Statement is not allowed to be nil")
87+
}
88+
89+
return shared.WithErrors(
90+
shared.PrefixResourceError("name", validateActionName(x.Name)),
91+
shared.ValidateRequiredNotEmptyPath("description", &x.Description),
92+
shared.PrefixResourceError("statements", shared.ValidateInterfaceList(x.Statements)),
93+
)
94+
}

0 commit comments

Comments
 (0)