payloadtoken/aragorn52

this library for payload from access token in lumen passport

1.0.4 2022-09-20 08:14 UTC

This package is auto-updated.

Last update: 2024-04-20 11:57:24 UTC


README

Library to add payload to Access token for lumen passport

Dependencies

  • PHP >= 8.1
  • Lumen >= 9.0
  • Lumen-passport: >= 0.1.1

Installation via Composer

$ composer require payloadtoken/aragorn52

Or if you prefer, edit composer.json manually:

{
    "require": {
        "payloadtoken/aragorn52": "^1.0"
    }
}

Modify the bootstrap flow (bootstrap/app.php file)

$app->register(\Payload\Providers\PassportServiceProvider::class);

Create YourCustomClaimService. Extends \Payload\Services\AbstractClaimService

in method addCustomClaim add for claimCollection your claims

id user can be obtained by accessing the $this->id property YourCustomClaimService

class YourCustomClaimService extends \Payload\Services\AbstractClaimService
{
    public function addCustomClaims(): void
    {
        $this->claimCollection->add('test', 'testClaim');
        $this->claimCollection->add('test2', 'testClaim2');
    }
}

Modify the AppServiceProvider flow (app/Providers/PassportServiceProvider) add this code in method boot()

    public function boot()
    {
        $this->app->bind(\Payload\Services\AbstractClaimService::class, fn () => new YourCustomClaimService());
    }