Giter Site home page Giter Site logo

gauravdave01 / jwt-multi-auth Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 8.54 MB

Boiler plate for implementing multi-auth and jwt token authentication.

License: MIT License

PHP 53.92% CSS 28.81% HTML 17.27%
laravel laravel-56 jwt-authentication jwt authentication api multi-auth mobile-api php php72

jwt-multi-auth's Introduction

Using Multi-Auth + JWT with Laravel 5.6

This application is based on implementation and application of Multi-Auth and JWT Token based authentication.

In layman's term, this respository handles a multi-role login portal and host Mobile API(s) with token authentication.


I've created 2 portals, which will have register and login functionality:

  1. Admin
  2. User

1. Admin:

  • This is very generic admin portal, you can use register feature to create an admin. Since, this is an demo application, I've kept the registration of admin the way it was.
  • If you're planning to implement this in your project, then you have to remove the registration feature and create admin user through database seeder or insert admin username and password in the database migration or some secure way to insert admin user(s).

2. User Portal

  • This portal consists of laravel basic auth features (i.e. register/login/logout). Apart from that, I've implemented JWT only for this portal. So, a user can register himself/herself using either hosted website or through API(s).
  • Using account creation from site is pretty much simple and straight forward.
  • When we talk of consuming mobile APIs, you need to register and validate user email and then when a user logs in to the system. JWT will create a token with an expiration time. Now, the expiration time is the time after which the token is no longer functional. In this repository token get expired after an hour. You can increase or decrease it's time as per your project needs.
  • Once you have the token from the login API. You'll have to store that token into presistent storage, provided by Android and Swift. Later, that token will be used to access auth restricted data API(s).
  • When token gets expired, you'll have to create a new token, for which you can refer api/refresh API endpoint and send it to user's device and that token will overwrite expired token.
  • This feature is developed in a way that user credentials will work for both desktop and mobile format.

Tech

This repository uses a two open source projects:

  • Hesto Multi-Auth - implements multi auth system (you can even implement its domain based auth)
  • JWT - Token based authentication system

Installation

Install the dependencies and devDependencies.

$ cd jwt-multi-auth/Source
$ php artisan key:generate
$ php artisan migrate

When you want to implement desgin and other feature which needs styling and script compilation, then you have to use Gulp or Webpack. This has Webpack inbuilt, but if you're comfortable with Gulp, then you've to add gulp based packages in package.json file, then you have perform:

Webpack

$ npm install
$ npm run watch

OR

For Gulp

$ npm install
$ gulp
$ gulp watch

jwt-multi-auth's People

Contributors

gauravdave01 avatar

Stargazers

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