Bypassing authentication for localhost in order to implement search in Etherpad
I'm trying to implement Nutch + Solr based search engine into my Etherpad installation. The main issue I'm having is that Nutch doesn't support POST
authentication. Etherpad and Nutch are installed on the same machine, so an obvious solution would be to find a way to bypass authentication for localhost
.
This is where I'm stuck. I don't know the Etherpad codebase very well, I've mostly done cosmetic tweaks until now.
Can someone point me to where I should be looking, or poten开发者_Go百科tial solutions ? I've found some interesting bits of code having do to with auth in the codebase, but it's Javascript, so there's no obvious way to check if the request host is localhost
.
Edit :
I've found the code that handles the auth policy, and tested it with a simple condition so that it always returns true
. Authentication can then be bypassed. Which leaves me with my initial problem : how can I determine if the host is localhost
in Javascript ?
if (guestPolicy == "allow") {
return;
}
Which leaves me with my initial problem : how can I determine if the host is localhost in Javascript ?
Use the location
API:
if (/localhost/.test(location.hostname) )
References
- MSDN: location Object
精彩评论