-
Notifications
You must be signed in to change notification settings - Fork 24
fix(ers): Do not use auth header jwt in MultiStrategy ERS #2862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Standard Benchmark Metrics Skipped or FailedBulk Benchmark Results
TDF3 Benchmark Results:
NANOTDF Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Standard Benchmark Metrics Skipped or FailedBulk Benchmark Results
TDF3 Benchmark Results:
NANOTDF Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Standard Benchmark Metrics Skipped or FailedBulk Benchmark Results
TDF3 Benchmark Results:
NANOTDF Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Standard Benchmark Metrics Skipped or FailedBulk Benchmark Results
TDF3 Benchmark Results:
NANOTDF Benchmark Results:
|
| var claimsMap types.JWTClaims | ||
| switch entityV2.GetEntityType().(type) { | ||
| case *entity.Entity_Claims: | ||
| claims := entityV2.GetClaims() | ||
| if claims != nil { | ||
| // First unmarshal to structpb.Struct | ||
| var claimsStruct structpb.Struct | ||
| err := claims.UnmarshalTo(&claimsStruct) | ||
| if err != nil { | ||
| return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("error unpacking anypb.Any to structpb.Struct: %w", err)) | ||
| } | ||
| // Convert to map[string]interface{} | ||
| claimsMap = claimsStruct.AsMap() | ||
| } | ||
| default: | ||
| entityBytes, err := protojson.Marshal(entityV2) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| err = json.Unmarshal(entityBytes, &claimsMap) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this logic block is almost identical to the one in the v2 version (besides getting the claims). Is there a way to abstract this logic to a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call out, do you know if we have a recommended strategy around shared code for v1/v2 versions? looking at the rest of the code at least within the ERS implementations it seems like its all duplication instead of shared functions, so i kind of just followed that strategy, but if thats not the case we should refactor across ERS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We copied over the entirety of the v2 ERS initially when it was scaffolded for Auth Service v2. As the intention is to deprecate the entirety of ERS v1 when Auth Service v1 is deprecated (within the next few releases), I would not recommend expending too much effort on DRYness unless the DRY changes also benefit logic within the single v2 service version alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya the logic doesnt really repeat within v2 so not sure a separate func would be needed, also not sure where i would put that if it were to be shared between the two, we dont really have a place for that right now. so i may just opt to go with the duplication for now if thats ok
Proposed Changes
Checklist
Testing Instructions