MDQ metadata source fails on every download in 2.4.12 / 2.4.13: Call to undefined method SimpleSAML\Utils\HTTP::createHttpClient()

Ouverte Adaptée aux débutants
#2,695 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
78/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
php

Piste de recherche

Lisez src/SimpleSAML/Metadata/Sources/MDQ.php autour de getMetaData() à la ligne 330 et suivez l’appel de téléchargement jusqu’à Utils\HTTP::fetch(). L’issue signale un appel inutilisé à createHttpClient() qui échoue sur la branche 2.4 ; supprimez-le et examinez si l’utilitaire HTTP injecté devrait prendre en charge fetch(). Le travail est terminé lorsqu’une recherche MDQ sans cache télécharge les métadonnées et applique les vérifications de entityID sur 2.4.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Since v2.4.12, the mdq metadata source (SimpleSAML\Metadata\Sources\MDQ) can no longer download metadata. Every lookup that is not already in the cache fails with:

Error: Call to undefined method SimpleSAML\Utils\HTTP::createHttpClient()

The call came with the backport of the MDQ entityID checks in 8e1190360 ("Merge commit from fork"). That commit added this to MDQ::getMetaData() (src/SimpleSAML/Metadata/Sources/MDQ.php:330):

$client = $this->httpUtils->createHttpClient([
'headers' => ['Accept' => 'application/samlmetadata+xml'],
]);

Utils\HTTP::createHttpClient() exists only in 2.5. On the 2.4 branch the method does not exist, and $client is never used: the metadata is still downloaded a few lines below with $httpUtils->fetch($mdq_url, $context), through a
separately created Utils\HTTP instance.

The tests added in the same commit injected a Utils\HTTP double that defines createHttpClient(), so they passed. They were removed from the legacy branch in f82c9b207, so nothing covers this code path with the real Utils\HTTP class.

Because Error is not an Exception, the catch (Exception $e) around the download does not catch it either. The whole metadata lookup aborts, and every IdP or SP that comes only from MDQ becomes unusable (e.g. login via eduGAIN fails).

Affected versions: v2.4.12, v2.4.13 (v2.4.11 is not affected).

Steps to reproduce

  1. Configure an MDQ source, e.g.:
    'metadata.sources' => [
    [
    'type' => 'mdq',
    'server' => 'https://mdq.aai.dfn.de',
    'validateCertificate' => '/path/to/mdq-signer.crt',
    'cachedir' => '/tmp/mdq-cache',
    ],
    ],
  2. With an empty cache directory, look up any entity:
    $handler = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler();
    $handler->getMetaData('https://idp.example.org/idp/shibboleth', 'saml20-idp-remote');
  3. Result: Error: Call to undefined method SimpleSAML\Utils\HTTP::createHttpClient().

Expected behaviour: the metadata is downloaded with Utils\HTTP::fetch(), as in v2.4.11, and the new entityID checks are applied.

Suggested fix (2.4 branch): remove the unused statement:

  •    $client = $this->httpUtils->createHttpClient([                                                                                                                                                                                    
    
  •        'headers' => ['Accept' => 'application/samlmetadata+xml'],                                                                                                                                                                    
    
  •    ]);                                                                                                                                                                                                                               
    

Optionally, use the injected $this->httpUtils for the fetch() call instead of new Utils\HTTP(), so that setHttpUtils() actually affects the download and the code path can be tested.

Workaround until a fix is released: subclass the source (in a module) and, after parent::__construct(), call setHttpUtils() with a Utils\HTTP subclass that defines a no-op createHttpClient(). This restores the 2.4.11 download path and
keeps the entityID checks.

Langage dominant
PHP
Étoiles
1.1k
Forks
704
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de simplesamlphp/simplesamlphp

Toutes les issues de simplesamlphp/simplesamlphp

Issues similaires

Plus d'issues PHP

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.