rails recaptcha on localhost? windows causing issues? - ruby-on-rails

I just checked out this answer: Rails Recaptcha plugin always returns false
but it didn't seem to help. I'm trying to run recaptcha on rails on my local machine. The site says the API keys should work for prod and local. I've checked the keys many times and have even tried "workarounds" where you explicitly feed in the pub/priv key (since I'm running on windows). I just wanted to know if there's a known issue with windows, or if there's an issue with running on localhost, or if this plugin is out of date? Thanks.
I'm always getting the error that my captcha is wrong. I even tried the sound type, still wrong. Apologies if this is just a silly question, I just wanted to rule out everything that may be a known issue.

When getting an API key for ReCaptcha a domain must be specified. localhost won't work but your hostname should. As the recaptcha site says:
By default, your reCAPTCHA key is restricted to the specified domain, and any subdomains for additional security
Find out your hostname at the following link and use it as the domain for you API keys:
http://whatismyipaddress.com/staticpages/index.php/what-is-my-hostname
My provider happens to be Comcast, so I created a global API key for comcast.net
https://admin.recaptcha.net/recaptcha/createsite/

Related

How to get SSL working on Rails app with Heroku?

I am trying to get SSL working on my Rails app that I am deploying with Heroku.
I have used the automated certificate management from Heroku and followed the directions, but when I visit my site I still see a “Not Secure” label in the URL bar. I am trying to figure out how to address this.
My site is at http://give.toacause.com/. When I use inspect in the chrome browser and go to Security, I read that the certificate is missing. However, when I click “view certificate”, I see a notice that “This certificate is valid.”
What step am I missing here?
It appears as though the CNAME record for give.toacause.com is mysterious-bastion-66058.herokuapp.com
You need to use *.herokudns.com.
heroku domains will output something like
Domain Name DNS Record Type DNS Target
give.toacause.com CNAME give.toacause.com.herokudns.com
You need to set the CNAME to the value of the DNS target field. After you do, make sure you flush your DNS cache so you can resolve and check it again, or use one of the many HTTPS checkers on the internet.

net_ssh on production returns 'Authentication Failed' using public keys

I am trying to execute couple of commands on remote server and as authentication method, I am using public keys.
Public keys are configured properly on server and I can connect to it without system prompting me for password like this:
ssh root#example.com
So this is what I do in my code:
Net::SSH.start(host, user, :keys=>["~/.ssh/id_rsa","~/.ssh/id_rsa.pub"]) do |ssh|
ssh.exec "service nginx reload"
end
On local machine, everything works properly, when on production server, I get an error.
Net::SSH::AuthenticationFailed: Authentication failed for user root#example.com
I did some Googling and I had already tried to fallback to net_ssh 2.7.0, yet no luck, same issue. I also tried to replace relative path to absolute, in my case /root/.ssh/...
I tried adding an option
:auth_methods => ['publickey']
yet still, no luck.
I am also certain that the keys reside in correct paths.
EDIT 1
Worth noting that this works perfectly well when run in production rails console.
EDIT 2
Symptoms here are similar with ones in this question: Net::SSH works from production rails console, AuthenticationFailed from production webapp
with exception that my app runs from root and there shouldn't be permission issues because of that.
EDIT 3
I had temporary fallen back to password auth that works fine but I'd really like to use key auth instead.
Any help on this issue is much appreciated.

DirContextOperations is null

So I have an application that works perfectly on my desktop, and also works perfectly when deployed to tomcat on a windows machine. However, when I attempt to use this application while deployed on the same version of tomcat, but on AIX, it fails to retrieve data out of LDAP.
A user is able to successfully authenticate, but the context is null. DirContextOperations is passed into my ContextMapper as null. Does anyone know what ports that need to be open to get this data or what other configuration may need to be done? Based on what I am seeing it has to be a server configuration issue somewhere.
If you are using Spring Security LDAP plugin then it will be easy to co-relate the below mentioned configuration in AIX with the app. I prepared few snapshots for the configuration so that I do not clutter the answer space here. Have a look at LDAP config in AIX and try to setup the same in AIX Server.
Now coming to the LDAP plugin, there is nothing much other than setting up a bunch of properties is required. Values for these properties will be available once the LDAP configuration is done in AIX (as mentioned in the above mentioned slide).
Note:-
After creating a standalone LDAP, you might need to add realm if the user is associated to a group. I have not mentioned the same in the slides since I do not have an active LDAP host available now.
UPDATE
Instead of using BindAuthenticator can you try switching to PasswordComparisonAuthenticator for authentication.
Using the below setting in Config forces to use PasswordComparisonAuthenticator to authenticate and return back the DirContextOperations. Can this setting be tried?
grails.plugins.springsecurity.ldap.authenticator.useBind = false
#Refer LdapAuthentication Implementations.
I am not sure if this will be the answer in your case. I was also getting null in DirContextOperations object when trying to obtain values from Active Directory.
I was trying to get ldap attributes like this as the Grails LDAP plugin Documentation states:
String mail = ctx.originalAttrs.attrs['mail'].values[0]
and all those were null. So I have changed the line above for this one instead and it works for me:
String mail = ctx.attributes.getAt('mail').values[0].toString()

Recaptcha error

I have a problem with Recaptcha gem. I'm using Ubuntu on a virtual machine (VirtualBox). It uses bridged network interface card, so I have internet access there and I can see this Ubuntu from my host computer.
When I run rails s and than go to
127.0.0.1:3000 on virtual machine everything is fine.
192.168.0.103:3000 on host machine there is an error with recaptcha box.
Input error: Invalid referer is where the box is supposed to be.
Why is it like that and how to fix this?
But, when we tried to host the same application to any server with the same pair of keys, it will not generate an error but, it will display like "input error - invalid referer" instead of captcha in your form.
Because, when we are getting the pair of keys from Google API, we will specify the domain name there. In that, to use those keys in your local system, we will enter domain as "localhost". But, these pair of keys will not work when we deploy that application in any server.
So, for the application to work in the remote host, we should get the pair of keys from Google API with the domain name, where we are going to deploy your application. And use them in your application.
Note:
We can have a new pair of keys for recaptcha using following link:
http://www.google.com/recaptcha/whyrecaptcha

DNS issue with Azure - gives error when using DNS

I am facing a strange issue with azure -
After uploading a new version of my app about an hour back, the public facing url is throwing a runtime error. However the app works fine when I access it through the azure internal domain -- app.cloudapp.net.
Before upgrading it was working fine.
I have rechecked the cname records with my hosting provider (bluehost) but I cannot find any problem. Even otherwise, the problem seems like an ASP.net issue (due to the typical error page rendered) but something that just does not make sense.
Anyone has any ideas as to what I can do?
EDIT: This started working just as mysteriously as it had stopped - I have no clue whether it is due to DNS propagation delay (although in that case it should not have thrown an error page like described above). However if someone knows why this might happen, I will still appreciate it.
There is a DNS service available for Windows Azure called "DNS Azure" that changes your cloudapp's IP address automatically. See dnsazure.com
This solutions helps to avoid the CNAME record because the A record is kept up-to-date.

Resources