Mongo Server
  • Introduction
  • Getting started
  • Basics
    • Routing and Queries
    • Restrict endpoints
    • Route logic
    • Default values
    • Input validation and Output Formatting
  • Auth and permissions
    • Login and authentication
    • Permission handling
    • Local authentication
    • Magic Links and codes
  • Automatic Documentation
    • Server description
    • Swagger Docs
  • Miscellaneous
    • Db Seeding
    • Mailing settings
    • Roadmap
    • Population Constrains
Powered by GitBook
On this page

Was this helpful?

  1. Auth and permissions

Login and authentication

The majority of systems needs a way to identify and authenticate user, with Moser you can activate an auth system based on JWT just adding one option in your config file

module.exports= {
  resources: {
    users:{
      auth:{
        local:['email','password']
      }
    }
  },
  jwtSecret: 'secret', // by default is "secret", used to sign token
  bcryptRounds:1, //used to hash passwords by default is 1
}

using this you can call the endpoint POST /auth/users/sign-up to create an user and POST /auth/users/log-in to authenticate, after that, you will get a $token parameter in your log-in response, check the next section to know how to restrict access to your endpoints

PreviousInput validation and Output FormattingNextPermission handling

Last updated 6 years ago

Was this helpful?