File tree Expand file tree Collapse file tree 5 files changed +28
-26
lines changed Expand file tree Collapse file tree 5 files changed +28
-26
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,14 @@ type Context map[string]interface{}
6
6
// AccessRequest - describes a Subject's intention to perform some Actions against
7
7
// given Resource.
8
8
type AccessRequest struct {
9
- Subject Subject
9
+ // Subject - subject (typically a user) that wants to perform given Actions.
10
+ // Needs to implement Subject interface.
11
+ Subject Subject
12
+ // Resource - resource that given Subject wants to interact with.
13
+ // Needs to implement Resource interface.
10
14
Resource Resource
11
- Actions []string
12
- Context Context
15
+ // Actions - list of operations Subject wants to perform on given Resource.
16
+ Actions []string
17
+ // Context - map of any additional values needed while checking Conditions.
18
+ Context Context
13
19
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -185,6 +185,17 @@ func (e *AccessDeniedError) Reason() error {
185
185
return e .reason
186
186
}
187
187
188
+ // FailedCondition - helper function for retrieving underlying failed Condition.
189
+ func (e * AccessDeniedError ) FailedCondition () Condition {
190
+ if e .reason != nil {
191
+ if conditionErr , ok := e .reason .(* ConditionNotSatisfiedError ); ok {
192
+ return conditionErr .condition
193
+ }
194
+ }
195
+
196
+ return nil
197
+ }
198
+
188
199
// RequestMalformedError - thrown when AccessRequest is no correct or
189
200
// does not contain all necessary information.
190
201
type RequestMalformedError struct {
@@ -288,6 +299,7 @@ func (e *ConditionNotSatisfiedError) Error() string {
288
299
return fmt .Sprintf ("Condition: \" %v\" was not satisfied! %s" , e .condition .Name (), e .reason .Error ())
289
300
}
290
301
302
+ // Reason - returns underlying reason (an error) of failing Condition.
291
303
func (e * ConditionNotSatisfiedError ) Reason () error {
292
304
return e .reason
293
305
}
Original file line number Diff line number Diff line change @@ -6,9 +6,12 @@ import (
6
6
7
7
// ValueDescriptor - describes a value that will be tested in its parent Condition.
8
8
type ValueDescriptor struct {
9
- Source ValueSource `json:"source"`
10
- Field string `json:"field"`
11
- Value interface {} `json:"value"`
9
+ // Source - source of the value, one of the predefined enum type (ValueSource).
10
+ Source ValueSource `json:"source,omitempty" yaml:"source,omitempty"`
11
+ // Field - field on the given ValueSource that should hold the value.
12
+ Field string `json:"field,omitempty" yaml:"field,omitempty"`
13
+ // Value - explicit value used when defining ValueSource.Explicit as value source.
14
+ Value interface {} `json:"value,omitempty" yaml:"value,omitempty"`
12
15
}
13
16
14
17
// GetValue - returns real value represented by given ValueDescriptor.
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ func (vs *ValueSource) UnmarshalJSON(jsonData []byte) error {
70
70
return nil
71
71
}
72
72
73
- // UnmarshalJSON - unmarshals a string into ValueSource.
73
+ // UnmarshalYAML - unmarshals a string into ValueSource.
74
74
func (vs * ValueSource ) UnmarshalYAML (value * yaml.Node ) error {
75
75
var sourceName string
76
76
You can’t perform that action at this time.
0 commit comments