feathersjs-ecosystem / authentication-oauth2

[MOVED] OAuth 2 plugin for feathers-authentication
https://github.com/feathersjs/feathers
MIT License
26 stars 15 forks source link

Add userId to JWT content #5

Closed rockingskier closed 7 years ago

rockingskier commented 7 years ago

Solves #4.

When generating the JWT the userId needs to be passed in as the payload. This allows it to be encoded into the token which in turn makes it possible to fetch the user on decode / log in.

The current token content is:

{
  "iat": 1481443686,
  "exp": 1481530086,
  "aud": "https://yourdomain.com",
  "iss": "feathers",
  "sub": "anonymous"
}

The new content is:

{
  "userId": 2,
  "iat": 1481443989,
  "exp": 1481530389,
  "aud": "https://yourdomain.com",
  "iss": "feathers",
  "sub": "anonymous"
}

This brings the payload in line with when you login/authenticate via local and when you login via OAuth.

rockingskier commented 7 years ago

Fixed in d01f50167e4bfe010f3f72d65a77153465af5a52

ekryski commented 7 years ago

Thanks for the fix @rockingskier! I ended up fixing this along with a few other bugs so this is now live. Going to close but thank you so much for the effort! 😄