Phase 0: Fundament für Inhaus
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s

- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3)
- Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung
- Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü
- Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person
- Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“
- Benutzerverwaltung im Admin, Zugang vorläufig über is_admin
- vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/
- PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung
- VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-25 20:35:30 +00:00
parent 7197eaebf2
commit 9c0f8de791
15771 changed files with 1564103 additions and 5 deletions

View file

@ -0,0 +1,170 @@
<?php
declare(strict_types=1);
namespace Cose\Signature;
use CBOR\ByteStringObject;
use CBOR\CBORObject;
use CBOR\Decoder;
use CBOR\ListObject;
use CBOR\MapObject;
use CBOR\OtherObject\OtherObjectManager;
use CBOR\StringStream;
use CBOR\Tag;
use CBOR\Tag\CoseSign1Tag as UpstreamTag;
use CBOR\Tag\TagManager;
use const E_USER_DEPRECATED;
use InvalidArgumentException;
use function sprintf;
use function trigger_error;
/**
* A tagged COSE_Sign1 (RFC 9052, CBOR tag 18).
*
* @deprecated since 4.8.0, use \CBOR\Tag\CoseSign1Tag from spomky-labs/cbor-php 3.4.0 or later instead. Will be removed
* in 5.0.0.
*
* The six COSE structures were ported upstream in cbor-php 3.4.0, where they share AbstractCoseTag and are
* registered in the default decoder, so Decoder::create() resolves tag 18 on its own. The replacement accepts what
* this class rejects -- a zero-length protected header, a detached (nil) payload, the indefinite-length encodings --
* and reads every item through the list it carries, so its accessors cannot drift from the bytes it serializes.
*
* What does not move upstream is the RFC 9052 layer above the CBOR shape, and that stays here: {@see \Cose\Structure\CoseHeaders}
* for header labels typed as RFC 9052 section 1.5 defines them, and the Sig_structure, MAC_structure and
* Enc_structure builders that a signature or a MAC is actually computed over. Both work on the upstream classes.
*
* Migrating: the class name changes, and the four-argument create() becomes createFromComponents() -- upstream
* create() takes the whole list instead.
*
* @see https://github.com/web-auth/cose-lib/issues/176
* @see \Cose\Tests\Structure\DeprecatedTagClassesTest
*/
final class CoseSign1Tag extends Tag
{
/**
* A COSE header is a flat map of a handful of parameters whose values nest a couple of levels at most, so the
* decoder built when none is given is bounded far below the cbor-php default of 1000: a protected header crafted
* to nest thousands of levels is rejected instead of being walked.
*/
public const DEFAULT_PROTECTED_HEADER_MAX_DEPTH = 32;
private const TAG_ID = 18;
private readonly ByteStringObject $protectedHeader;
private readonly MapObject $unprotectedHeader;
private readonly ByteStringObject $payload;
private readonly ByteStringObject $signature;
public function __construct(int $additionalInformation, ?string $data, CBORObject $object)
{
trigger_error(sprintf(
'The class "%s" is deprecated since 4.8.0 and will be removed in 5.0.0. Use "%s" from spomky-labs/cbor-php 3.4.0 or later instead.',
self::class,
UpstreamTag::class
), E_USER_DEPRECATED);
if (! $object instanceof ListObject) {
throw new InvalidArgumentException('Not a valid CoseSign1 object. No list.');
}
if ($object->count() !== 4) {
throw new InvalidArgumentException('Not a valid CoseSign1 object. The list shall have 4 items.');
}
$protectedHeader = $object->get(0);
$unprotectedHeader = $object->get(1);
$payload = $object->get(2);
$signature = $object->get(3);
if (! $protectedHeader instanceof ByteStringObject) {
throw new InvalidArgumentException(
'Not a valid CoseSign1 object. The item 1 shall be a ByteString object.'
);
}
if (! $unprotectedHeader instanceof MapObject) {
throw new InvalidArgumentException('Not a valid CoseSign1 object. The item 2 shall be a Map object.');
}
if (! $payload instanceof ByteStringObject) {
throw new InvalidArgumentException(
'Not a valid CoseSign1 object. The item 3 shall be a ByteString object.'
);
}
if (! $signature instanceof ByteStringObject) {
throw new InvalidArgumentException(
'Not a valid CoseSign1 object. The item 4 shall be a ByteString object.'
);
}
parent::__construct($additionalInformation, $data, $object);
$this->protectedHeader = $protectedHeader;
$this->unprotectedHeader = $unprotectedHeader;
$this->payload = $payload;
$this->signature = $signature;
}
public static function getTagId(): int
{
return self::TAG_ID;
}
public static function createFromLoadedData(int $additionalInformation, ?string $data, CBORObject $object): self
{
return new self($additionalInformation, $data, $object);
}
public static function create(
MapObject $protectedHeader,
MapObject $unprotectedHeader,
ByteStringObject $payload,
ByteStringObject $signature
): self {
$protectedHeaderAsBytesString = ByteStringObject::create((string) $protectedHeader);
$object = ListObject::create([$protectedHeaderAsBytesString, $unprotectedHeader, $payload, $signature]);
[$additionalInformation, $data] = self::determineComponents(self::TAG_ID);
return new self($additionalInformation, $data, $object);
}
public function getProtectedHeader(): ByteStringObject
{
return $this->protectedHeader;
}
/**
* The nesting bound only applies to the decoder created here: a caller passing its own $decoder sets its own
* bound, and $maxDepth is then ignored.
*/
public function getProtectedHeaderAsMap(
?Decoder $decoder = null,
int $maxDepth = self::DEFAULT_PROTECTED_HEADER_MAX_DEPTH
): MapObject {
$stream = new StringStream($this->protectedHeader->getValue());
$decoder ??= Decoder::create(TagManager::create(), OtherObjectManager::create(), $maxDepth);
$decoded = $decoder->decode($stream);
if (! $decoded instanceof MapObject) {
throw new InvalidArgumentException('Protected header is not a valid Map object.');
}
return $decoded;
}
public function getUnprotectedHeader(): MapObject
{
return $this->unprotectedHeader;
}
public function getPayload(): ByteStringObject
{
return $this->payload;
}
public function getSignature(): ByteStringObject
{
return $this->signature;
}
}

