luchavez/passport-pgt-server

Laravel Passport Password Grant Tokens Server for Laravel 8|9|10

2.0.1 2023-09-17 06:38 UTC

This package is auto-updated.

Last update: 2024-10-17 09:14:01 UTC


README

Latest Version on Packagist Total Downloads GitHub Repo stars Discord Twitter Follow

Laravel Passport is an authentication package for Laravel. It is used by a lot of Laravel apps to authenticate users before accessing any resources. Basically, it generates an access token which you can then use on every request to provide identification to the OAuth Server.

One of Laravel Passport's mostly used authentication methods is the Password Grant Tokens grant type. It is a stateless way to get access tokens and refresh tokens from the OAuth Server.

Take a look at contributing.md if you want to contribute to this project.

Passport PGT Client-Server

Installation

Via Composer

// Install the package and its dependencies
$ composer require luchavez/passport-pgt-server --with-all-dependencies

// Publish the config, migrate Passport tables, and run passport:install
$ php artisan pgt:server:install

Setting Up

  1. Run php artisan migrate to create the Passport related tables.

  2. Use Passport's Laravel\Passport\HasApiTokens on User model.

  3. Add these variables to .env file if you want to override the default values.

Usage

Passport PGT Server

The package provides a service called PassportPgtServer which you can use by calling its helper functions:

  1. passportPgtServer()
  2. passport_pgt_server()

Here's the list of its available methods.

Routes

By default, laravel/passport adds authentication related routes. This package adds two new routes: /api/oauth/logout and /api/oauth/me.

Here's the list of routes that this package provides.

Note: If you wish to override the logout or get self logic, feel free to do so by updating the published passport-pgt-server config file.

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email jamescarloluchavez@gmail.com instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.