Skip to content

Beautiful Open-Source Form Builder

Enhance JWT Authentication Middleware and Configuration

Julien Nahum6b03808d36a2
diff --git a/api/app/Http/Middleware/AuthenticateJWT.php b/api/app/Http/Middleware/AuthenticateJWT.php
index 820161963..e4da8d31d 100644
--- a/api/app/Http/Middleware/AuthenticateJWT.php
+++ b/api/app/Http/Middleware/AuthenticateJWT.php
@@ -16,6 +16,11 @@ class AuthenticateJWT
*/
public function handle(Request $request, Closure $next)
{
+ // If skipping IP and UA validation is enabled in config, skip the rest
+ if (config('app.jwt_skip_ip_ua_validation')) {
+ return $next($request);
+ }
+
// Parse JWT Payload
try {
$payload = \JWTAuth::parseToken()->getPayload();
diff --git a/api/config/app.php b/api/config/app.php
index dfe4dabaf..e409eb8b7 100644
--- a/api/config/app.php
+++ b/api/config/app.php
@@ -68,6 +68,19 @@ return [
'front_url' => env('FRONT_URL', null),
'front_api_secret' => env('FRONT_API_SECRET', null),
+ /*
+ |--------------------------------------------------------------------------
+ | JWT IP and User Agent Validation
+ |--------------------------------------------------------------------------
+ |
+ | This value determines if the IP and User Agent validation for JWT tokens
+ | should be skipped. This can be useful for self-hosting users with dynamic IPs.
+ | Set this in your ".env" file.
+ |
+ */
+
+ 'jwt_skip_ip_ua_validation' => env('JWT_SKIP_IP_UA_VALIDATION', false),
+
/*
|--------------------------------------------------------------------------
| Application Timezone
diff --git a/docs/configuration/environment-variables.mdx b/docs/configuration/environment-variables.mdx
index 8dff5f89d..9d4b6be8e 100644
--- a/docs/configuration/environment-variables.mdx
+++ b/docs/configuration/environment-variables.mdx
@@ -41,6 +41,7 @@ There are dedicated configuration pages available for more detailed setup instru
| `FRONT_API_SECRET` | Shared secret with the front-end. |
| `TELEGRAM_BOT_ID` | ID of your Telegram bot for notifications. |
| `TELEGRAM_BOT_TOKEN` | Authentication token for your Telegram bot. |
+| `JWT_SKIP_IP_UA_VALIDATION` | Set to `true` to disable JWT IP and User Agent validation (defaults to `false`). Useful for dynamic IPs. |
### User Options Environment Variables