Giter VIP home page Giter VIP logo

lumen-api-jwt-auth's Introduction

Example JWT authentication for Lumen API

Simple way create API with authorization with JWT

Installation

  1. Cope config file: cp .env.example .env
  2. Config .env:
    • Set param "APP_KEY" with random string (32 characters long)
    • Set param "JWT_SECRET" with random string too (used for JWT, recommended 32 characters long)
    • Config database config (DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD)
  3. Run install dependencies: composer install
  4. Run migration database: php artisan migrate
  5. Insert data to DB
    • php artisan db:seed (insert users in database, see database/factories/ModelFactory.php)

Getting Started

Private access

We have private access to the list of users, you can check by typing in the browser:
http://lumen-jwt.loc/users

And you see fail message:
"error": "Token not provided."

Authentication

  1. Select any user from database (email, password)
  2. Go to postman (https://www.getpostman.com/)
  3. Create POST request to url: https://lumen-jwt.loc/auth/lohin with params:
    • email
    • password
  4. Return token, save it
  5. Create GET request to url: https://lumen-jwt.loc/users with param:
    • token (obtained with successful login)
  6. See result: list of users

Built With

lumen-api-jwt-auth's People

Contributors

freeongoo avatar

Watchers

 avatar  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.