If you run that curl command with -I and/or -v, you'll see that curl is 
actually sending two different requests.  The first obtains the realm and 
nonce, the second uses those values, along with the username and password, to 
hash the authentication header.  Your JS client must do the same.  Here's what 
the response headers (using -I, not -v) in the digest dance look like:

$ curl -I -H "X-REQUESTED-AUTH: Digest" --digest --user 
"matterhorn_system_account:CHANGE_ME" http://localhost:8080/welcome.html
HTTP/1.1 401 Full authentication is required to access this resource
WWW-Authenticate: Digest realm="Opencast Matterhorn", qop="auth", 
nonce="MTMwNjkzNDc1ODU3MjpjN2IwMTNmMTViNjlhYWQ2NmMxYWQ5NmRmZDY3ZjMzMg=="
Content-Type: text/html; charset=iso-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1469
Server: Jetty(6.1.x)

HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 6015
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: JSESSIONID=14krgt18n5lwd;Path=/
ETag: 27d2f494164d574f677693f0cb0c4975
Server: Jetty(6.1.x)

Alternatively, if you can secure the cryptographic keys (i.e. you're doing 
server-side JS, not in a browser), you can use 2-legged OAuth instead.  This 
should be much easier in javascript.   There were several HMAC implementations 
in javascript the last time I checked.  Currently Matterhorn has only a 
proof-of-concept OAuth filter with hard-coded keys (see 
OAuthSingleConsumerDetailsService), but this would be easy to change to use a 
database of OAuth consumer keys and secrets.

Josh


On Jun 1, 2011, at 3:43 AM, Lovemore Nalube wrote:

> Hi Everyone
>  
> I am trying to configure my Air app to authenticate to a Capture Agent using 
> Adobe Air Javascript plugins. The authentication headers I have tried so fare 
> are not working. Can somebody nudge me in the right direction?
>  
> I need to have the Javascript equivalent of this Curl based line:
>  
> curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-Auth: Digest"));
>  
> So far this is the format of the Javascript header setter (which does not 
> work with those parameters):
>  
> var hash = $.base64.encode("admin:opencast");
> request.requestHeaders = [new air.URLRequestHeader('X-REQUESTED-AUTH', 
> 'Digest auth=' + hash)];
>  
> How can i properly set the auth parameters and headers?
>  
> Thanks
>  
>  
> --
> Lovemore Nalube
> OLE Developer (Vula)
> University of Cape Town
> http://www.cet.uct.ac.za/LovemoreN
> 
> 
> ###
> 
> UNIVERSITY OF CAPE TOWN
> 
> 
> This e-mail is subject to the UCT ICT policies and e-mail disclaimer 
> published on our website at 
> http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 
> 21 650 9111. This e-mail is intended only for the person(s) to whom it is 
> addressed. If the e-mail has reached you in error, please notify the author. 
> If you are not the intended recipient of the e-mail you may not use, 
> disclose, copy, redirect or print the content. If this e-mail is not related 
> to the business of UCT it is sent by the sender in the sender's individual 
> capacity.
> 
> 
> ### 
> _______________________________________________
> Matterhorn mailing list
> [email protected]
> http://lists.opencastproject.org/mailman/listinfo/matterhorn
> 
> 
> To unsubscribe please email
> [email protected]
> _______________________________________________

_______________________________________________
Matterhorn mailing list
[email protected]
http://lists.opencastproject.org/mailman/listinfo/matterhorn


To unsubscribe please email
[email protected]
_______________________________________________

Reply via email to