Skip to content
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

[Bug / Feature Request] Create JsonWebToken with empty Payload #2656

Closed
remyblok opened this issue Jun 20, 2024 · 3 comments · Fixed by #2745
Closed

[Bug / Feature Request] Create JsonWebToken with empty Payload #2656

remyblok opened this issue Jun 20, 2024 · 3 comments · Fixed by #2745
Assignees
Labels
Bug Product is not functioning as expected Customer reported Indicates issue was opened by customer
Milestone

Comments

@remyblok
Copy link

Is your feature request related to a problem? Please describe.
I need to create Detached JWS signature for all requests to a webservice. Also for GET requests (which do not have a body/payload). This library creates JWTs of thich I remove the payload to get the JWS variant. But for GET-requests there is no payload. The CreateToken()-method fails when the payload is null or string.Empty.

Describe the solution you'd like
I want to be able to call JsonWebTokenHandler.CreateToken() with string.Empty as payload.
The result should be an empty payload in the created token:

{header}..{signature}

Describe alternatives you've considered
I've concidered using JsonWebTokenHandler.CreateToken(SecurityTokenDescriptor tokenDescriptor). The issue is that then an (empty) json-object is automatically created as payload.

I'm now calling the internal static CreateToken() on JsonWebTokenHandler using reflection with an string.Empty payload. This actually works perfectly and results in the expected behaviour as described above. Only reflection is not a future proof solution.

Additional context
iDeal API desciption with requirements of Detached JWS for all requests

@remyblok
Copy link
Author

Also. I looked at the documentation of CreateToken(). There it does not mention that the payload cannot be string.Empty. So this may even be concidered a bug.

/// <exception cref="ArgumentNullException">if <paramref name="payload"/> is null.</exception>

@remyblok remyblok changed the title [Feature Request] Create JsonWebToken with empty Payload [Bug / Feature Request] Create JsonWebToken with empty Payload Jun 20, 2024
@brentschmaltz
Copy link
Member

@remyblok i agree this is a bug, will fix.

@brentschmaltz brentschmaltz self-assigned this Jul 24, 2024
@brentschmaltz brentschmaltz added Customer reported Indicates issue was opened by customer Bug Product is not functioning as expected labels Jul 24, 2024
@brentschmaltz
Copy link
Member

@remyblok #2745

@jennyf19 jennyf19 added this to the 8.0.2 milestone Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Product is not functioning as expected Customer reported Indicates issue was opened by customer
Projects
None yet
3 participants