New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

ackosoft/auth-adapter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ackosoft/auth-adapter

auth adapter for oauth2 passport

Source
Packagist
Version
v1.1
Version published
Total downloads
20
Maintainers
1
Created
Source

Installation

This package is specially for lumen micro auth service client app.

$ composer require ackosoft/auth-adapter

Create config folder in your root directory. then add the following code into config/auth.php

<?php
return [
    'defaults' => [
        'guard' => 'api',
        'passwords' => 'users',
    ],

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

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => \App\User::class
        ]
    ],
    'auth_connection'=>env('AUTH_DB_CONNECTION','mysql')
];

If you use seperate mysql connection for Passport Authentication so you can do it by chaning env variable. Example:

AUTH_DB_CONNECTION=mysql2

Modify bootstrap/app.php file for enabling the package

// Enable Facades
$app->withFacades();

// Enable Eloquent
$app->withEloquent();

$app->register(Laravel\Passport\PassportServiceProvider::class);
$app->register(\Ackosoft\AuthAdapter\AppServiceProvider::class);
$app->routeMiddleware([
     'auth' => \Ackosoft\AuthAdapter\Middleware\AuthMiddleware::class,
 ]);

$app->configure('auth'); //Add this line if not working properly

Make sure your user model uses Passport's HasApiTokens trait, eg.:

class User extends Model implements AuthenticatableContract, AuthorizableContract
{
    use HasApiTokens, Authenticatable, Authorizable;

    /* rest of the model */
}
 

If you use seprate database for authentication so add the connection in User model

    protected $connection = 'mysql2'; 

Todos

  • Add more features

License

MIT

FAQs

Package last updated on 21 Aug 2019

Related posts