GithubHelp home page GithubHelp logo

dparnell / erl_openid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from talklittle/erl_openid

0.0 1.0 0.0 338 KB

Erlang OpenID 2.0 - fork for zotonic's mod_openid https://bitbucket.org/helllamer/mod_openid/

License: MIT License

Erlang 100.00%

erl_openid's Introduction

Erlang OpenID client (and maybe server, sometime).

Quickstart workflow: 

[ your website starts ]

0> {ok, _Pid} = openid:start_link([]).

[ one user requested authentification over OpenID. 
  He/she passed an openid URL into form on you site. ]

1> {ok, AuthReq} = openid:prepare(SessionId, UserUrl).
	* SessionId -	Some string. For example "foobar".
	* UserUrl   -	The data, provided by user. Example values:
			"http://john.myopeid.org/"
			"https://www.google.com/o8/id"
			As you can, UserUrl may NOT contain any user name at all.
			Note: this URL is not unique for each user. 
			For example, all google users will provide equal URLs (look at URL above).
	* AuthReq   -	Just a returned context. Used for step 2.

2> Url = openid:authentication_url(AuthReq, ReturnTo, Realm).
	* AuthReq   -	See step 1.
	* ReturnTo  -	URL on YOUR server. User will be redirected here after authentification.
			Resource on this url should be able to handle GET and POST requests and 
			ready to pass all arguments into step 4. Example value:
			"http://yoursite.com/login/openid/verify"

	* Realm	    -	Will be displayed to user by remote OpenID server. 
			Many openid servers wants to see something like "http://yoursite.com/" 
			here and they will display message to user like "Site "yoursite.com" 
			wants to authentificate YOU. Continue?" to user. 
			This value must be immutable for ages. If it changes, user will be
			to reauthentificated again by remote server.

	* Url	    -	URL string for redirection the user. Just send user to this url and wait 
			for him on ReturnUrl.

3> [ user is redirected from your server to remote openID server ]

4> [ user returned to http://yoursite.com/login/openid/verify?openid.data=some_data&openid... ]

5> {ok, OpenId} = verify(SessionId, ReturnTo, HttpParams).
	* SessionId -	See step 1. Same value expected.
	* ReturnTo  -	See step 2. Same value expected for .
	* HttpParams-	Proplist [{string, string}]. It contains returned GET/POST parameters. 
			In zotonic:	z_context:get_q_all_noz(Context).
			In webmachine:	wrq:req_qs(ReqData).
			Constructed from URL on step 4 by mochiweb/webmachine/etc.
	* OpenId    -	Unique OpenID realm of user. String. Sometimes MAY be equal 
			to UserUrl (see step 1). Example values:
			"http://openid.myopenid.org/user/john/yadis/"
			"https://www.google.com/o8/ud/?x=agrg43gwsgsegergerg".
			Do not try to parse it, really. This Realm URL may NOT contain any 
			username. This realm is unique for every user.
			Just store it on your users db as some user_id. This realm helps 
			your's webserver to identity one user in future log-in attempts.


External Links:
http://taizilla.wordpress.com/2010/07/21/erl_openid-an-erlang-openid-2-0-client/ - Tutorial, written by original author.
http://paste.pocoo.org/show/235385/ - code sample (for mochiweb?).

erl_openid's People

Contributors

brendonh avatar andrewtj avatar talklittle avatar dparnell avatar lordnull avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.