Token with custom objects as claims#239
Conversation
|
It would be beneficial to have this, there has been no work around for quite some time now. |
|
This merge would be very handy, thank you @EL-Greco-Domi Any thoughts why this fails on Java 7, but not 8? |
|
Please check the open/closed issues regarding this same matter. This is definitely something we don't want to accept in a generic way. If you still want to try, an implementation we suggested back then is detailed here. |
|
Hi, Regarding your concerns in the linked issue: If you really really don't wont to open up the library, there still is the possibility to create an own interface which is about the same like the one of jackson (StdSerializer), so just like this: public interface ObjectSerializer<T> {
public String serialize(T item);
public Class<T> getClassToHandle();
}A user can pass custom objects, if he's unhappy with the result he can register custom serializers which extend this interface. we can then wrap his custom serializer inside a StdSerializer and pass it to the ObjectMapper as serializer for the specified class. Using this way we don't force a specific library onto the users and still have the benefits of being able to use custom objects. Cheers, |
|
@EL-Greco-Domi Yeah that could work out. I'll add this to our backlog for discussion. In the meantime, I'll leave this issue open as a reminder. |
|
Jackson ObjectMapper supports converting objects directly to and from Map in a single line of code, so implementing a customer serializer would perhaps be more work and thus less convenient @EL-Greco-Domi? Performance is not an issue either. I suggest rather creating an 'extension' artifact for exposing this kind of inner workings, i.e. java-jwt-jackson-extension or something like that. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇♂️ |
This pull requests adds the ability to create tokens with custom objects as claims.
Motivation
It was possible to verify tokens with JSON objects as claim values, but it was not possible to create them. The public API didn't provide the necessary methods to add custom objects to the token as a claim value.
This pull request enables a user of this library to do so, furthermore it is now also possible to pass mandatory object claims during verification of the token.