PHP code example of scolmore / zerotrust

1. Go to this page and download the library: Download scolmore/zerotrust library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

scolmore / zerotrust example snippets


Route::middleware('zero-trust')->get('/dashboard', function () {
    return view('dashboard');
})->name('dashboard');



namespace App\Http\Middleware;

use Scolmore\ZeroTrust\ZeroTrust;

class ZeroTrustMiddleware extends ZeroTrust
{
    public function completed(bool $success, array $user): void
    {
        // TODO: Add your logging here.
        
        // $success = true if access was granted or false if the user was refused due to restrictions.
        
        // $user is an array of the user's details from the Microsoft graph API.
    }
}

bash
php artisan vendor:publish --provider="Scolmore\ZeroTrust\ZeroTrustServiceProvider"