diff --git a/public-api/.helm/values.yaml b/public-api/.helm/values.yaml index f27c0e56..0a159c83 100644 --- a/public-api/.helm/values.yaml +++ b/public-api/.helm/values.yaml @@ -23,7 +23,7 @@ podSecurityContext: supplementalGroups: [] env: - name: AUTH_API_URL - value: '{{ printf "%s://auth-api:9000" (include "common.cs.http-scheme" .) }}' + value: '{{ printf "%s://auth-center:9000" (include "common.cs.http-scheme" .) }}' - name: POLICY_ENFORCER_GRPC_ADDR value: "policy-enforcer:8000" - name: HISTORY_API_GRPC_ADDR diff --git a/public-api/pkg/client/auth_api.go b/public-api/pkg/client/auth_api.go index 733f1c9d..390f1ea3 100644 --- a/public-api/pkg/client/auth_api.go +++ b/public-api/pkg/client/auth_api.go @@ -41,14 +41,14 @@ type AuthAPI struct { } type AuthAPIUser struct { - Email *string `json:"email"` - RoleID string `json:"role_id"` - MappingRoleID *string `json:"mapping_role_id"` - ID string `json:"id"` - Username string `json:"username"` - Role AuthAPIRole `json:"role"` - AuthType string `json:"auth_type"` - LastPasswordChangedAt jwt.JSONTime `json:"last_password_changed_at"` + Email *string `json:"email"` + RoleID string `json:"role_id"` + MappingRoleID *string `json:"mapping_role_id"` + ID string `json:"id"` + Username string `json:"username"` + Role AuthAPIRole `json:"role"` + AuthType string `json:"auth_type"` + LastPasswordChangedAt string `json:"last_password_changed_at"` } type AuthAPIRole struct { diff --git a/public-api/pkg/service/constructor/rule.go b/public-api/pkg/service/constructor/rule.go index 512d590c..ca5f19c3 100644 --- a/public-api/pkg/service/constructor/rule.go +++ b/public-api/pkg/service/constructor/rule.go @@ -15,6 +15,17 @@ import ( "google.golang.org/protobuf/encoding/protojson" ) +// unmarshalOptions returns a protojson.UnmarshalOptions configuration +// necessary for correctly parsing protojson and ignoring unknown fields. +// It enables the DiscardUnknown option so that missing fields are simply +// ignored during unmarshaling, ensuring that the parsing process does not +// fail due to unexpected fields. +func unmarshalOptions() protojson.UnmarshalOptions { + return protojson.UnmarshalOptions{ + DiscardUnknown: true, + } +} + func RuleCreate(svc service.Rule) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) @@ -25,7 +36,7 @@ func RuleCreate(svc service.Rule) http.Handler { } req := &enf_api.Rule{} - if err = protojson.Unmarshal(body, req); err != nil { + if err = unmarshalOptions().Unmarshal(body, req); err != nil { status := status.New(codes.InvalidArgument, err.Error()) handler.StatusJSONResp(w, status) return @@ -133,7 +144,7 @@ func RuleUpdate(svc service.Rule) http.Handler { } req := &enf_api.Rule{} - if err = protojson.Unmarshal(body, req); err != nil { + if err = unmarshalOptions().Unmarshal(body, req); err != nil { handler.StatusJSONResp(w, status.New(codes.InvalidArgument, err.Error())) return }