WP-API / Basic-Auth

Basic Authentication handler for the JSON API, used for development and debugging purposes
761 stars 281 forks source link

how can i do basic auth only for get data #62

Open AsafAzoulay opened 5 years ago

TheJoshuaEvans commented 5 years ago

I actually was able to solve this issue in my fork of the project: https://github.com/Trifoia/Basic-Auth/blob/master/basic-auth.php#L14-L23

I check for the endpoint using the $_SERVER['REQUEST_URI'] global variable and then abort authentication if the endpoint doesn't match one that I specifically whitelisted. This isn't guaranteed to work in every case - since some previous operation could change the value of that variable - but it works good enough for my use-case. I also added some brute force protections to further improve security