Add bindings for csharp modules to use JWT claims #3414
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
This exposes JWT claims for csharp modules, similar to how they are exposed to rust modules in #3288.
This adds the new types
AuthCtx
andJwtClaims
, and adds anAuthCtx
to theReducerContext
.AuthCtx
represents the credentials associated with the request, andJwtClaims
represents a jwt token.One difference from the rust version is that I didn't create helpers to build an
AuthCtx
from a jwt payload. The reason is that we would need to be able to compute the identity from the payload claims, which requires a blake3 hash implementation. The first two c# libraries I found had issues at runtime (Blake3 is wrapping a rust implementation, and HashifyNet seems to be broken by our trimming because it uses reflection heavily). I can look into taking the implementation fromHashifyNet
, since it is MIT licensed, but I don't think we need to block merging on that.API and ABI breaking changes
This adds the new types
AuthCtx
andJwtClaims
, and adds anAuthCtx
to theReducerContext
.This also adds a csharp wrapper for the get_jwt ABI function added in #3288.
Expected complexity level and risk
Testing
This has a very minimal unit test of JwtClaims.
I manually tested using this locally with the csharp quickstart, and I was able to print jwt tokens inside the module.