Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JumslaMatesane's avatar

Lumen 5.2 authentication

Trying to do a very simple api authentication using lumen 5.2

That is just check the header HTTP_key value to the hardcoded key value in lumen. If correct then process the api else throw an error.

I was able to implement it in php using the below code. I simply am not able to do the same in lumen. I previously used codeigniter only. So kind of new to the framework

public function auth() { if (empty($_SERVER['HTTP_KEY'])) { $_SERVER['HTTP_KEY'] = 0; } if (!($_SERVER['HTTP_KEY'] === $this->key)) { $error = array('status' => 'Error', 'msg' => 'Authentication Failed'); $this->response($this->json($error), 401); } }

0 likes
0 replies

Please or to participate in this conversation.