feathersjsfeathers-authentication

feathersJS custom authentication


im trying to create an auth with feathersJS. im not there when they did it from the beginning they create the services MANUALLY, meaning they did not use the command "feathers generate service", now, everything works fine. but now they want me to implment a authentication to their login, i saw some example in documentation that i have to put in default.json like this

"authentication": {
"entity": null,
"service": "users",
"secret": "fhaCVRbeGa0XDMcxRKcnTMz/Ti8=",
"authStrategies": [
  "jwt",
  "local"
],
"jwtOptions": {
  "header": {
    "typ": "access"
  },
  "audience": "https://yourdomain.com",
  "issuer": "feathers",
  "algorithm": "HS256",
  "expiresIn": "1d"
},
"local": {
  "usernameField": "userName",
  "passwordField": "password"
}

}

so my first question is this. where should i get that entity? is that as is for name? or there must be a file that exist for that? thanks


Solution

  • thanks for the help, I already solved it using your help and i noticed also i havent included .hooks file, thanks something like this

      before: {
        all: [],
        find: [ authenticate('jwt') ],
        get: [ authenticate('jwt') ],
        create: [ hashPassword('password') ],
        update: [ hashPassword('password'),  authenticate('jwt') ],
        patch: [ hashPassword('password'),  authenticate('jwt') ],
        remove: [ authenticate('jwt') ],
      },