Swagger UI getCSPNonce() method error when using nelmio/security-bundle
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
The error originates in SwaggerUiProcessor.php line 62, where a static call is made to a non-static method getCSPNonce() from Nelmio\SecurityBundle\Twig\CSPRuntime. Examine the resolveCspNonce method and the surrounding code to understand how the nonce is retrieved. Check the nelmio/security-bundle documentation for the correct way to obtain the nonce, and see if API Platform needs to adapt its integration. Verify the fix by reproducing the issue with the bundle installed and visiting the Swagger UI endpoint.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
API Platform version(s) affected: v5.0.0
Description
I posted about this also on #8310 but unsure if that will be seen: When using API Platform v5.0.0 with nelmio/security-bundle v3.9.0 we get the following error when visiting the Swagger UI:
{
"@context": "/api/contexts/Error",
"@id": "/api/errors/500",
"@type": "Error",
"title": "An error occurred",
"detail": "Non-static method Nelmio\\SecurityBundle\\Twig\\CSPRuntime::getCSPNonce() cannot be called statically",
"status": 500,
"type": "/errors/500",
"description": "Non-static method Nelmio\\SecurityBundle\\Twig\\CSPRuntime::getCSPNonce() cannot be called statically",
"trace": [
{
"file": "/var/www/html/vendor/api-platform/symfony/Bundle/SwaggerUi/SwaggerUiProcessor.php",
"line": 62,
"function": "resolveCspNonce",
"class": "ApiPlatform\\Symfony\\Bundle\\SwaggerUi\\SwaggerUiProcessor",
"type": "->"
},
{
"file": "/var/www/html/vendor/api-platform/state/CallableProcessor.php",
"line": 52,
"function": "process",
"class": "ApiPlatform\\Symfony\\Bundle\\SwaggerUi\\SwaggerUiProcessor",
"type": "->"
},
{
"file": "/var/www/html/vendor/api-platform/state/Processor/WriteProcessor.php",
"line": 58,
"function": "process",
"class": "ApiPlatform\\State\\CallableProcessor",
"type": "->"
},
{
"file": "/var/www/html/vendor/api-platform/symfony/Validator/State/ValidateProcessor.php",
"line": 44,
"function": "process",
"class": "ApiPlatform\\State\\Processor\\WriteProcessor",
"type": "->"
},
{
"file": "/var/www/html/vendor/api-platform/symfony/Action/EntrypointAction.php",
"line": 61,
"function": "process",
"class": "ApiPlatform\\Symfony\\Validator\\State\\ValidateProcessor",
"type": "->"
},
{
"file": "/var/www/html/vendor/symfony/http-kernel/HttpKernel.php",
"line": 188,
"function": "__invoke",
"class": "ApiPlatform\\Symfony\\Action\\EntrypointAction",
"type": "->"
},
{
"file": "/var/www/html/vendor/symfony/http-kernel/HttpKernel.php",
"line": 79,
"function": "handleRaw",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "->"
},
{
"file": "/var/www/html/vendor/symfony/http-kernel/Kernel.php",
"line": 143,
"function": "handle",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "->"
},
{
"file": "/var/www/html/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php",
"line": 34,
"function": "handle",
"class": "Symfony\\Component\\HttpKernel\\Kernel",
"type": "->"
},
{
"file": "/var/www/html/vendor/autoload_runtime.php",
"line": 32,
"function": "run",
"class": "Symfony\\Component\\Runtime\\Runner\\Symfony\\HttpKernelRunner",
"type": "->"
},
{
"file": "/var/www/html/public/index.php",
"line": 7,
"function": "require_once"
}
]
}
This issue seems to have been fixed for the API Platform v5.0.0 release when not using nelmio/security-bundle based on the PR description, since a similar error is produced. However, when requiring nelmio/security-bundle we get the afforementioned error.
How to reproduce
- composer require nelmio/security-bundle
- Create a route with API Platform
- Visit url.example.com/api
Possible Solution
At the moment using a custom decorator that gets the nonce using the nelmio/security-bundle functions seems to work but that is just a workaround and not an official solution.
- Lenguaje dominante
- PHP
- Estrellas
- 2.6k
- Forks
- 987
- Merge medio
- 1 d 7 h
- PR fusionados (30 d)
- 84
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de api-platform/core
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
api-platform/core#8660 ·
Los mantenedores suelen responder en 1 día
-
DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
api-platform/core#8650 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
api-platform/core#8649 ·
Los mantenedores suelen responder en 1 día
-
`OrderExtension` and `OrderFilter` pass string sort directions, deprecated since `doctrine/orm` 3.7Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
api-platform/core#8648 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
api-platform/core#8647 ·
Los mantenedores suelen responder en 1 día
Todos los issues de api-platform/core
Issues similares
-
Python 3.15 supportPosiblemente ocupada @amnesiaof la tomó hoy. AbiertoL: python L: python:uv
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dependabot/dependabot-core#16524 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
crazy-goat/rabbit-stream#830 ·
Los mantenedores suelen responder en 1 día
-
sync-en
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
sync-en
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 4 días
-
Перевод устарел
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100