Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AsafAzoulay opened this issue Jul 31, 2019 · 1 comment
Open

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

AsafAzoulay opened this issue Jul 31, 2019 · 1 comment

Comments

@AsafAzoulay
Copy link

No description provided.

@AsafAzoulay AsafAzoulay changed the title HI, i want to use basic auth for a spesific register_rest_route and if i install your plugin it will allow all wp json route and its not good form me. HI, i want to use basic auth for a specific register_rest_route and if i install your plugin it will allow all wp json routes and its not good for me, what i need to do? if i install your plugin it is open all wp json api and i dont want it, i want only my custom json api route... for example if i install your plugin users can get any rest json api url like this: /wp-json/wp/v2/users and i dont want to give access to this url... i want to give access only to /wp-json/rgb/events by register this route (register_rest_route()), what i need to do? Jul 31, 2019
@AsafAzoulay AsafAzoulay changed the title HI, i want to use basic auth for a specific register_rest_route and if i install your plugin it will allow all wp json routes and its not good for me, what i need to do? if i install your plugin it is open all wp json api and i dont want it, i want only my custom json api route... for example if i install your plugin users can get any rest json api url like this: /wp-json/wp/v2/users and i dont want to give access to this url... i want to give access only to /wp-json/rgb/events by register this route (register_rest_route()), what i need to do? how can i do basic auth only for get data Jul 31, 2019
@TheJoshuaEvans
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants