-
Notifications
You must be signed in to change notification settings - Fork 464
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
Newtonsoft dependency and Blazor Client apps #204
Comments
I'm also wondering if this library would make a good fit lgihtweight client side usage, and by lightweight I mean the only features that will be required are:
|
Actually I don't mind and was also thinking about the split, see #76. However the idea was abandoned due to the lack of either support or demand. The library can do all three: encode, decode, validate. Those are core and essential functions. I would not split them further. |
Understood. I think the dependency on |
Other than Json.Net it has no other dependencies and fits NetStandard 1.3 so I find it lightweight enough to be used on the client side. |
The split should be a trivial job. I'm happy to participate, do code reviews, fix/adjust CI/CD if would be necessary. |
Thanks. I have just experimented a little bit within my blazor client app, and to get readonly access the things I need is pretty trivial, without any external dependency: var jwt = "header.payload.sig" // replace this with your jwt.
string[] jwtEncodedSegments = jwt.Split('.');
var payloadSegment = jwtEncodedSegments[1];
var decodePayload = System.Convert.FromBase64String(payloadSegment);
var decodedUtf8Payload = Encoding.UTF8.GetString(decodePayload);
var result = System.Text.Json.Serialization.JsonSerializer.Parse<Dictionary<string, JsonElement>>(decodedUtf8Payload); For a few lines of code, there is no dependency on any external serialiser, or cryptography package.. this is probably going to be the easiest solution from my perspective however.. what is't great about this:
So for my use case, if |
If it's that simple and works well for you then maybe it's not worth troubles. Again, I welcome the split across the JSON library but don't think it's a good idea to split across the encoder/decoder. Re |
Ok thanks. I'll stick with what I've got then for now I think :-) |
I'd love to use this library in a Blazor Client application.
Microsoft have recently switched away from being relient on Newtonsoft as a dependency, and instead use
System.Text.Json
by default (developers can still opt-in to using newtonsoft if they wish). This is a bit more lightweight and works well in Blazor client applications as well as on the server side. Newtonsoft was never designed to be lightweight for browser side use.However one gap in blazor client side apps is that there is no lightweight mechanism for decoding a JWT into a claims principal. See my issue here: dotnet/aspnetcore#11417
So I found your library. The problem is, it pulls in newtonsoft.json by default (I know you can use a custom serialiser implementation, but the damage has already been done as the newtonsoft dependency is still pulled into the app increasing it's size).
Would you consider splitting
jwt
intojwt
andjwt.newtonsoft
packages so the newtonsoft serialiser package was optionally adopted? That way I could use jwt without the newtonsoft dependency, and then implement a serialiser based onSystem.Text.Json
?The text was updated successfully, but these errors were encountered: