Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public-api/.helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions public-api/pkg/client/auth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 13 additions & 2 deletions public-api/pkg/service/constructor/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
Loading