# Basic Authentication fails with curl using restful\_authentic

**URL:** <https://www.ruby-forum.com/t/basic-authentication-fails-with-curl-using-restful-authentic/114076>\
**Category:** Rails\
**Created:** [September 7, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/basic-authentication-fails-with-curl-using-restful-authentic/114076 "2007-09-07T17:16:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hardbap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/c89c15/32.png) [@Hardbap](https://www.ruby-forum.com/u/Hardbap)\
**Post date:** [September 7, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/basic-authentication-fails-with-curl-using-restful-authentic/114076/1 "2007-09-07T17:16:08Z")

</div>

Rails 1.2.3  
Ruby 1.8.4  
url 7.15.5

I have a simple app that uses the restful\_authentication plugin.  
Authentication works great from the browser but when I try to test  
things via curl I get “Couldn’t authenticate you”.

Here is the curl command I’m using:

curl -v -H ‘Accept: application/xml’ -H ‘Content-Type: application/  
xml’ -b -u username:password -d ‘’ [http://theurl.com](http://theurl.com)

I’ve also tried this:

curl -v -H ‘Accept: application/xml’ -H ‘Content-Type: application/  
xml’ -d ‘’ [http://username:removed\_email\_address@domain.invalid](http://username:removed_email_address@domain.invalid)

The curl command will works fine if I don’t pass the -d switch.

Thanks in advance for the help.

---

<div class="post-metadata">

**Author:** ![Hardbap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/c89c15/32.png) [@Hardbap](https://www.ruby-forum.com/u/Hardbap)\
**Post date:** [September 7, 2007, 5:28pm UTC](https://www.ruby-forum.com/t/basic-authentication-fails-with-curl-using-restful-authentic/114076/2 "2007-09-07T17:28:09Z")

</div>

This is because RESTful Authentication is not an HTTP Authentication  
system.

---

<div class="post-metadata">

**Author:** ![Hardbap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/c89c15/32.png) [@Hardbap](https://www.ruby-forum.com/u/Hardbap)\
**Post date:** [September 7, 2007, 5:57pm UTC](https://www.ruby-forum.com/t/basic-authentication-fails-with-curl-using-restful-authentic/114076/3 "2007-09-07T17:57:12Z")

</div>

Also, the project log states that this has been added:

[http://projects.wh.techno-weenie.net/browser/r2943/plugins/restful\_authentication/generators/authenticated/templates](http://projects.wh.techno-weenie.net/browser/r2943/plugins/restful_authentication/generators/authenticated/templates)

---

<div class="post-metadata">

**Author:** ![Hardbap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/c89c15/32.png) [@Hardbap](https://www.ruby-forum.com/u/Hardbap)\
**Post date:** [September 7, 2007, 5:55pm UTC](https://www.ruby-forum.com/t/basic-authentication-fails-with-curl-using-restful-authentic/114076/4 "2007-09-07T17:55:12Z")

</div>

line 103 of authenticated\_system.rb says to me that it is…

# Called from #current\_user. Now, attempt to login by basic

authentication  
information.  
def login\_from\_basic\_auth  
username, passwd = get\_auth\_data  
self.current\_user = User.authenticate(username, passwd) if  
username &&  
passwd  
end

---

<div class="post-metadata">

**Author:** ![Hardbap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/c89c15/32.png) [@Hardbap](https://www.ruby-forum.com/u/Hardbap)\
**Post date:** [September 7, 2007, 8:16pm UTC](https://www.ruby-forum.com/t/basic-authentication-fails-with-curl-using-restful-authentic/114076/5 "2007-09-07T20:16:31Z")

</div>

The issue only happens in production (Linux/Apache/FCGI). It works  
fine in development (Win XP/Webrick). I’m still investigating and will  
post anything new here.

---

<div class="post-metadata">

**Author:** ![Hardbap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/c89c15/32.png) [@Hardbap](https://www.ruby-forum.com/u/Hardbap)\
**Post date:** [September 7, 2007, 9:54pm UTC](https://www.ruby-forum.com/t/basic-authentication-fails-with-curl-using-restful-authentic/114076/6 "2007-09-07T21:54:41Z")

</div>

It looks like it is an issue with my host. The response.env is missing  
the HTTP\_AUTHENTICATION header. I’m not really sure if this is a  
problem with just my host or all Apache/FastCGI set ups.
