Enhance JWT Authentication Middleware and Configuration
- Updated the `AuthenticateJWT.php` middleware to conditionally skip IP and User Agent validation based on a new configuration setting, improving flexibility for users with dynamic IPs. - Added a new configuration option `jwt_skip_ip_ua_validation` in `app.php` to control the validation behavior, allowing it to be set via the environment file. - Updated documentation in `environment-variables.mdx` to include the new configuration option, ensuring users are informed about its purpose and usage. These changes enhance the JWT authentication process by providing an option to bypass IP and User Agent validation, improving usability for self-hosted users.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user