0

I have a web application made in laravel with vue for a physical security company but we need to block access to this application when some users try to access from personal devices, we need to grant access just for company devices. Is there any strategy?

Thanks

Martijn Pieters
  • 889,049
  • 245
  • 3,507
  • 2,997
Sergio Ríos
  • 41
  • 1
  • 3
  • There are various strategies, of various levels of complexity and security. Permitting a specific set of IPs is probably your easiest bet. – ceejayoz Feb 13 '20 at 15:57
  • @ceejayoz only if you know that the staff doesn't have access to network from their personal devices. – Ersin Demirtas Feb 13 '20 at 16:06
  • There are some solutions with users mac address but the whole company will have to use IE here is a solution https://stackoverflow.com/questions/3385/mac-addresses-in-javascript. This means you will need all mac addresses of the company computers that you want to give access. – Ersin Demirtas Feb 13 '20 at 16:11

1 Answers1

0

The most common solution to this is to restrict access to devices on your own network. This is a good case for using a middleware to make sure that the IP requesting access is one of the IPs on your corporate network:

<?php

namespace App\Http\Middleware;

use Closure;

class CorporateIP
{

    public function handle($request, Closure $next)
    {

        $valid_addresses = ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'];

        if (!in_array($request->ip(), $valid_addresses)) {
            abort(403);
        }

        return $next($request);
    }
}

If you want to protect all routes, just register this class as a global middleware on your app/Http/Kernel.php.

dr_ermio
  • 644
  • 1
  • 5
  • 19