View file

@ -0,0 +1,164 @@
<?php
declare(strict_types=1);
namespace Cose\Signature;
use CBOR\ByteStringObject;
use CBOR\CBORObject;
use CBOR\Decoder;
use CBOR\ListObject;
use CBOR\MapObject;
use CBOR\OtherObject\OtherObjectManager;
use CBOR\StringStream;
use CBOR\Tag;
use CBOR\Tag\CoseSignTag as UpstreamTag;
use CBOR\Tag\TagManager;
use const E_USER_DEPRECATED;
use InvalidArgumentException;
use function sprintf;
use function trigger_error;
/**
* A tagged COSE_Sign (RFC 9052, CBOR tag 98).
*
* @deprecated since 4.8.0, use \CBOR\Tag\CoseSignTag from spomky-labs/cbor-php 3.4.0 or later instead. Will be removed
* in 5.0.0.
*
* The six COSE structures were ported upstream in cbor-php 3.4.0, where they share AbstractCoseTag and are
* registered in the default decoder, so Decoder::create() resolves tag 98 on its own. The replacement accepts what
* this class rejects -- a zero-length protected header, a detached (nil) payload, the indefinite-length encodings --
* and reads every item through the list it carries, so its accessors cannot drift from the bytes it serializes.
*
* What does not move upstream is the RFC 9052 layer above the CBOR shape, and that stays here: {@see \Cose\Structure\CoseHeaders}
* for header labels typed as RFC 9052 section 1.5 defines them, and the Sig_structure, MAC_structure and
* Enc_structure builders that a signature or a MAC is actually computed over. Both work on the upstream classes.
*
* Migrating: the class name changes, and the four-argument create() becomes createFromComponents() -- upstream
* create() takes the whole list instead.
*
* @see https://github.com/web-auth/cose-lib/issues/176
* @see \Cose\Tests\Structure\DeprecatedTagClassesTest
*/
final class CoseSignTag extends Tag
{
/**
* A COSE header is a flat map of a handful of parameters whose values nest a couple of levels at most, so the
* decoder built when none is given is bounded far below the cbor-php default of 1000: a protected header crafted
* to nest thousands of levels is rejected instead of being walked.
*/
public const DEFAULT_PROTECTED_HEADER_MAX_DEPTH = 32;
private const TAG_ID = 98;
private readonly ByteStringObject $protectedHeader;
private readonly MapObject $unprotectedHeader;
private readonly ByteStringObject $payload;
private readonly ListObject $signatures;
public function __construct(int $additionalInformation, ?string $data, CBORObject $object)
{
trigger_error(sprintf(
'The class "%s" is deprecated since 4.8.0 and will be removed in 5.0.0. Use "%s" from spomky-labs/cbor-php 3.4.0 or later instead.',
self::class,
UpstreamTag::class
), E_USER_DEPRECATED);
if (! $object instanceof ListObject) {
throw new InvalidArgumentException('Not a valid CoseSign object. No list.');
}
if ($object->count() !== 4) {
throw new InvalidArgumentException('Not a valid CoseSign object. The list shall have 4 items.');
}
$protectedHeader = $object->get(0);
$unprotectedHeader = $object->get(1);
$payload = $object->get(2);
$signatures = $object->get(3);
if (! $protectedHeader instanceof ByteStringObject) {
throw new InvalidArgumentException('Not a valid CoseSign object. The item 1 shall be a ByteString object.');
}
if (! $unprotectedHeader instanceof MapObject) {
throw new InvalidArgumentException('Not a valid CoseSign object. The item 2 shall be a Map object.');
}
if (! $payload instanceof ByteStringObject) {
throw new InvalidArgumentException('Not a valid CoseSign object. The item 3 shall be a ByteString object.');
}
if (! $signatures instanceof ListObject) {
throw new InvalidArgumentException('Not a valid CoseSign object. The item 4 shall be a List object.');
}
parent::__construct($additionalInformation, $data, $object);
$this->protectedHeader = $protectedHeader;
$this->unprotectedHeader = $unprotectedHeader;
$this->payload = $payload;
$this->signatures = $signatures;
}
public static function getTagId(): int
{
return self::TAG_ID;
}
public static function createFromLoadedData(int $additionalInformation, ?string $data, CBORObject $object): self
{
return new self($additionalInformation, $data, $object);
}
public static function create(
MapObject $protectedHeader,
MapObject $unprotectedHeader,
ByteStringObject $payload,
ListObject $signatures
): self {
$protectedHeaderAsBytesString = ByteStringObject::create((string) $protectedHeader);
$object = ListObject::create([$protectedHeaderAsBytesString, $unprotectedHeader, $payload, $signatures]);
[$additionalInformation, $data] = self::determineComponents(self::TAG_ID);
return new self($additionalInformation, $data, $object);
}
public function getProtectedHeader(): ByteStringObject
{
return $this->protectedHeader;
}
/**
* The nesting bound only applies to the decoder created here: a caller passing its own $decoder sets its own
* bound, and $maxDepth is then ignored.
*/
public function getProtectedHeaderAsMap(
?Decoder $decoder = null,
int $maxDepth = self::DEFAULT_PROTECTED_HEADER_MAX_DEPTH
): MapObject {
$stream = new StringStream($this->protectedHeader->getValue());
$decoder ??= Decoder::create(TagManager::create(), OtherObjectManager::create(), $maxDepth);
$decoded = $decoder->decode($stream);
if (! $decoded instanceof MapObject) {
throw new InvalidArgumentException('Protected header is not a valid Map object.');
}
return $decoded;
}
public function getUnprotectedHeader(): MapObject
{
return $this->unprotectedHeader;
}
public function getPayload(): ByteStringObject
{
return $this->payload;
}
public function getSignatures(): ListObject
{
return $this->signatures;
}
}

