[chef] Re: Re: Re: Re: Re: Re: Can i authenticate myself as an admin using the RESTful API (in java code)?


Chronological Thread 
  • From: Dikang Gu < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Re: Re: Can i authenticate myself as an admin using the RESTful API (in java code)?
  • Date: Tue, 20 Oct 2009 13:10:35 +0800
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=hF1wTVZo6ufK/+BIeY1FBDo2Lc7gKF7cxoS0bYuhw36Ek3JbObXFVyugmaBjw+wISr NRs9StycMf0CTgazzgBS51kdFrv8J8ifw6Guh+aH8FzyWOp2xeQHbojwAvyzIC/Wcn5t sB+h3MBxDwK6kHtCsLhGVciI1/khyAoHjsYRc=

Hi Arjuna,

I've solved this issue, by fixing a cookie bug!

Thanks very much for your help!

Thanks
Dikang

On Tue, Oct 20, 2009 at 12:40 PM, Arjuna Christensen < "> > wrote:
Hello,

On 20/10/2009, at 5:08 PM, Dikang Gu wrote:

Hi Arjuna,

Thank you for your information!

Yes, I have converted the ruby authenticate code to java, and used the cookie in subsequent calls to Chef Server, but I still have the 401 error. I attach some of the debug log, could you help me to talk a look at it, please?

Thanks
Dikang


{snip}

Can you please post the chef-server logs in debug mode (-l debug or log_level :debug in server.rb) showing the auth/authz failure :)

The default location is /var/log/chef/server.log



On Tue, Oct 20, 2009 at 11:54 AM, Arjuna Christensen < " target="_blank"> > wrote:
Hi,

On 20/10/2009, at 4:37 PM, Dikang Gu wrote:

please refer to my mail: "A problem when implementing the java client of chef".

As per the Knife snippet, Chef::Rest#authenticate is called - http://github.com/opscode/chef/blob/master/chef/lib/chef/rest.rb#L65-76

    def authenticate(user, pass)
      Chef::Log.debug("Authenticating #{user} via openid")
      response = post_rest('openid/consumer/start', {
        "openid_identifier" => "#{Chef::Config[:openid_url]}/openid/server/node/#{user}",
        "submit" => "Verify"
      })
      post_rest(
        "#{Chef::Config[:openid_url]}#{response["action"]}",
        { "password" => pass }
      )
    end
Shouldn't be too hard to port that over to Java. You'll need to persist and use the cookie in subsequent authentication-required calls to the Chef Server [handled internally by Chef::Rest for the ruby client].

HTH!


On Tue, Oct 20, 2009 at 11:32 AM, Dikang Gu < " target="_blank"> > wrote:
Thank you Adam!

And after the authentication, will I get any information (like some tokens), that I will use in the http call?  To tell the chef-server that I have been authenticated?

Thanks 
Dikang

On Tue, Oct 20, 2009 at 2:25 AM, Adam Jacob < " target="_blank"> > wrote:
Sure - you need to just create a new client credential, and then set
it to be an administrator.

See the 'register' and 'authenticate' methods here:

http://gist.github.com/100837

Adam

On Mon, Oct 19, 2009 at 3:02 AM, Dikang Gu < " target="_blank"> > wrote:
> As per subject. So that I can do the operations just like users on the web
> UI?
> Thanks
> Dikang



--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: " target="_blank">



-- 
Arjuna Christensen, Software Development Engineer
Opscode, Inc.
E:  " target="_blank">



-- 
Arjuna Christensen, Software Development Engineer
Opscode, Inc.
E:  " target="_blank">





Archive powered by MHonArc 2.6.16.

§