Download the PHP package xcoorp/laravel-passport-control without Composer

On this page you can find all versions of the php package xcoorp/laravel-passport-control. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-passport-control

Introduction

Passport Control is a Laravel Passport compatible, OAuth2 resource server package.

This package is meant to be used in a Laravel application that is acting as a Resource Server only e.g. an API server that is meant to authenticate against an Authentication Server running Laravel Passport.

This project does not depend on the Laravel Passport package itself, but it does share some of the same concepts and interfaces.

Table of Contents

Installation

The installation of this package is quite straightforward. But before you start, make sure you have the pre-requisites in place.

Pre-requisites

This package assumes, you have already installed and configured Laravel Passport in your Laravel application. Once you have done this, you need to create a new client with client credentials grant type on your Passport Server.

Follow the official Laravel Passport documentation on how to do this.

Once you have done this, set the PASSCONTROL_INTROSPECTION_CLIENT_ID and PASSCONTROL_INTROSPECTION_CLIENT_SECRET environment variables accordingly.

As of now, Laravel does not Ship with an introspection endpoint. So you need to create one manually. You can do this by installing the Laravel Passport Introspection package on your Passport Server:

Once you have done this an introspection Endpoint will be available for your Laravel application, you can now continue with the installation of this package.

[!TIP] If you need more information on how to install and configure the introspection package, check out its documentation.

Composer

You can simply install the package via composer:

Once the package is installed, you should publish the configuration and migration files:

and run the migrations:

Configuration

This package comes with a configuration file that you can and should customize to your needs. The configuration file is located at config/passport-control.php.

All configuration options (except the User Model) can be also configured via environment variables instead of the configuration file.

The following Environment variables are available:

Environment Variable Value Default
PASSCONTROL_CREATE_USER Whether this package should create a user in the local db if not existent. false
PASSCONTROL_INTROSPECTION_ENDPOINT The Introspection Endpoint URL. Usually $YOUR_PASSPORT_SERVER/oauth/introspect http://localhost/oauth/introspect
PASSCONTROL_ACCESS_TOKEN_ENDPOINT The Token Endpoint URL to receive a new access token. Usually $YOUR_PASSPORT_SERVER/oauth/token http://localhost/oauth/token
PASSCONTROL_ACCESS_TOKEN_CLIENT_ID Client Id needed to get the access token for introspection. Check Pre-requisites for more information.
PASSCONTROL_ACCESS_TOKEN_CLIENT_SECRET Client Secret needed to get the access token for introspection. Check Pre-requisites for more information.
PASSCONTROL_PUBLIC_KEY_PATH Path where the public key file oauth-public.key is stored. NOTE: Specify the path without the filename. Laravel Storage Path (storage)
PASSCONTROL_INHERIT_SCOPES In Laravel Passport, you can configure that the scopes are inherited from the parent client, set to true if you have passport configured that way. False
PASSCONTROL_CACHE_STORE Cache Storage used for storing the Client Credential Access Token CACHE_STORE, file
PASSCONTROL_CACHE_PREFIX Cache Prefix used for storing the Client Credential Access Token xcoorppasscontrol

Usage

After you have installed and configured the package, you need to configure your auth guard to be passport_control. In your config/auth.php file, you can add a new guard configuration like this:

That's it, now you can protect your API routes as usual by using the auth:api middleware.

Advanced Usage

In certain circumstances, you may want to automatically create a user in your local db, if there is none. If you want so you can enable this package to do this via the config. In that case, after success authentication, if no user is found in your local db, one is created. (PASSCONTROL_CREATE_USER).

[!TIP] Only the user id field is filled, all other fields must be either nullable or have default values.

Testing

Functionality of this package is tested with Pest PHP. You can run the tests with:

Code of Conduct

In order to ensure that the community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review the security policy on how to report security vulnerabilities.

License

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


All versions of laravel-passport-control with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
symfony/psr-http-message-bridge Version ^7.1.1
nyholm/psr7 Version ^1.8.1
league/oauth2-server Version ^9.0.0
illuminate/auth Version ^11.0
illuminate/contracts Version ^11.0
illuminate/container Version ^11.0
illuminate/http Version ^11.0
illuminate/support Version ^11.0
illuminate/config Version ^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package xcoorp/laravel-passport-control contains the following files

Loading the files please wait ....