Giter Site home page Giter Site logo

express-auth-jwt-strategy's Introduction

express-auth-jwt-strategy

A basic express app for authorizing users with JWT strategy.

After cloning repo and changing to directory

  1. Install Dependencies

    npm i
  2. Set env variables

    • Create a .env file at the root of repo.
    • (REQUIRED): set value for SECRET
      • SECRET=...
    • (OPTIONAL): set value for PORT (default: 3030)
      • PORT=...
  3. Run development server

    npm run dev

    Or build and start

    npm run build
    npm run start
  4. Login Endpoint

    On Postman, make a POST request to http://localhost:3030/auth/login/

    • The request should have a body of type x-www-form-urlencoded
    • request body should have an email and password
      • The email and password are hard coded in this example. There are 2 existing users.
        {
            email: '[email protected]',
            password: 'johnny-password'
        },
        {
            email: '[email protected]',
            password: 'jane-password'
        }
    • The request should return an object with a JSON web token.
  5. Dashboard Endpoint

    On Postman, make a GET request to http://localhost:3030/dashboard/user/

    • Create a header with
      • key: Authorization
      • value: JWT <jwt-from-login-post-request>
    • This should return an object representing the user information.

express-auth-jwt-strategy's People

Contributors

keshprad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.