php-crud-api icon indicating copy to clipboard operation
php-crud-api copied to clipboard

Adding Auth using login.html issue

Open ruraldev opened this issue 8 years ago • 3 comments

I have the api.php (V1) working until I attempt to add authorisation, all I get is the token displayed on the screen but I can't seem to see why?

Just in case there is an easier way to do it all I am trying to do is setup an API which allows me to retrieve data from a mysql database table, but obviously I don't want the public to be able to make changes to the data etc.

Hope someone can help with a working example.

Thanks

ruraldev avatar Aug 13 '18 08:08 ruraldev

This depends on what you want to achieve. If you just want to perform read-only operations, you could simply set the api to read-only so that no changes can be made without direct access to the database. For a simple protection via basic auth you could try the following: https://github.com/mevdschee/php-api-auth/issues/21

mycaravam avatar Aug 14 '18 07:08 mycaravam

Thanks for the suggestion, it worked fine and for my limited needs it'll do the job.

ruraldev avatar Aug 14 '18 17:08 ruraldev

@mevdschee : Looks like a very cool application, which works fine for me without authorization. Once i turn on basic auth it seems to not pick up the htpasswd file. (access is rejected with 401)
I must say i am completly new to API usage and may have some configuration wrong as well. Can you therefore give me some examples how the API.php must look like (incl. paths) for a virtual host setup? (eg. absolute paths?)

Many thanks

piatho avatar Jul 30 '20 08:07 piatho