Open fatihusta opened 2 years ago
So this can 100% be an extension, you would just need to have your directories setup something like this:
- src/
-- Middleware/UsernameToHeader::class
-- extend.php
composer.json
From there you need to change the namespace of your Middleware to be your own and setup the extend.php and use the Middleware extender to add your middleware in the extend.php file.
For an example of adding and using middleware in an extension you can take a look at https://github.com/flarum-tank/middleware/blob/master/extend.php
In your case you need to use both: (new Extend\Middleware('forum'))->add(<classhere>)
and (new Extend\Middleware('api'))->add(<classhere>)
You can read more documentation on this via our docs: https://docs.flarum.org/extend/middleware
Feature Request
Requierment I want to save username to access.log who logged in from the IP address for security purpose.
Solution I saw a solution on the link. https://stackoverflow.com/questions/39475430/how-to-add-laravel-username-to-the-access-log-of-nginx
I staticly tested. And It worked but just at root page(/). I'm not a PHP developer. So please support this feature in flarum.
Sample nginx log
My static test src/Http/Middleware/UsernameToHeader.php (copied from FlarumPromotionHeader.php)
src/Forum/ForumServiceProvider.php
config.php
/etc/nginx/conf.d/logging.conf