stallionexpress/authutility

Package to implement auth

0.0.35 2024-08-22 10:54 UTC

README

Latest Version on Packagist Total Downloads

This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.

Installation

You can install the package via composer:

composer require stallionexpress/authutility

.env setup

Setup these keys in your .env file

AUTH_SERVER_URL="http://auth.stallionexpress.xyz"
CLIENT_ID="your client id"
CLIENT_SECRET="your client secret"
FRONT_END_URL="your front end redirect url"

Register provider

First add Register StallionExpress\AuthUtility\Providers\StallionServiceProvider in your config/app.php

'providers' => [
        StallionExpress\AuthUtility\Providers\StallionServiceProvider::class,
]

Register guard

Add the below code in your config/auth.php

'guards' => [
        'token' => [
            'driver' => 'access_token',
        ],
    ],

Middleware Usage

If you want to use our middleware to decode has value then add middleware to laravel project

step 1: add middleware to kernal

use StallionExpress\AuthUtility\Middleware\ReplaceRouteAndRequestHashValueMiddleware;

step 2: add middleware to kernal

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            ReplaceRouteAndRequestHashValueMiddleware::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
            'throttle:api',
            ReplaceRouteAndRequestHashValueMiddleware::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],
    ];

Trait Usage

If you want to use PrimaryIdEncodeTrait

  • Step 1: Import namespace
use StallionExpress\AuthUtility\Trait\PrimaryIdEncodeTrait;
  • Step 2: Add to use
use PrimaryIdEncodeTrait;

If you want to use STEncodeDecodeTrait

  • Step 1: Import namespace
use StallionExpress\AuthUtility\Trait\STEncodeDecodeTrait;
  • Step 2: Add to use
use STEncodeDecodeTrait;

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email avinashkant@stallionexpress.ca instead of using the issue tracker.

Credits

License

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

  • lluminate/support": "^10.12.0"