View file

@ -0,0 +1,136 @@
<?php
declare(strict_types=1);
namespace Cose\Signature;
use CBOR\ByteStringObject;
use CBOR\CBORObject;
use CBOR\IndefiniteLengthByteStringObject;
use CBOR\IndefiniteLengthListObject;
use CBOR\IndefiniteLengthMapObject;
use CBOR\ListObject;
use CBOR\MapObject;
use Cose\Structure\CoseHeaders;
use Cose\Structure\HeaderMapHelper;
use InvalidArgumentException;
/**
* One entry of the "signatures" list of a COSE_Sign (RFC 9052 section 4.1).
*
* COSE_Signature = [ Headers, signature : bstr ]
*
* The raw list a message carries says nothing about what is inside it, and neither cbor-php nor the deprecated
* Cose\Signature\CoseSignTag looks: both accept an empty list and entries of any shape. This view is the checked
* form, and it carries the same header reader as the message, because a signer of a COSE_Sign has a protected
* bucket of its own that its signature commits to.
*
* ```php
* foreach ($message->getSignatures() as $entry) {
* $signer = CoseSignature::create($entry);
* $toBeSigned = Signature::create(
* $message->getProtectedHeader(),
* $signer->getProtectedHeader(),
* $message->getPayload(),
* );
* }
* ```
*
* @see https://www.rfc-editor.org/rfc/rfc9052#section-4.1
* @see \Cose\Tests\Structure\CoseSignatureTest
*/
final class CoseSignature
{
private readonly ByteStringObject|IndefiniteLengthByteStringObject $protectedHeader;
private readonly MapObject|IndefiniteLengthMapObject $unprotectedHeader;
private readonly ByteStringObject|IndefiniteLengthByteStringObject $signature;
public function __construct(ListObject|IndefiniteLengthListObject $signature)
{
HeaderMapHelper::assertSignatureList(ListObject::create([$signature]));
/** @var ByteStringObject|IndefiniteLengthByteStringObject $protectedHeader */
$protectedHeader = $signature->get(0);
/** @var IndefiniteLengthMapObject|MapObject $unprotectedHeader */
$unprotectedHeader = $signature->get(1);
/** @var ByteStringObject|IndefiniteLengthByteStringObject $signatureValue */
$signatureValue = $signature->get(2);
$this->protectedHeader = $protectedHeader;
$this->unprotectedHeader = $unprotectedHeader;
$this->signature = $signatureValue;
}
public static function create(ListObject|IndefiniteLengthListObject $signature): self
{
return new self($signature);
}
/**
* Every entry of a "signatures" list, checked and wrapped.
*
* @return list<self>
*/
public static function all(ListObject|IndefiniteLengthListObject $signatures): array
{
HeaderMapHelper::assertSignatureList($signatures);
$result = [];
foreach ($signatures as $signature) {
if (! $signature instanceof ListObject && ! $signature instanceof IndefiniteLengthListObject) {
throw new InvalidArgumentException('Not a valid COSE_Signature object. It shall be a List object.');
}
$result[] = new self($signature);
}
return $result;
}
/**
* The protected bucket of this signer, as it is carried: what its Sig_structure covers verbatim.
*/
public function getProtectedHeader(): ByteStringObject|IndefiniteLengthByteStringObject
{
return $this->protectedHeader;
}
public function getUnprotectedHeader(): MapObject|IndefiniteLengthMapObject
{
return $this->unprotectedHeader;
}
/**
* The headers of this signer, read the way RFC 9052 defines them.
*/
public function headers(): CoseHeaders
{
return CoseHeaders::of($this->protectedHeader, $this->unprotectedHeader);
}
public function getProtectedHeaderParameter(int|string $label): ?CBORObject
{
return $this->headers()
->getProtectedHeaderParameter($label);
}
public function getUnprotectedHeaderParameter(int|string $label): ?CBORObject
{
return $this->headers()
->getUnprotectedHeaderParameter($label);
}
public function getSignature(): ByteStringObject|IndefiniteLengthByteStringObject
{
return $this->signature;
}
/**
* The list this view was built from, rebuilt so that nothing the caller does to it reaches the message.
*/
public function toListObject(): ListObject
{
return ListObject::create([$this->protectedHeader, $this->unprotectedHeader, $this->signature]);
}
}

