I’ve been using Laravel Middleware for checking a certain user has been authenticated with the Uni’s SSO.
As a rule, anyone darkening our servers HAS to be a Warwick University Student and so, should be Auth’d by Shibboleth to the Uni’s Single Sign On.
The Laravel docs suggest that for “Global Middleware” you should put it in the app/Http/Kernel.php
class and it will run on everything,
If you want a middleware to be run during every HTTP request to your application, simply list the middleware class in the $middleware property of your app/Http/Kernel.php class.
http://laravel.com/docs/5.0/middleware#registering-middleware
However, whilst that’s fine there is a good argument for putting it in the routes.php
file, so it’s clear to any non-laravellers what Middleware is protecting the routes.
Route::group(['middleware' => ['IsUniSSOd']], function()
To be honest either’s fine. I started using the Route::group protection initially, however, it indents everything and starts to make it look a bit like a horrific massive if statement from days of old.
So now we’re putting it in our Kernel.php
file to smarten it up as everyone gets more used to Laravel.
protected $middleware = [
...
'AppHttpMiddlewareIsUniSSOdMiddleware'
]