Search by

adachsoft / oidc-provider-json-file

Arkadiusz Adach

JSON file repository adapters for OIDC provider contracts.

Package info

gitlab.com/a.adach/oidc-provider-json-file

Issues

pkg:composer/adachsoft/oidc-provider-json-file

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-11-27 05:51 UTC

This package is auto-updated.

Last update: 2026-11-27 04:51:23 UTC


README

This package provides local JSON-file adapters for the OIDC provider client, authorization-code, refresh-token, device-authorization, and signing-key repository contracts. It targets small deployments that need durable storage on a local filesystem without a database service.

Requirements

  • PHP 8.3 or newer.
  • Composer.

Installation

composer require adachsoft/oidc-provider-json-file

Usage

Construct each repository with the path of its own JSON document:

use AdachSoft\OidcProviderJsonFile\Repository\JsonAuthorizationCodeRepository;
use AdachSoft\OidcProviderJsonFile\Repository\JsonClientRepository;
use AdachSoft\OidcProviderJsonFile\Repository\JsonDeviceAuthorizationRepository;
use AdachSoft\OidcProviderJsonFile\Repository\JsonRefreshTokenRepository;
use AdachSoft\OidcProviderJsonFile\Repository\JsonSigningKeyRepository;

$clients = new JsonClientRepository(__DIR__ . '/var/oidc/clients.json');
$authorizationCodes = new JsonAuthorizationCodeRepository(__DIR__ . '/var/oidc/authorization-codes.json');
$refreshTokens = new JsonRefreshTokenRepository(__DIR__ . '/var/oidc/refresh-tokens.json');
$deviceAuthorizations = new JsonDeviceAuthorizationRepository(__DIR__ . '/var/oidc/device-authorizations.json');
$signingKeys = new JsonSigningKeyRepository(__DIR__ . '/var/oidc/signing-keys.json');

Each repository implements the corresponding interface from adachsoft/oidc-provider-contracts. Use these adapters through the repository interfaces in application services.

File layout

Each repository owns one document and indexes records by client ID, token hash, device-code hash, or key ID:

var/oidc/
├── clients.json                 {"clients": {"<clientId>": {...}}}
├── authorization-codes.json    {"authorizationCodes": {"<tokenHash>": {...}}}
├── refresh-tokens.json          {"refreshTokens": {"<tokenHash>": {...}}}
├── device-authorizations.json  {"deviceAuthorizations": {"<deviceCodeHash>": {...}}}
└── signing-keys.json            {"signingKeys": {"<keyId>": {...}}}

adachsoft/json-file-storage creates a sidecar .lock file for each document. The repository documents contain client-secret hashes and authorization-code, refresh-token, and device-code hashes only; callers must supply a hash in ClientDto::secretHash. Plaintext client secrets, authorization codes, refresh tokens, and device codes are never persisted by these adapters.

The signing-key document contains private key material. Keep it outside the web root, owned by the application user, and restricted to file mode 0600. JsonFileStorage creates the temporary replacement file with mode 0600; the atomic rename preserves that permission.

Guarantees and limits

  • Each repository operation that checks and changes state runs in one JsonFileStorage::transaction() call. This provides atomic per-repository operations across cooperating processes, including single-use authorization-code and device-authorization consumption, refresh-token rotation and family revocation, optimistic client/device-authorization/signing-key version checks, active signing-key uniqueness, and expiration or retired-key cleanup.
  • adachsoft/json-file-storage uses sidecar flock() locks and atomic file replacement. Locks are advisory, and every process accessing these documents must use the same storage implementation.
  • Storage is for a local filesystem only. Network filesystems such as NFS are not supported. Each write rewrites its repository document, so these adapters are intended for small- and medium-sized data sets.