steampixel / simplePHPRouter

This is a simple and small single class PHP router that can handel the whole url routing for your project.
MIT License
406 stars 117 forks source link

how to add basic authenticator? #36

Closed lsjack93 closed 3 years ago

lsjack93 commented 3 years ago

Hello, I am trying to implement basic authentication, but without success yet. Have you planned something similar?

steampixel commented 3 years ago

Hi @lsjack93,

basic auth is not part of the router. This is an extra topic. I will not plan to add this to the router because this is has nothing to do with basic routing. You can use PHP to add basic auth before the routers run() method is called or you can add those logic inside single routes. Examples can be found here: https://www.php.net/manual/de/features.http-auth.php

If you are on Apache you can also use .htaccess basic auth to protect the whole app: https://homepage-kosten.de/htaccess/