waiting-for-dev / warden-jwt_auth

JWT token authentication with warden
MIT License
113 stars 56 forks source link

Config model mapping works only with default key #6

Closed tejasbubane closed 7 years ago

tejasbubane commented 7 years ago

The README has this model mapping:

config.mappings = { user: UserRepository }

and revocation strategy:

config.revocation_strategies = { user: RevocationStrategy }

This does not seem to work for me. It does not send the JWT token in the header for login - no error shown.

Wiki uses default instead of user as key. I have taken the example in wiki and replaced the key default with user and it stops working. Does not work with any other key except default. Is default the expected key?

You can find the code in this gist.

waiting-for-dev commented 7 years ago

Warden defaults to default scope, and otherwise you have to tell it.

So, you have to use:

env['warden'].authenticate!(scope: :user)
env['warden'].set_user(User.instance, store: false, scope: :user)

instead that current:

env['warden'].authenticate!
env['warden'].set_user(User.instance, store: false)

That's warden API.

tejasbubane commented 7 years ago

Thanks! 👍 I overlooked warden scope from the README and assumed that to be this gem's API for config.