View file

@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace Cose\Signature;
use CBOR\ByteStringObject;
use CBOR\IndefiniteLengthByteStringObject;
use Cose\Structure\CoseStructure;
/**
* The Sig_structure of one signer of a COSE_Sign (RFC 9052 section 4.4).
*
* Sig_structure = [ "Signature", body_protected : empty_or_serialized_map, sign_protected : empty_or_serialized_map,
* external_aad : bstr, payload : bstr ]
*
* The sign_protected field is what tells this structure apart from {@see Signature1}: a signature of a COSE_Sign
* commits to the protected bucket of the message *and* to the one of its own COSE_Signature entry. Without it, a
* per-signer signature would be byte-identical to a COSE_Sign1 signature over the same header and payload.
*
*
* The fields a decoded message supplies are typed to accept the indefinite-length byte strings the cbor-php
* accessors can hand back, and are kept exactly as they were given: a cryptographic structure has to embed the
* protected bucket byte for byte, or the signature the sender computed over it no longer verifies.
* @see https://www.rfc-editor.org/rfc/rfc9052#section-4.4
* @see \Cose\Tests\Structure\CoseStructureTest
*/
final class Signature extends CoseStructure
{
private readonly ByteStringObject $externalAad;
public function __construct(
private readonly ByteStringObject|IndefiniteLengthByteStringObject $bodyProtectedHeader,
private readonly ByteStringObject|IndefiniteLengthByteStringObject $signProtectedHeader,
private readonly ByteStringObject|IndefiniteLengthByteStringObject $payload,
?ByteStringObject $externalAad = null
) {
$this->externalAad = $externalAad ?? self::emptyExternalAad();
}
public static function create(
ByteStringObject|IndefiniteLengthByteStringObject $bodyProtectedHeader,
ByteStringObject|IndefiniteLengthByteStringObject $signProtectedHeader,
ByteStringObject|IndefiniteLengthByteStringObject $payload,
?ByteStringObject $externalAad = null
): self {
return new self($bodyProtectedHeader, $signProtectedHeader, $payload, $externalAad);
}
public function getBodyProtectedHeader(): ByteStringObject|IndefiniteLengthByteStringObject
{
return $this->bodyProtectedHeader;
}
public function getSignProtectedHeader(): ByteStringObject|IndefiniteLengthByteStringObject
{
return $this->signProtectedHeader;
}
public function getPayload(): ByteStringObject|IndefiniteLengthByteStringObject
{
return $this->payload;
}
public function getExternalAad(): ByteStringObject
{
return $this->externalAad;
}
protected function context(): string
{
return 'Signature';
}
protected function items(): array
{
return [$this->bodyProtectedHeader, $this->signProtectedHeader, $this->externalAad, $this->payload];
}
}

