PHP

Support group for those afflicted with PHP. Don't ask to ask, ...
Jul 19, 2021 02:01
Generally speaking that is.
Jul 19, 2021 02:00
@ZahidSaeed I would put the code for decoding the JWT inside the lambda function. There won't usually be many illegal requests anyway. 99.99 percent of requests should be legitimate, so the cost reduction will be tiny and the complexity may be high.
Jul 19, 2021 01:37
(instead of foobar) which would be the result without register_shutdown_function
Jul 19, 2021 01:36
@Tiffany yeah, i will come back. It is quite cool to see PHP run code like "setTimeout(function() { echo "foo";}, 500); echo "bar" ; and see barfoo appear. :)
Jul 19, 2021 01:33
@ZahidSaeed yeah, aws is quite overwhelming. If you have one API gateway, I assume you must write some code in your API. It seems to me that Cognito creates a JWT, and that tokens will contain information about which groups a user is assigned to. The API will receive the JWT on every request, so you should decode the token and then you can simply check if the user is member of the required group.
Jul 19, 2021 01:18
@ZahidSaeed seems to me that if you have two api gateways (one for each api), then you can bind groups to IAM roles. Next you grant privileges on the api gateway to the corresponding IAM role.
Jul 19, 2021 01:09
Turns out PHP has "always" been an asynchronous language. The "register_shutdown_function" seems to do exactly what the "setImmediate" function does in node.js, which is all you need to implement other event loop functions such as "setTimeout" and "setInterval". Any reasons we shouldn't use "register_shutdown_function" for this?