How can i create multiple authendication in laravel api? - laravel

I have two different registers and logins. How can i create multiple authendication for that using laravel api.

It's a little bit tricky because Laravel Passport doesn't currently support multiple authentication yet. What I did with a previous project of mine is use this package for implementing multiple authentication for APIs using Laravel Passport. The package I've suggested is fairly simple to implement. Go check it out!

Related

Laravel-Authentication: Passport vs Sanctum

I am new to Laravel and for practicing I am trying to create a website like GoFundMe but simpler with Laravel and Vue js.
But am very confused with Laravel's authentication systems, even though I have read most of the questions here.
Which authentication system should I use ? is it ok to use Sanctum for authentication and then Spatie for user permissions?
You have to have a clear concept of the topic authentication & authorization first. You may use Laravel Sanctum powered by Laravel framework as well. Because it provides authentication support for SPAs (single-page applications), mobile applications, and simple, token-based APIs. You may also have a look at passport later.
After passing your authentication, the topic authorization comes. You may use Gate. But as you are new to Laravel framework, then it seems to be a good choice to use laravel spatie for managing your permissions. But keep in mind that, it uses Gate concept under the hood.

Front end of application is built in Laravel livewire and want to consume API's built in Lumen

I was handed over a project by my company, it was made in Laravel with livewire and Nova.The company wants me to redo the app by consuming API's written in Lumen.
The first thing that I want to ask is whether its a good idea and secondly how to go about storing jwt token in Laravel provided by the Lumen login API and use it in subsequent requests?
First question you need to ask is why do they want to rebuild something existing under Laravel to Lumen. Lumen is basically a lightweight version of Laravel. If the idea is to seperate the frontends from the backend you could keep using Laravel, it can definitely be used to define APIs.
Regarding your second question, there are already some existing libraries (https://github.com/dusterio/lumen-passport ) which can help you use Laravel Passport in Lumen, so you shouldn't have any issue and you should be able to use your token everywhere.

Information on laravel API

I need clear information about laravel API.
I've been reading lots of articles about laravel API. Beside choosing between JWT and laravel-passport—which is a whole different level of confusion—I need to get basic information about laravel API to make it clearer to me what's what.
Questions
Why does laravel passport need a database (what's the usage of those tables)?
If I change auth driver to passport in authProvider file, and not use api, would it affect my normal auth behavior?
If i use API (passport) do I have to use laravel-echo or any js library?
Laravel passport needs database to store tokens that are generated and used during authorization. Also, needs to bind these tokens to a specific users.
There are actually 5 new tables that are generated from migrations when installing Laravel Passport:
https://github.com/laravel/passport/tree/7.0/database/migrations
About using Laravel Echo or any js library is optional, and Laravel Passport does not require any of these.
See the Laravel Passport composer.json on requirements and other dependencies:
https://github.com/laravel/passport/blob/7.0/composer.json

How to use laravel package in lumen?

I want to use a laravel package named thinksaydo/envtenant from githup link
This package for creating multitenancy software in laravel , but i can't install this package in lumen
How can install this package and use it in lumen?
There are so many things you'll need for Tenancy that Lumen doesn't provide out of the box. You'll need to enable Facades, setup your Providers, and Lumen doesn't provide session support out of the box.
The purpose of Lumen is to provide a simple, fluid, stateless API that returns a Data Interchange Language. What you're doing here is attempting to run a fully-functional SaaS service on a Micro-API framework; that's not going to work.
You need to be using Laravel to accomplish the SaaS model, so it can know about Tenancy.
In Lumen, the only thing you should be looking at is an API key in your request.

Token authorisation for Laravel 5 RESTful API

I'm writing a RESTful API using Laravel 5. Out of the box, Laravel 5 provides a number of middleware services for authentication, etc.
I'm implementing a token-based authentication system for a RESTful API. My question is whether or not I should modify the existing Laravel 5 files or whether I should just ignore them and create my own middleware.
I know either would work but I'm more wondering about best practice particularly in the light of upgrading down the track as it always makes me a little nervous modifying the original code files in a framework. My normal expectation would be that a framework is kept in a separate folder from my application so that its clear which files can be safely modified with minimal effect on the upgrade path.
Not a direct answer to your question, and I have no personal experience with it, but if you hadn't seen it this may be what you're looking for: https://github.com/susomena/Laravel-Token-Auth
You can refer How to create Token-Based authentication in laravel 4?
There the answer includes link to a OAuth2-Server-Laravel which helps you to implement OAuth2 Token based Verification of requests for create Restful Api.
For documentation of OAuth2-Server0Laravel refer this link.

Resources