View file

@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace Cose\Signature;
use CBOR\ByteStringObject;
use CBOR\IndefiniteLengthByteStringObject;
use Cose\Structure\CoseStructure;
/**
* The Sig_structure of a COSE_Sign1 (RFC 9052 section 4.4).
*
* Sig_structure = [ "Signature1", body_protected : empty_or_serialized_map, external_aad : bstr, payload : bstr ]
*
* The payload is a parameter rather than something read back from the message so that a detached payload -- the nil
* form of RFC 9052 section 4.2 -- is supplied by the application, which is what the RFC requires of it.
*
*
* The fields a decoded message supplies are typed to accept the indefinite-length byte strings the cbor-php
* accessors can hand back, and are kept exactly as they were given: a cryptographic structure has to embed the
* protected bucket byte for byte, or the signature the sender computed over it no longer verifies.
* @see https://www.rfc-editor.org/rfc/rfc9052#section-4.4
* @see \Cose\Tests\Signature\CoseSign1CreateAndVerifyTest
*/
final class Signature1 extends CoseStructure
{
private readonly ByteStringObject $externalAad;
public function __construct(
private readonly ByteStringObject|IndefiniteLengthByteStringObject $protectedHeader,
private readonly ByteStringObject|IndefiniteLengthByteStringObject $payload,
?ByteStringObject $externalAad = null
) {
$this->externalAad = $externalAad ?? self::emptyExternalAad();
}
public static function create(
ByteStringObject|IndefiniteLengthByteStringObject $protectedHeader,
ByteStringObject|IndefiniteLengthByteStringObject $payload,
?ByteStringObject $externalAad = null
): self {
return new self($protectedHeader, $payload, $externalAad);
}
public function getProtectedHeader(): ByteStringObject|IndefiniteLengthByteStringObject
{
return $this->protectedHeader;
}
public function getPayload(): ByteStringObject|IndefiniteLengthByteStringObject
{
return $this->payload;
}
public function getExternalAad(): ByteStringObject
{
return $this->externalAad;
}
protected function context(): string
{
return 'Signature1';
}
protected function items(): array
{
return [$this->protectedHeader, $this->externalAad, $this->payload];
}
}