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
Post a Comment