Download the PHP package narakode/fineauth without Composer

On this page you can find all versions of the php package narakode/fineauth. 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 fineauth

Fine Auth

A simple authentication package for Laravel REST APIs.

Features

Requirements

Installation

Install the package:

Publish the package configuration:

This package requires Laravel Sanctum. If you haven't installed it yet, run:

Add the HasApiTokens and HasRefreshTokens traits to your User model.

Usage

Register the authentication routes in your routes file (for example, routes/api.php):

You can verify that the routes have been registered by listing your application's routes:

Endpoints

Login

The POST /login endpoint requires the following request parameters:

The package uses Laravel's authentication system to validate the provided credentials.

If the credentials are invalid, it returns a 401 Unauthorized response:

If authentication succeeds, it returns a 200 OK response:

A refresh token is also returned as an HTTP cookie named refresh_token with the following attributes:

Current User

The GET /me endpoint returns the authenticated user associated with the provided access token.

Provide the access token in the Authorization header using the following format:

If the access token is valid, the response will be:

If the access token is missing or invalid, the endpoint returns a 401 Unauthorized response.

Refresh Token

The POST /refresh-token endpoint returns a new access token and the authenticated user using the refresh token stored in a cookie.

If the cookie is exists and has not expired, the response is the same as login. Otherwise, the endpoint returns 401 Unauthorized.

Customization

Custom Credentials

By default, this package uses the email and password fields as the authentication credentials.

You can customize these credentials by creating a class that implements the Narakode\FineAuth\Auth\AuthCredentials interface.

The class should define a rules method that returns an array containing the credential fields and their validation rules.

For example, create App\Auth\AuthCredentials.php.

Then, register the AuthCredentials in your application service provider (App\Providers\AppServiceProvider.php).

Custom Authenticator

By default, this package uses Auth::attempt($credentials) to determine whether the credentials are valid.

You can customize this behavior by creating a class that implements the Narakode\FineAuth\Auth\Authenticator interface.

The class should define an attempt method that accepts a credentials array as its parameter.

The attempt method should return a User object when the credentials are valid, or false when they are invalid.

For example, create App\Auth\Authenticator.php.

Then, register the Authenticator in your application service provider (App\Providers\AppServiceProvider.php).

Adding Meta

You can add a meta object to the response for the login, refresh, and me endpoints by creating a class that implements the Narakode\FineAuth\Auth\AuthMeta interface.

The class should define a toArray method that accepts a Narakode\FineAuth\Auth\AuthContext object as its parameter.

The toArray method should return an array that will be included as the meta field in the JSON response.

The AuthContext object exposes the getUser method, which returns the authenticated User object.

For example, create App\Auth\AuthMeta.php.

Then, register the AuthMeta in your application service provider (App\Providers\AppServiceProvider.php).

Custom Expiration

By default, the access token expires after 15 minutes, and the refresh token expires after 2 months.

To customize these values, edit the config/fineauth.php file. The expiration values are specified in minutes.


All versions of fineauth with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
laravel/sanctum Version ^4.3
laravel/framework Version ^13.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 narakode/fineauth contains the following files

Loading the files please wait ...