You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My static test
src/Http/Middleware/UsernameToHeader.php (copied from FlarumPromotionHeader.php)
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Http\Middleware;
use Flarum\Foundation\Config;
use Illuminate\Support\Arr;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface as Middleware;
use Psr\Http\Server\RequestHandlerInterface;
class UsernameToHeader implements Middleware
{
protected $enabled = true;
public function __construct(Config $config)
{
$this->enabled = Arr::get($config, 'headers.usernameToHeader') ?? true;
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
if ($this->enabled) {
$response = $response->withAddedHeader('X-Username', 'Flarum');
}
return $response;
}
}
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.
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
The text was updated successfully, but these errors were encountered: