From cd4156c552e68ed2f6c4ae201039bff6e2ddc4fa Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Thu, 24 Oct 2024 18:05:48 -0400 Subject: [PATCH] I know it's halloween, but still... we should rewrite this in Ruby Signed-off-by: Alex Snaps --- controllers/auth_config_controller.go | 4 ++-- pkg/evaluators/identity.go | 10 ++++++---- pkg/evaluators/identity_extension.go | 5 ++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/controllers/auth_config_controller.go b/controllers/auth_config_controller.go index e871c961..9140e322 100644 --- a/controllers/auth_config_controller.go +++ b/controllers/auth_config_controller.go @@ -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)) diff --git a/pkg/evaluators/identity.go b/pkg/evaluators/identity.go index 0bce9cbf..01608d47 100644 --- a/pkg/evaluators/identity.go +++ b/pkg/evaluators/identity.go @@ -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 diff --git a/pkg/evaluators/identity_extension.go b/pkg/evaluators/identity_extension.go index 63dc87a9..bbea29fc 100644 --- a/pkg/evaluators/identity_extension.go +++ b/pkg/evaluators/identity_extension.go @@ -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, }