session-less use of jwt and passport.js
note: by module I mean either a javascript (.js) or coffeescript (.coffee) file
install the following:
- sailsjs
- sails-generate-auth
- passport-jwt
- jwt-simple
- moment
- include jwt in your
config/passportmodule - modifiy the
api/services/passportmodule to setup jwt. - create a
api/services/protocols/jwtmodule - create
api/policies/hasJsonWebTokenmodule - modify
config/policiesmodule to use the newhasJsonWebTokenpolicy, relax policies onUserController.loginbut requirehasJsonWebTokenonUserController.index - create
api.models.ApiTokenmodule to define valid tokens of various types. - include
api/controllers/UserControllermodule to expose aloginaction, this generates and returns the users JWT access token.