Download the PHP package faithfm/laravel-simple-auth-tokens without Composer

On this page you can find all versions of the php package faithfm/laravel-simple-auth-tokens. 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-simple-auth-tokens

laravel-simple-auth-tokens

Authentication of routes using API keys (ie: https://example.com/my/route?api_token=XXXX) can be achieved simply using Laravel's built-in 'token' authentication driver.

This package enables this functionality by providing a simple migration to add the required api_token field to your users table.

We often enable session-based (as well as token-based) authentication on our API routes, but Laravel's StartSession middleware creates new sessions every time a request is made from an API clients (because it typically doesn't support cookies). This can quickly result in the creation of thousands of sessions.

To solve this issue, this package provides a replacement StartSession middleware that prevents sessions from being created when api_token=XXXX is detected in a given request.

Installation + Configuration:

Modify Models\User.php to include the new api_token field:

For Laravel 8 onwards, add a token-based guard to config/auth.php in the Authentication Guards section. (This config was included by default in prior versions.)

Modify App\Http\Kernel.php to replace the StartSession middleware for WEB routes:

(Optionally) modify App\Http\Kernel.php to add the session-based middleware for API routes (if you want to enable session-based as well as token-based authentication in API routes):

[!CAUTION]

For Laravel 11 onwards, modify bootstrap/app.php instead... [NOT FULLY TESTED]

Usage:

Assuming session and token guards have been configured as 'web' and 'api' respectively (ie: Laravel defaults), you can use Laravel's normal authentication methods as follows:

When multiple alternative guards have been specified via middleware (ie: the last example above), all authentication calls inside this route are implicitly resolved using the first authenticated guard that was found: (The middleware calls the shouldUse() method which overrides the configured default guard.)

We also have created an extended auth_guards() helper that allows multiple guards to be specified, since unfortunately neither Laravel's guard() helper nor Auth::guard() facade support multiple guards outside of a middleware-protected-route - ie:

How It Works:

Laravel's built-in 'token' authentication driver is:

This 'token' driver attempts to authenticate a request using the following approach:

Our FaithFM\SimpleAuthTokens\Http\Middleware\StartSession middleware works as follows:

[!NOTE]

A side-effect of our StartSession middleware this is that if you load a route from a browser that already has a valid / logged-in session, this session becomes invisible if you add an api_token=XXXX request parameter to the URL. (ie: authentication can't fall-back to the session if the api_token has been specified)


All versions of laravel-simple-auth-tokens with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0|^8.0
illuminate/support Version >5.0
laravel/framework Version >5.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 faithfm/laravel-simple-auth-tokens contains the following files

Loading the files please wait ....