Skip to content

Commit

Permalink
I know it's halloween, but still... we should rewrite this in Ruby
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Snaps <[email protected]>
  • Loading branch information
alexsnaps committed Oct 24, 2024
1 parent b445436 commit cd4156c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions controllers/auth_config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ func (r *AuthConfigReconciler) translateAuthConfig(ctx context.Context, authConf
for identityCfgName, identity := range authConfigIdentityConfigs {
extendedProperties := make([]evaluators.IdentityExtension, len(identity.Defaults)+len(identity.Overrides))
for propertyName, property := range identity.Defaults {
extendedProperties = append(extendedProperties, evaluators.NewIdentityExtension(propertyName, &json.JSONValue{
extendedProperties = append(extendedProperties, evaluators.NewIdentityExtension(propertyName, json.JSONValue{
Static: property.Value,
Pattern: property.Selector,
}, false))
}
for propertyName, property := range identity.Overrides {
extendedProperties = append(extendedProperties, evaluators.NewIdentityExtension(propertyName, &json.JSONValue{
extendedProperties = append(extendedProperties, evaluators.NewIdentityExtension(propertyName, json.JSONValue{
Static: property.Value,
Pattern: property.Selector,
}, true))
Expand Down
10 changes: 6 additions & 4 deletions pkg/evaluators/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,13 @@ func (config *IdentityConfig) ResolveExtendedProperties(pipeline auth.AuthPipeli
authJSON := pipeline.GetAuthorizationJSON()

for _, extendedProperty := range config.ExtendedProperties {
resolved, err := extendedProperty.ResolveFor(extendedIdentityObject, authJSON)
if err != nil {
return nil, err
if extendedProperty.Value != nil {
resolved, err := extendedProperty.ResolveFor(extendedIdentityObject, authJSON)
if err != nil {
return nil, err
}
extendedIdentityObject[extendedProperty.Name] = resolved
}
extendedIdentityObject[extendedProperty.Name] = resolved
}

return extendedIdentityObject, nil
Expand Down
5 changes: 2 additions & 3 deletions pkg/evaluators/identity_extension.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package evaluators

import (
"github.com/kuadrant/authorino/pkg/expressions"
"github.com/kuadrant/authorino/pkg/json"
)

func NewIdentityExtension(name string, value expressions.Value, overwrite bool) IdentityExtension {
func NewIdentityExtension(name string, value json.JSONValue, overwrite bool) IdentityExtension {
return IdentityExtension{
JSONProperty: json.JSONProperty{
Name: name,
Value: value,
Value: &value,
},
Overwrite: overwrite,
}
Expand Down

0 comments on commit cd4156c

Please sign in to comment.