Skip to content

A free open source IT asset/license management system

Optionally log the user’s ID in the header

snipe5d75765aaedd
diff --git a/app/Http/Middleware/SecurityHeaders.php b/app/Http/Middleware/SecurityHeaders.php
index 767d7fc1aa..5d5440dfac 100644
--- a/app/Http/Middleware/SecurityHeaders.php
+++ b/app/Http/Middleware/SecurityHeaders.php
@@ -69,6 +69,11 @@ class SecurityHeaders
$response->headers->set('X-Frame-Options', 'DENY');
}
+ if (config('app.authorized_user_header') === true) {
+ $response->headers->set('X-Authorized-User-ID', auth()?->id());
+ }
+
+
// This defaults to false to maintain backwards compatibility for
// people who are not running Snipe-IT over TLS (shame, shame, shame!)
// Seriously though, please run Snipe-IT over TLS. Let's Encrypt is free.
diff --git a/config/app.php b/config/app.php
index 131c61cf0b..81e74bafe9 100755
--- a/config/app.php
+++ b/config/app.php
@@ -233,6 +233,22 @@ return [
'allow_iframing' => env('ALLOW_IFRAMING', false),
+
+ /*
+ |--------------------------------------------------------------------------
+ | LOG AUTHED USER HEADER
+ |--------------------------------------------------------------------------
+ |
+ | This is an additional header that can be enabled to include the authenticated user's ID
+ | in the response headers of each request. This can be useful for debugging and auditing purposes,
+ | but it may also expose sensitive information if not used carefully.
+ | It should normally be set to false unless you have a specific need for it and
+ | understand the security implications.
+ |
+ */
+
+ 'authorized_user_header' => env('INCLUDE_AUTHED_USER_HEADER', false),
+
/*
|--------------------------------------------------------------------------
| ENABLE HTTP Strict Transport Security (HSTS)