dimanche 13 mars 2016

Session properties and JWT claims can't be accessed with embre-simple-auth-token

I have a basic working authentication system in my Ember app. I can receive a JWT and my app will log me in. The problem is that I can't access anything with something like this.get('session').get('data.id') as shown in an example on ember-simple-auth's GitHub page.

Here's the response from my authentication request:

{token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImFiY…yMyJ9.X0O3xMVikn-5l9gXBU5a2XF6vlMmTzm4mCqUNA68e-A", test: "abc123"}

Here's the payload of the token:

{
  "id": "abc123"
}

Yet, calling this.get('session').get('data.id') doesn't return anything. I also tried other things like this.get('session').get('id').

this.get('session').get('data') returns:

{"authenticated":{"authenticator":"authenticator:jwt","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImFiYzEyMyJ9.X0O3xMVikn-5l9gXBU5a2XF6vlMmTzm4mCqUNA68e-A","test":"abc123"}}

So there is technically a way to read test but it doesn't seem like the right way.

this.get('session') exists, but is empty. Setting properties work well and they can be accessed afterwards.

How do I access the claims? ember-simple-auth-token has a specific authenticator for JWT so I assume it should be able to read the token.




Aucun commentaire:

Enregistrer un commentaire