alfred-nutile-inc/quick-auth

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (dev-master) of this package.

dev-master 2014-10-23 12:40 UTC

This package is not auto-updated.

Last update: 2018-05-08 20:36:00 UTC


README

For angular routes that are in the router.php file

October 12

notes on getting auth setup again http://www.alfrednutile.info/posts/109

Until the docs for Laravel 5 are updated I am not sure right now to do auth filters in the routes.php file which is fine since now most routes are handled in the controllers via annotations.

But for those routes that angular is taking over and not needing a controller it might be easy to use this.

This also centralizes some logic to deal with CI so we can easily the the environment as needed.

$router->get('/', function(){
    if($results = QuickAuthFacade::check())
        return $results;
    return Redirect::to('/behat');
});

Also I set my middleware file for this

#app/Http/Middleware/AuthMiddleware.php
<?php namespace BehatEditor\Http\Middleware;

use AlfredNutileInc\QuickAuth\QuickAuthFacade;
use Closure;
use Illuminate\Routing\Route;
use Illuminate\Contracts\Auth\Authenticator;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Contracts\Routing\ResponseFactory;

class AuthMiddleware implements Middleware {

    /**
     * The authenticator implementation.
     *
     * @var Authenticator
     */
    protected $auth;

    /**
     * The response factory implementation.
     *
     * @var ResponseFactory
     */
    protected $response;

    /**
     * Create a new filter instance.
     *
     * @param  Authenticator  $auth
     * @param  ResponseFactory  $response
     * @return void
     */
    public function __construct(Authenticator $auth,
                                ResponseFactory $response)
    {
        $this->auth = $auth;
        $this->response = $response;
    }

    /**
     * Handle an incoming request.
     *
     * @param  \Symfony\Component\HttpFoundation\Request  $request
     * @param  \Closure  $next
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function handle($request, Closure $next)
    {
        if($results = QuickAuthFacade::check())
            return $results;

        return $next($request);
    }

}

But this will not work if you do not register your middleware

#app/Providers/AppServiceProvider.php

Under protected $middleware I change them as needed to the apps namespace etc App for Foo what ever you have called it. Otherwise you will still be pulling in the default middleware.

Of course you can just move your angular routes to an quick controller to pass logic in there.

Make sure to include this in your config/app.php provider list as

'AlfredNutileInc\QuickAuth\QuickAuthServiceProvider',

And set in there your facade array to

'QuickAuth' => 'AlfredNutileInc\QuickAuth\QuickAuthFacade',

Composer install

see https://packagist.org/packages/alfred-nutile-inc/quick-auth for the require info needed