ToastShaman / dropwizard-auth-jwt

A Dropwizard authentication filter using JSON Web Token (JWT)
Apache License 2.0
116 stars 50 forks source link

Using an object when authenticating #20

Closed patrickreck closed 8 years ago

patrickreck commented 8 years ago

Am I supposed to store an ID of the user authorizing in the Principal.getName() or is it possible to actually store a User object?

I've tried to replace the Principal with a User extending it with little success:

skaermbillede 2016-02-08 kl 19 37 28

Could you enlighten me on how I should be using this?

ToastShaman commented 8 years ago

Hi,

You can use your own User object as long as it extends java.security.Principal. See my previous commit that uses a MyUser object with an additional getId() method. It is up to you what information you want to store as part of your Principal implementation.

situokko commented 8 years ago

Just used it like this and it is working nicely!

patrickreck commented 8 years ago

Yep, this is working perfectly fine. Thank you!