[Proposal] Replace AuthContext map[string]string with Typed Struct in Policy SDK #1048
renuka-fernando
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
|
@renuka-fernando But let's say a user want to use a different claim rather than the default |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
AuthContext map[string]stringin the policy SDK'sSharedContextwith a typedAuthContextstruct containing named fields for common auth dataProperties map[string]stringescape hatch on the struct for custom/policy-specific metadata that does not fit the typed fieldsMotivation
AuthContextusing magic string keys like"x-wso2-user-id"with no compile-time safety. A typo in a key name silently produces missing data rather than a build error.Proposal
AuthContextstruct insdk/gateway/policy/v1alpha/context.gowith typed fields for the most common auth attributesSharedContextProperties map[string]stringfield as an escape hatch for custom dataThe proposed struct:
Examples
Before (auth policy writing to AuthContext):
After (auth policy writing to AuthContext):
Before (downstream policy reading AuthContext):
After (downstream policy reading AuthContext):
References
AuthContext map[string]stringdefinitionAuthContextis initialized asmake(map[string]string)AuthContext["x-wso2-user-id"]Beta Was this translation helpful? Give feedback.
All reactions