5d94572569
Vorbereitung für pod-unabhängige Sessions (k8s-Ziel). Ändert am Live-System NICHTS: AUTH_BACKEND='session' bleibt Default, die neuen Libs sind noch nirgends verdrahtet. - composer eingeführt: firebase/php-jwt ^6.11 + predis/predis ^2.4 (pure PHP, keine Redis-Extension nötig → läuft auf XAMPP wie im Prod-Image). vendor/ committed (kein Composer auf dem Server). - Jwt.php: HS256-Access-Token (issue/verify), decode() IMMER mit explizitem Algorithmus (mitigiert Algorithmus-Confusion). 8/8 Tests grün. - SessionStore.php: predis-gestützter Session/Refresh-Store (sess:<sid>, Sliding-TTL, revoke=DEL) — die widerrufbare Session hinter dem kurzen JWT. - app.php: vendor/autoload (guarded), Konstanten AUTH_BACKEND (Default session), REDIS_URL, JWT_TTL, JWT_REFRESH_TTL. JWT_SECRET bewusst ohne Default. - docker-compose.dev.yml: Redis (+ redis-commander UI) für lokale Dev-Parität. - .env.example um Auth-Block ergänzt. Nächste Phasen: $_SESSION-Zugriffe (293) durch Session:: kanalisieren → Backend-Umschalter in Session.php → doppelgleisiger Cutover → Reporting auf student_id-FK ziehen. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Firebase\JWT;
|
|
|
|
use InvalidArgumentException;
|
|
use OpenSSLAsymmetricKey;
|
|
use OpenSSLCertificate;
|
|
use TypeError;
|
|
|
|
class Key
|
|
{
|
|
/**
|
|
* @param string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate $keyMaterial
|
|
* @param string $algorithm
|
|
*/
|
|
public function __construct(
|
|
private $keyMaterial,
|
|
private string $algorithm
|
|
) {
|
|
if (
|
|
!\is_string($keyMaterial)
|
|
&& !$keyMaterial instanceof OpenSSLAsymmetricKey
|
|
&& !$keyMaterial instanceof OpenSSLCertificate
|
|
&& !\is_resource($keyMaterial)
|
|
) {
|
|
throw new TypeError('Key material must be a string, resource, or OpenSSLAsymmetricKey');
|
|
}
|
|
|
|
if (empty($keyMaterial)) {
|
|
throw new InvalidArgumentException('Key material must not be empty');
|
|
}
|
|
|
|
if (empty($algorithm)) {
|
|
throw new InvalidArgumentException('Algorithm must not be empty');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Return the algorithm valid for this key
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getAlgorithm(): string
|
|
{
|
|
return $this->algorithm;
|
|
}
|
|
|
|
/**
|
|
* @return string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate
|
|
*/
|
|
public function getKeyMaterial()
|
|
{
|
|
return $this->keyMaterial;
|
|
}
|
|
}
|