Download the PHP package olipayne/guzzle-web-bot-auth-middleware without Composer
On this page you can find all versions of the php package olipayne/guzzle-web-bot-auth-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download olipayne/guzzle-web-bot-auth-middleware
More information about olipayne/guzzle-web-bot-auth-middleware
Files in olipayne/guzzle-web-bot-auth-middleware
Package guzzle-web-bot-auth-middleware
Short Description Guzzle middleware for HTTP Message Signatures (RFC9421) with web-bot-auth.
License MIT
Informations about the package guzzle-web-bot-auth-middleware
Guzzle Web Bot Auth Middleware (Ed25519 Edition)
A PHP Guzzle middleware for signing HTTP requests using HTTP Message Signatures (RFC 9421), specifically tailored for the web-bot-auth profile as discussed by Cloudflare. This version uses Ed25519 signatures via the libsodium PHP extension.
Requirements
- PHP 7.4+ (libsodium is bundled with PHP 7.2+, but this package uses features from 7.4+)
- The
sodiumPHP extension must be enabled. - GuzzleHTTP 7.0+
Installation
Install the package via Composer:
Prerequisites & Setup (Ed25519)
To use this middleware, you need an Ed25519 private key, its corresponding public key (in JWK format hosted publicly), and a keyid (JWK Thumbprint of the public key). The middleware uses alg: "ed25519" in the Signature-Input header.
Easiest Setup: All-in-One Ed25519 Key Generation Script
This package includes a utility script to generate everything you need for Ed25519:
-
Make the script executable (if you haven't already):
-
Run the script from your project's root directory (or any directory where you want the key files to be saved):
(Path might vary based on your setup. If installed as a library, it's in
vendor/olipayne/guzzle-web-bot-auth-middleware/bin/.)The script will:
- Create
ed25519_private.key(containing the base64 encoded Ed25519 private key - KEEP THIS SAFE AND SECRET!). - Create
ed25519_public.key(containing the base64 encoded Ed25519 public key, for your reference). - Output the Base64 Encoded Ed25519 Private Key: You'll pass this (or the path to
ed25519_private.key) to the middleware. - Output the JWK Thumbprint (kid): This is the
keyidfor the middleware. - Output the Full Ed25519 JWK: This is the JSON structure of your public key to host publicly.
Example output snippet:
- Create
-
Host Your Public Key Data for Signature-Agent The
Signature-Agentheader in your requests points to metadata that allows a verifier to discover your signing key.A common path in existing deployments is
https://your-bot.example.com/.well-known/jwks.json. The current HTTP Message Signatures directory draft recommendshttps://your-bot.example.com/.well-known/http-message-signatures-directory.If you expose a direct JWKSet URL, the content should be:
Ensure this URL is publicly accessible.
Using an Existing Ed25519 Public Key
If you already have a base64 encoded Ed25519 public key and need its JWK and kid:
-
Make the
generate-jwk.phpscript executable: -
Run it with your base64 encoded Ed25519 public key string or the path to a file containing it:
This will output the
kidand the full JWK for your existing public key. - You will need your corresponding Ed25519 private key (base64 encoded) to configure the middleware.
- Host the public JWK as described in Step 3 of the "Easiest Setup".
Usage
Provide the base64 encoded Ed25519 private key (or the path to the file like ed25519_private.key), your keyid, and your signatureAgent URL to the middleware.
Covered Components & Algorithm
- Covered Components:
("@authority" "signature-agent") - Signature Algorithm (in
Signature-Input):alg="ed25519" - JWK Algorithm (
algin JWK):Ed25519
How it Works
The middleware uses sodium_crypto_sign_detached for Ed25519 signatures. The Signature-Input header includes an alg="ed25519" parameter. The JWK for the public key uses kty: "OKP" (Octet Key Pair) and crv: "Ed25519".
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues.
Testing
Static analysis and style checks:
Optional live integration test:
Releases
See RELEASE.md for the tag-based release and Packagist publishing process.
License
This package is open-sourced software licensed under the MIT license.