Apache Solr 5.3.1 basic authentication plugin causing issue - apache

I am able to setup the basic authentication plugin using the blog below, for Apache Solr5.3.1, but nothing happens and I am still able to browse through my Solr admin console using firefox without password.
http://lucidworks.com/blog/2015/08/17/securing-solr-basic-auth-permission-rules/
(http)localhost:8501/solr/#/ instead of (http)localhost:8501/solr/admin/
Also when I place the following curl commands I get different results.
curl (http)localhost:8983/solr/admin/authentication
curl (http)localhost:8983/solr/#/authentication
I think I am missing the admin prefix in the console URL but found no way to change it.
Thanks!

After lot of search & debug I finally found out the error.
The curl command was giving an error like message which I overlooked, something like curl: (3) [globbing] nested brace in column 24.
It seems there was some problem in json parsing so I copied and pasted the exact json sample and modified it precisely while keeping the indentation as is and it worked.
curl --user solr:SolrRocks -H 'Content-type:application/json' -d '{
"set-user": {"yepmeasolrupdateuser":"y08klasd"}
}' http://localhost:8983/solr/admin/authentication
Also I found that !! characters in the password field were causing the curl command not to execute properly.
Thanks anyway.

Related

Thruk cgi authentication override

I have the latest version of thruk installed with naemon and livestatus. I want to be able to post commands from a python script to cmd.cgi from the same server without the interference of authentication. I have tried the settings of:
use_authentication=0
default_user_name=thrukadmin
but it doesn't seem to work in the thruk gui. When trying to post to the cgi from the thruk gui I get the error, "I'm sorry Dave......"
Any thoughts on why this not working right? The apache server on that system uses ldap to authenticate to the gui, could this be an issue?
Other thoughts?
It's much easier, you don't even need Thruk in the middle. You can simply write to Naemons command_file.
The external command list at https://www.naemon.org/documentation/developer/externalcommands/ contains an example for every possible command.
Here is a shell snippet which schedules a host downtime:
printf "[%lu] SCHEDULE_HOST_DOWNTIME;host1;1478648441;1478638441;1;0;3600;naemonadmin;This is an example comment.\n" `date +%s` > /var/lib/naemon/naemon.cmd
When using Thruk, you can use thruks cli script to send commands:
thruk r -d comment_data=test /hosts/localhost/cmd/schedule_host_downtime
Authentication is only required if you want to send commands by HTTP.

Failed to login, Forbidden, using hawtio offline war file with ActiveMQ

I'm trying to use hawtio 1.5.2 offline war file as a webapp within ActiveMQ 5.14.5. I have added what I believe are the required entries to ACTIVEMQ_OPTS in $ACTIVEMQ_HOME/bin/env
-Dhawtio.role=admins -Dhawtio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config
and when I go to http://localhost:8161/hawtio I get the login screen, but after using admin/admin and trying to login I get the error Failed to login, forbidden.
I am however able to use the executable JAR for hawtio and connect to my server, so I believe I must be missing something in the ActiveMQ configuration to allow this to work.
I have tried adding log4j.logger.io.hawt=DEBUG to my ActiveMQ's log4j.properties file but I don't seem to get any feedback in the logs from hawtio.
Can anyone help? Thanks
I found my problem. I didn't have this entry in ACTIVEMQ_OPTS in $ACTIVEMQ_HOME/bin/env
-Dhawtio.realm=activemq
Now with my entry reading
ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY \
-Djava.util.logging.config.file=logging.properties \
-Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config \
-Dhawtio.realm=activemq \
-Dhawtio.role=admins \
-Dhawtio.rolePrincipalClasses=org.apache.activemq.jaas.GroupPrincipal"
I'm able to login.

Getting gps coordinates without a gps module

I am working on Raspberry PI B+.
I have to get the current location of the system in python.
Is there a way to do that without using a GPS Module ?
The PI is always connected to the Internet
Take a look at the GeoIP2.
It won't work like a GPS but depending on the purpose, might be useful.
If you have a Wifi network adaptor connected, you can query Google's geocoding API with the access point data to get location.
The following command line will retrieve the location:
sudo iwlist wlan0 scan | sed -E '1s/.*/{"wifiAccessPoints":[/;s/^ *Cell.*: (.*)/{"macAddress":"\1",/;s/^ *Channel:(.*)/"channel":\1,/;s/^.*nal level=(-[0-9]+) .*/"signalStrength":\1},/;/^ /d;$d' | sed '$s/.$/]}/' | curl -d #- -H "Content-Type: application/json" "https://www.googleapis.com/geolocation/v1/geolocate?key=${APIKEY}"
You'll need to set the APIKEY environment variable. You can get an API key from https://developers.google.com/maps/documentation/geocoding/get-api-key.
curl https://ipvigilante.com, this is the best you can do.
I don't know the application, but this is close enough to freak me out.
html5_geolocation_watchposition
Click the button to Try it; Share you location with w3schools.com; Modify the script in the other panel of the webpage to suit.
Edit: Sorry, just noticed the "in Python" but will leave it up.

Testing API with Curl

I'm writing an API with Flask. Testing with a browser works great:
http://stuff.com/login?username=test#test.com&password=testpassword
returns what I expect.
However, I tried typing this into curl two ways (forgive the ignorance, new to LAMP)
curl http://stuff.com/login?username=test#test.com&password=testpassword
curl -i http://stuff.com/login?username=test#test.com&password=testpassword
Unfortunately, the variables in the query aren't making it to the server, as my error message is similar to passing:
http://stuff.com/login?username=
Help?
I believe the reason is because your shell is evaluating the GET arguments you are using, instead of passing them on as a string. To prevent this, use single quotes around the request url. For example:
curl 'http://stuff.com/login?username=test#test.com&password=testpassword'

JMeter File Upload with HTTP Put Method Not Working

The idea is to build a sampler in JMeter that will upload a file using the HTTP PUT method. I'm trying to follow the official documentation to specify the entire content body as a file with no parameter name.
What should happen: The file gets uploaded and the server returns 201: created
What actually happens:
java.lang.NullPointerException: charsetName
at java.lang.String.<init>(Unknown Source)
at java.lang.String.<init>(Unknown Source)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sendPutData(HTTPHC4Impl.java:1067)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:274)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1054)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1043)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:416)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:271)
at java.lang.Thread.run(Unknown Source)
This seems to indicate that JMeter has a problem with filling out the body of a request. I can get rid of this error by specifying a parameter with the request, but I want the entire body to be the photo data. Here's the CURL line of what I want accomplished:
curl -u testuser:testpass "http://localhost:8080/photo" -T photo.jpg -H "content-type:image/jpeg"
I've tried setting the content-encoding to UTF-8 as I've seen in one post, but that changed nothing.
I'm running Java 1.7.0 on Windows 7 x64. Nothing of interest gets generated in jmeter.log, and wireshark tells me that JMeter isn't sending the request.
Any ideas? Thanks in advance.
Turns out it was a bug that the nice folks at JMeter were able to fix very quickly: https://issues.apache.org/bugzilla/show_bug.cgi?id=52897
Using the nightly build solved my problem, and by now it has probably made it into the release.
Use Raw HTTP Request to accomplish this. You may specify headers in Request Data and also specify file containing PUT body for convinience.
Some details may be found here
I was having issues with image uploads and found the answers here https://stackoverflow.com/a/2115944/455363.
After making the suggested changes here I had to re-record the transaction and make my edits and I was successfully able to upload files.
Hope this helps.