Comments (6)
I did found the issue ... it turned out that when using swoole this stuff
public function __construct(RequestStack $requestStack)
{
$this->request = $requestStack->getCurrentRequest();
}
...
should be avoided at all cost. This object is saved in memory along with the first request!
instead doing this
public function __construct(RequestStack $requestStack)
{
$this->request = $requestStack;
}
public function getPayload()
{
list($header, $payload, $signature) = explode(".", $this->request->getMasterRequest()->headers->get('Authorization'));
return JWT::jsonDecode(JWT::urlsafeB64Decode($payload));
}
is safe! And everything works as expected.
Nothing to do with the bundle I guess, but to the very nature of how swoole works. Retrieving the request in an object constructor is an unsafe operation here.
Feel free to close the issue.
from swoole-bundle.
Thanks man for the update, sorry for not being able to debug it myself but (as usual) did not have time to do it :/
Happy that you've managed to resolve it by yourself, good job man!
Edit: And yes, with swoole on each request memory isn't flushed (and symfony container isn't reconstructed) so we need to keep track of global state and take care memory-related issues, that's why it's so fast.
from swoole-bundle.
Thanks man for the update, sorry for not being able to debug it myself but (as usual) did not have time to do it :/
Happy that you've managed to resolve it by yourself, good job man!
no prob! thank you for the good work on the bundle :)
from swoole-bundle.
Hi, unfortunately I don't know what could be the cause, if you can please provide simple repository so I can reproduce bug locally. Then I'll try to debug and see what can be done here. Maybe session support needs some adjustments. Also, this bundle does not support php 7.3 anymore.
from swoole-bundle.
Hi, unfortunately I don't know what could be the cause, if you can please provide simple repository so I can reproduce bug locally. Then I'll try to debug and see what can be done here. Maybe session support needs some adjustments. Also, this bundle does not support php 7.3 anymore.
Thank you, sure I'll try my best to find the time to put together an example repo.
I am using version 0.8.3 to work with php 7.3.
Meanwhile l am still trying to debug and it seems that is like the authorization headers are "cached" between different requests.
The way I am grabbing header information in my custom user provider is via a class like this:
use Firebase\JWT\JWT;
use Symfony\Component\HttpFoundation\RequestStack;
class JwtPayloadGetter
{
private $request;
public function __construct(RequestStack $requestStack)
{
$this->request = $requestStack->getCurrentRequest();
}
public function getPayload()
{
list($header, $payload, $signature) = explode(".", $this->request->headers->get('Authorization'));
return JWT::jsonDecode(JWT::urlsafeB64Decode($payload));
}
}
Debugging this it seems that $this->request->headers->get('Authorization')
doesn't change between requests even if I do change the value in my postman client.
maybe something linked to https://symfony.com/doc/current/http_cache.html#http-caching-and-user-sessions but with php'fpm I don't have the same problem, so I am thinking that is mainly linked to swoole
from swoole-bundle.
Still haven't got the time to create a sample repo for you, but I did some more digging today: it seems to me that working with a class like the one I showed above produces always the same result! So $this->request->headers->get('Authorization')
gives me always the same value, the one I sent in the first request after I started the server (as if the content of the headers are saved in memory after the first request).
Could you confirm that this shouldn't be the case and the bundle is exactly for this purpose ?
Have you ever tried yourself using the bundle with authorisation, security or user login features in Symfony ?
from swoole-bundle.
Related Issues (20)
- [ASK] Is possible to support PHP 7.2.X HOT 1
- Introduce rectorphp / rector in CI Pipeline
- hot reload not work HOT 1
- docs: Update README.md
- Symfony (http foundation) request->getRequestUri() doesn't contain query string HOT 4
- The bundle seems (too) dependent to Doctrine ORM
- Fix CI: release-version script
- Introduce Infection in CI Pipeline
- Your work is a millennium job LOL HOT 2
- Unable to upgrade to v0.8.3 on PHP 8.0 due to assertion BC break HOT 4
- http response is unavailable HOT 1
- Different Voter Result HOT 2
- Lots of timeout when fetching items from database using doctrine HOT 4
- when require ODM
- Use cooperative scheduling in request handling by enabling swoole coroutine hooks for IO functions HOT 2
- Add setting for task_enable_coroutine
- pid_file config does not work
- Some error's do not log.
- Reload does not work with opcache_enabled_cli
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swoole-bundle.