php - laravel5.1 basic http auth for API -


i'm working on web based api. don't need overloaded feature of laravel use table storing login details of http auth. protect 1 function (so middleware overloaded too) using hardcoded username & password http auth.

all found @ moment doesn't work, isn't there simple code example how so? found in tutorials using users table, api overloaded, since need 1 account hardcode controller.

pass username & password in headers every call, , check hardcoded credentials in controller's constructor.

example:

use use illuminate\http\request;  class mycontroller extends controller {   public function __construct(request $request)   {     parent::__construct();      $username = $request->header('username');     $password = $request->header('password');     if($username !== 'your hardcoded username' || $password !== 'hardcoded password') {       throw new \exception;     }   } } 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -