Download the PHP package rafalmasiarek/authkit without Composer

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

AuthKit

Lightweight, extensible PHP 8.1+ authentication library.

Works with MySQL/MariaDB and SQLite. Designed for Slim, Laminas, Symfony or plain PHP.


Installation


Quick start


Constructor

Clock and timezone

By default Auth uses UTC for all session and challenge expiry calculations.

purgeExpiredTokens() and purgeExpired() are maintenance operations called outside the login flow. They require an explicit DateTimeImmutable $now from the caller:


Login result

login() returns a Login object — never throws by default.

With throwExceptions: true — failure throws AuthException instead.


Login extension pipeline

Extensions run after credentials are verified. Register them with addLoginExtension(). The first deny or challenge decision terminates the pipeline.

LoginContext carries $user, $ip, $userAgent, and $credentialMeta from the credential provider. Use $context->credential('key') to read individual metadata values.


Challenge flows (MFA, email activation, etc.)

An extension can require a second step instead of immediately allowing or denying.

Flow:

Challenge storage must be provided:

Schema: (new PdoChallengeStorage($pdo))->createSchema();


Token transport

Controls how the active token is stored and read on the client side.

Web (default — PHP session)

API (Bearer header)


External credential providers

AuthKit core authenticates into a local User object. External providers such as Cognito, Keycloak, Authentik or Zitadel should map their external identity to a local user inside their own CredentialProviderInterface implementation.

A credential provider may pass non-persistent login metadata through CredentialResult::success($user, $meta). This metadata is available in login extensions through LoginContext::credential().

Users authenticated via an external provider have no local password — password_hash is NULL in the database. PdoCredentialProvider explicitly rejects login attempts for such accounts.

This keeps AuthKit core storage-agnostic and avoids forcing external identity tables into the base package.


Storage schema

PdoUserStorage::createSchema() creates the users and sessions tables. PdoChallengeStorage::createSchema() creates auth_challenges (only needed for challenge flows).

Both support MySQL/MariaDB and SQLite.

Auth::createSchema() — preferred bootstrap entry point

Auth::createSchema() is the single call to initialise the full schema. It:

  1. Calls PdoUserStorage::createSchema() with the correct column types for the configured ID policy.
  2. Runs additionalSchema() for every registered login extension that implements SchemaProviderInterface.
  3. Accepts extra SchemaProviderInterface instances for non-extension components (e.g. a mailer).

$storage->createSchema() still works for simple bootstraps without extensions.

User ID policy

UserIdPolicyInterface controls both ID generation and the schema column types used by createSchema().

Method Purpose
generate() Returns the ID to insert, or null to let the database auto-increment.
idColumnDefinition(string $driver) Full inline column definition for users.id. Drives PRIMARY KEY placement.
userIdForeignType(string $driver) SQL type for sessions.user_id and any other FK referencing users.id.

NullUserIdPolicy (default) — delegates to the database:

Driver users.id sessions.user_id
MySQL INT NOT NULL AUTO_INCREMENT INT NOT NULL
SQLite INTEGER PRIMARY KEY AUTOINCREMENT INTEGER NOT NULL

Custom policy (e.g. UUID):

Extension schema — SchemaProviderInterface

Any class can declare the tables or columns it needs by implementing SchemaProviderInterface. Auth::createSchema() automatically picks it up from registered login extensions and any explicitly passed providers.

Rules for additionalSchema():

External users and nullable password_hash

password_hash is NULL in the default schema. PdoCredentialProvider treats a NULL or empty hash as a disabled local login and returns a failure — this prevents accidental password bypass.

PdoUserStorage::createUser() is intended for local password accounts and requires a non-empty password hash. External credential providers (Cognito, Keycloak, etc.) should manage user creation with their own logic, or insert directly with password_hash = NULL for users that only authenticate externally.


Hooks

All hook methods are optional — implement only what you need.


Force logout


v2.1.0 breaking changes


v2 breaking changes


License

MIT


All versions of authkit with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-pdo Version *
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 rafalmasiarek/authkit contains the following files

Loading the files please wait ...