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

Aberta Para iniciantes
#2,695 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
php

Direção de pesquisa

Leia src/SimpleSAML/Metadata/Sources/MDQ.php perto de getMetaData() na linha 330 e siga a chamada de download até Utils\HTTP::fetch(). A issue identifica uma chamada não utilizada a createHttpClient() que causa problemas no branch 2.4; remova-a e considere se o utilitário HTTP injetado deve tratar fetch(). O trabalho estará concluído quando uma consulta MDQ sem cache baixar metadados e aplicar as verificações de entityID no 2.4.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
PHP
Estrelas
1.1k
Forks
704
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de simplesamlphp/simplesamlphp

Todas as issues de simplesamlphp/simplesamlphp

Issues semelhantes

Mais issues de PHP

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.