Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenId via Curl

How can I do OpenId based authentication using Curl? At first place can I do it? Regards, Allahbaksh

like image 670
Allahbaksh Asadullah Avatar asked Mar 28 '11 17:03

Allahbaksh Asadullah


1 Answers

I suppose you are talking about the curl command line, not the library. I have not tried, but according to what I know of OpenID and curl, it should be possible. However, not fully automated. You'll have to "parse" the content of the identity provider and of the content provider login pages if you want to be realy restful and generic. If you know where you're going and don't mind to couple your service and client (no hateoas), you can first authenticate with the identity provider, e.g.:

curl -iSsL --user-agent 'Mozilla/5.0' --cookie cookies --cookie-jar  cookies \
       --data login=$mylogin \
       --data passwd=$mypasswd \
       https://identprovider.example.com/login

and then post your OpenID to the content provider:

curl -iSsL --user-agent 'Mozilla/5.0' --cookie cookies --cookie-jar  cookies \
              --data openid="$myopenidurl" \
              http://contentprovider.example.com/login

This suppose that the content provider is already authorised to use the identity provider. Then get your content:

curl -iSsL --user-agent 'Mozilla/5.0' --cookie cookies --cookie-jar  cookies \
              http://contentprovider.example.com/interesting/content

Note that this approach is not restful, since I hard encoded the POST uris and fields in the code. To decouple the client and the server, the uris and field names must be extracted from responses. In a bash script, you can use sed for example.

I think is should work, but if not, then you'll have to realy follow the redirects and extract URIs and forms, since some params can be passed in the redirect URIs or in hidden form fields.

like image 175
Yannick Loiseau Avatar answered Oct 19 '22 01:10

Yannick Loiseau