Skip to content

Commit

Permalink
fix: RawExtension to string conversion
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Cassolato <[email protected]>
  • Loading branch information
guicassolato committed Nov 4, 2024
1 parent 82d7619 commit f0890d6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
16 changes: 13 additions & 3 deletions pkg/evaluators/authorization/authzed.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/kuadrant/authorino/pkg/auth"
"github.com/kuadrant/authorino/pkg/expressions"
"github.com/kuadrant/authorino/pkg/json"
"google.golang.org/grpc"
insecuregrpc "google.golang.org/grpc/credentials/insecure"

Expand Down Expand Up @@ -60,10 +61,11 @@ func (a *Authzed) Call(pipeline auth.AuthPipeline, ctx gocontext.Context) (inter
if err != nil {
return nil, err
}
permissionStr, err := json.StringifyJSON(permission)
resp, err := client.CheckPermission(ctx, &authzedpb.CheckPermissionRequest{
Resource: resource,
Subject: &authzedpb.SubjectReference{Object: object},
Permission: fmt.Sprintf("%s", permission),
Permission: permissionStr,
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -91,12 +93,20 @@ func authzedObjectFor(name, kind expressions.Value, authJSON string) (*authzedpb
if err != nil {
return nil, err
}
objectIdStr, err := json.StringifyJSON(objectId)
if err != nil {
return nil, err
}
objectType, err := kind.ResolveFor(authJSON)
if err != nil {
return nil, err
}
objectTypeStr, err := json.StringifyJSON(objectType)
if err != nil {
return nil, err
}
return &authzedpb.ObjectReference{
ObjectId: fmt.Sprintf("%s", objectId),
ObjectType: fmt.Sprintf("%s", objectType),
ObjectId: objectIdStr,
ObjectType: objectTypeStr,
}, nil
}
3 changes: 2 additions & 1 deletion pkg/evaluators/authorization/kubernetes_authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/kuadrant/authorino/pkg/auth"
"github.com/kuadrant/authorino/pkg/context"
"github.com/kuadrant/authorino/pkg/expressions"
"github.com/kuadrant/authorino/pkg/json"
"github.com/kuadrant/authorino/pkg/log"

kubeAuthz "k8s.io/api/authorization/v1"
Expand Down Expand Up @@ -71,7 +72,7 @@ func (k *KubernetesAuthz) Call(pipeline auth.AuthPipeline, ctx gocontext.Context
if err != nil {
return "", err
}
return fmt.Sprintf("%s", resolved), nil
return json.StringifyJSON(resolved)
}

user, err := jsonValueToStr(k.User)
Expand Down
6 changes: 5 additions & 1 deletion pkg/evaluators/metadata/generic_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ func (h *GenericHttp) buildRequest(ctx gocontext.Context, endpoint, authJSON str
if err != nil {
return nil, err
}
req.Header.Set(header.Name, fmt.Sprintf("%s", headerValue))
headerValueStr, err := json.StringifyJSON(headerValue)
if err != nil {
return nil, err
}
req.Header.Set(header.Name, headerValueStr)
}

req.Header.Set("Content-Type", contentType)
Expand Down

0 comments on commit f0890d6

Please sign in to comment.