Download the PHP package kipchak/middleware-auth-key without Composer

On this page you can find all versions of the php package kipchak/middleware-auth-key. 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 middleware-auth-key

API Key Middleware for Kipchak

This Middleware package provides API Key Authentication support for Kipchak APIs.

Composer Package

kipchak/middleware-auth-key

How to use it?

Install it via composer: composer require kipchak/middleware-auth-key.

Then just ensure you have appropriate settings configured in kipchak.auth.key.php config file in the root of your project.

For a sample, please see: https://github.com/kipchak-dev/examples/blob/master/config/kipchak.auth.key.php.

Configuration

Key Default Meaning
enabled Check every request for a key.
ignore_options Let OPTIONS (CORS preflight) requests through without a key.
ignore_paths Paths that need no key, compared exactly.
authorised_keys Each authorised key, mapped to the name of the client that uses it.
header The request header that carries the key. It is read first.
query_param The query parameter that carries the key when the header is absent.
accept_query_param true From 1.43. false accepts the key from the header only.

We recommend setting accept_query_param to false. A key in a URL ends up in access logs, proxy logs and browser history, where anyone who reads them can use it. It stays true by default so that an existing configuration keeps working unchanged.

Keys are compared in constant time (from 1.43): the presented key and every authorised key are hashed with SHA-256 and compared with hash_equals(), against every entry, so the time taken does not reveal which key matched or how long it is.

The client name on the request

From 1.43, a request whose key matched reaches your route with the client name, the value the key maps to in authorised_keys, in the request attribute kipchak.auth.key.client (the constant ApiKey::ATTRIBUTE_CLIENT):

Responses

A request without an authorised key gets a 401 with the message Missing or invalid key and the status UNAUTHENTICATED, the same status kipchak/middleware-error gives a 401 (from kipchak/core's ErrorStatus).

Upgrading to 1.41: it requires kipchak/core 3.18, and the status of that 401 is UNAUTHENTICATED instead of UNAUTHORIZED. A client that compares the status string needs the new one.

Release notes

1.43

No change for an existing configuration: the same keys are accepted, from the header first and then the apikey query parameter, with the same ignore_paths, ignore_options and the same 401. A test runs 1.41's sample.config.php unchanged through the 1.41 handler and this one and compares the results.

Tests

What is a Kipchak Middleware?

Kipchak Middleware is a standard PHP PSR-15 middleware.

Middleware is a component that sits between the request and response of a web application, allowing for interception and modification of the request and response data. In the context of Kipchak, middleware can be used to handle errors, authentication, and other cross-cutting concerns that are common across one or more API endpoints.


All versions of middleware-auth-key with dependencies

PHP Build Version
Package Version
Requires kipchak/core Version ^3.18
kipchak/driver-config Version ^1
kipchak/driver-logger Version ^1
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 kipchak/middleware-auth-key contains the following files

Loading the files please wait ...