All Projects → iamnotstatic → laravel-api-auth

iamnotstatic / laravel-api-auth

Licence: MIT License
A Laravel Package for easy API authentication setup with passport

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-api-auth

Clean-Laravel-Api
⭐️ Build APIs You Won't Hate In Laravel.
Stars: ✭ 85 (+193.1%)
Mutual labels:  laravel-passport, laravel-api
laravel-jarvis
Achieve Your Ambition With Me .
Stars: ✭ 32 (+10.34%)
Mutual labels:  laravel-authentication
docker-laravel-vuejs
🌟 🎯 📰 Dockerized Blog + Forum + REST API + App using Laravel, Vue.js
Stars: ✭ 27 (-6.9%)
Mutual labels:  laravel-passport
docker-laravel-api-dev
🐳 The containerized Laravel API development environment
Stars: ✭ 31 (+6.9%)
Mutual labels:  laravel-api
laravel-passport-demo
Shows you how to turn your website to an Oauth2 server using Laravel Passport
Stars: ✭ 27 (-6.9%)
Mutual labels:  laravel-passport
super-basic-auth
🔒 A lightweight package to add basic authentication to your Laravel app.
Stars: ✭ 22 (-24.14%)
Mutual labels:  laravel-authentication
bearer
Minimalistic token-based authorization for Laravel API endpoints.
Stars: ✭ 74 (+155.17%)
Mutual labels:  laravel-api
kauth
🔑 kauth is JWT API Authentication ( jwt-auth ) for laravel
Stars: ✭ 14 (-51.72%)
Mutual labels:  laravel-api
lumen-lighthouse-graphql
Lumen example use of a GraphQL PHP server using Lighthouse package
Stars: ✭ 31 (+6.9%)
Mutual labels:  laravel-passport
laravel-api
A base install of Laravel with Sanctum & Fortify, set up as an API.
Stars: ✭ 58 (+100%)
Mutual labels:  laravel-api
december-2018-meetup
🤖 Build an API with Laravel 5.7
Stars: ✭ 27 (-6.9%)
Mutual labels:  laravel-api
passport
The Laravel passport compatible oauth extension for your Flarum forum.
Stars: ✭ 24 (-17.24%)
Mutual labels:  laravel-passport
laravel-passport-socialite
The missing social authentication plugin (i.e. SocialGrant) for laravel passport.
Stars: ✭ 50 (+72.41%)
Mutual labels:  laravel-passport
laravel-jwt
A seamless JWT implementation for Laravel
Stars: ✭ 71 (+144.83%)
Mutual labels:  laravel-authentication
security-starter
Security starter is a full implementation of laravel/passport and heloufir/simple-passport, containing all the implementations of the authentication and forgot password systems, which allows you to start your project from a good foundation, and only worry about the business logic of your application.
Stars: ✭ 31 (+6.9%)
Mutual labels:  laravel-passport
rest-api
Laravel restfull api boilerplate
Stars: ✭ 57 (+96.55%)
Mutual labels:  laravel-passport
simple-passport
Simple passport, is a complete implementation of laravel/passport package, containing authentication, forgot passwort, recovery password, ... and all what you need to start your application that needs a complete authentication system
Stars: ✭ 22 (-24.14%)
Mutual labels:  laravel-passport
laravel-api
A repository containing a starter kit that can help you develop api in your Laravel applications.
Stars: ✭ 25 (-13.79%)
Mutual labels:  laravel-api
api.yike.io
一刻社区后端 API 源码
Stars: ✭ 1,019 (+3413.79%)
Mutual labels:  laravel-passport
laravel-api-example
💻 Build an API with Laravel 5
Stars: ✭ 47 (+62.07%)
Mutual labels:  laravel-api

Laravel API Auth

GitHub issues GitHub stars GitHub license Total Downloads

Introduction

A Laravel Package for easy API authentication setup with passport

Installation

To get the latest version of Laravel Api Auth, simply require it

composer require iamnotstatic/laravel-api-auth

Configuration

You can publish the configuration file using this command:

php artisan vendor:publish --provider="Iamnotstatic\LaravelAPIAuth\LaravelAPIAuthServiceProvider"

Migrate your database after installing the package

php artisan migrate

This command will create the encryption keys needed to generate secure access tokens. In addition, the command will create "personal access" and "password grant" clients which will be used to generate access tokens

php artisan passport:install

Next, you should call the Passport::routes method within the boot method of your AuthServiceProvider. This method will register the routes necessary to issue access tokens and revoke access tokens, clients, and personal access tokens:

<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
use Laravel\Passport\Passport;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();

        Passport::routes();
    }
}

In your config/auth.php configuration file, you should set the driver option of the api authentication guard to passport. This will instruct your application to use Passport's TokenGuard when authenticating incoming API requests:

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
],

In your config/auth.php configuration file, you should set the model option of the package model. This will provide a few helper methods to allow you to inspect the authenticated user's token and scopes:

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => Iamnotstatic\LaravelAPIAuth\Models\User::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],

Usage

Now, we can simple test by rest client tools (Postman), So I test it and you can see below screenshots.

In this api you have to set two header as listed below:

Accept: application/json

pkg imgs

Register

register

Login

login

Logout

logout

Get User

getuser

Forgotten Password

forgottenpass

Reset Passowrd

passwordreset

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

How can I thank you?

Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!

Don't forget to follow me on twitter!

Thanks! Abdulfatai Suleiman.

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].