kongono / security
Kongono v1 standalone PHP 8.5 security & passwordless auth primitives: HKDF XChaCha20-Poly1305 Encryptor, Argon2id PasswordHasher, RFC 6238 Totp + pure-PHP ISO/IEC 18004 QrCodeSvg, cryptographic QrLoginAuth, OneTimeCodeAuth (Email/SMS OTP), MagicLinkAuth, WebAuthn PasskeyVerifier (ES256/Ed25519), PK
Package info
pkg:composer/kongono/security
v1.25.0
2026-11-26 18:20 UTC
Requires
- php: >=8.5.13
- ext-curl: *
- ext-dom: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- ext-sodium: *
- kongono/core: ^1.23
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
None
Suggests
- kongono/database: Required only when using PdoPersonalAccessTokenStore for SQL-backed Personal Access Tokens.
- kongono/http: Required only when using SessionAuth, RememberMeManager, Gate HTTP exceptions, or Kongono PSR-15 security middleware.
Provides
None
Conflicts
None
Replaces
None
README
Read-only subtree split of
kongono/framework. Open issues and pull requests in the main monorepo.
Standalone, zero-Symfony PHP 8.5.13+ security & passwordless authentication primitives usable in any PHP application (Laravel, Symfony, Slim, or vanilla PHP):
- Cryptographic QR Login & Pure-PHP SVG QR Encoder:
QrLoginAuth(phishing-resistant cross-device sign-in with desktop-onlypoll_secret, 6-digitXXX-XXXQRLjacking verification code & atomic single-useclaim()) +QrCodeSvg(ISO/IEC 18004 Versions 1–10 strict-CSP inline<svg>). - Passwordless, Passkeys & 2FA:
PasskeyVerifier(complete WebAuthn/FIDO2 registration & assertions with pure-PHP RFC 8949CborDecoderfor ES256 P-256, EdDSA Ed25519 & RS256 Windows Hello TPMs),OneTimeCodeAuth(Email/SMS OTP with HKDF storage & brute-force lockout),MagicLinkAuth(single-use HMAC links),Totp(RFC 6238 +provisioningQrSvg()+ 80-bit recovery codes),PkceOAuthClient(GitHub/Google/OIDC S256). - Cryptography & App Defense: HKDF
Encryptorv2 (XChaCha20-Poly1305 AEAD + key rotation), Argon2idPasswordHasher,TokenSigner,SignedUrl, revocable SHA-256PersonalAccessToken, HTML5 LexborHtmlSanitizer, multi-providerWebhookSignerRegistry(registerStripe()+#[VerifyWebhook('stripe')]) /WebhookDispatcher, and DNS-pinned SSRF-proofSafeHttpClient.
Installation
composer require kongono/security
Examples
<?php declare(strict_types=1); use Kongono\Core\Cache\MemoryCache; use Kongono\Security\Auth\{OneTimeCodeAuth, QrLoginAuth}; use Kongono\Security\Totp; $cache = new MemoryCache(); $appKey = base64_encode(random_bytes(32)); // 1. 2FA TOTP + strict-CSP inline SVG QR code $totp = new Totp(replayCache: $cache); $secret = Totp::generateSecret(); $svg = $totp->provisioningQrSvg($secret, 'dev@example.com', 'My App'); // 2. Single-use Email/SMS OTP with automatic brute-force lockout $otp = new OneTimeCodeAuth($appKey, $cache); $issued = $otp->issue('dev@example.com', digits: 6, ttlSeconds: 600, maxAttempts: 5); $verified = $otp->verify('dev@example.com', $issued['code']); // 3. Cross-device cryptographic QR sign-in $qr = new QrLoginAuth($appKey, $cache); $challenge = $qr->begin('https://app.example.com/auth/qr/approve', requesterIp: '203.0.113.10');
Documentation & License
- Full documentation: https://kongono.com/docs.html#security
- Monorepo & issues: https://github.com/kongono/framework
- License: MIT