Permalink
Browse files

Adding more info to the README

  • Loading branch information...
1 parent 06ac01e commit bd1d30280f27e1f113aee8ab209a8a02787ec398 @roman committed Sep 16, 2009
Showing with 24 additions and 21 deletions.
  1. +24 −21 README.rdoc
View
@@ -1,39 +1,31 @@
= warden_oauth
-warden_oauth enhances the warden gem offering a simple interface for creating oauth strategies
-on very simple steps.
+warden_oauth enhances the Warden authentication framework, offering a simple interface for creating
+oauth strategies.
== Getting Started
To get started you just have to require the warden_oauth libraries, and setup the
oauth services you would like to have on the <tt>Warden::Manager</tt> middleware declaration:
-<pre>
-<code class="ruby">
-Warden::Manager do |manager|
- manager.failure_app = FailureApp
- manager.oauth(:twitter) do |twitter|
- twitter.consumer_secret = <YOUR CONSUMER SECRET>
- twitter.consumer_token = <YOUR CONSUMER TOKEN>
- twitter.options :site => 'http://twitter.com'
+ Warden::Manager do |manager|
+ manager.failure_app = FailureApp
+ manager.oauth(:twitter) do |twitter|
+ twitter.consumer_secret = <YOUR CONSUMER SECRET>
+ twitter.consumer_token = <YOUR CONSUMER TOKEN>
+ twitter.options :site => 'http://twitter.com'
+ end
+ manager.default_strategies(:twitter_oauth, :password, :other)
end
- manager.default_strategies(:twitter_oauth, :password, :other)
-end
-</code>
-</pre>
== Giving an Access Token fetcher
Users get identified on a system via an access_token and an access_secret, when a valid access_token is
recevied, warden_oauth calls a fetcher declared on <tt>Warden::Manager.access_token_user_finder</tt>.
-<pre>
-<code class="ruby">
-Warden::Manager.access_token_user_finder(:twitter) do |access_token|
- User.find_by_access_token_and_access_secret(access_token.token, access_token.secret)
-end
-</code>
-</pre>
+ Warden::Manager.access_token_user_finder(:twitter) do |access_token|
+ User.find_by_access_token_and_access_secret(access_token.token, access_token.secret)
+ end
If a user is returned, then this is the user that is going to be authenticated in the session, otherwise the
<tt>FailureApp</tt> will be called, you may check the <tt>env['warden.options'][:oauth][:access_token]</tt> to check
@@ -48,6 +40,17 @@ a <tt>Warden::OAuth::Strategy::ServiceName</tt> will be declared, at the same ti
So if we have a declaration like the one of the Getting Started section, we will have an Strategy class
called <tt>Warden::OAuth::Strategy::Twitter</tt>, and this will be registered as <tt>:twitter_oauth</tt>.
+== Running the Strategy
+
+In order to get the strategy running in the app, you have to specify a parameter called warden_oauth_provider
+with the name of the oauth service you want to start. So for example, if you would like to boot the twitter
+oauth example given on the "Getting Started" section you just have to specify the parameter on a protected
+url.
+
+In Rails:
+
+ link_to 'Twitter Authentication', url_for(login_path(:warden_oauth_provider => 'twitter'))
+
== Note on Patches/Pull Requests
For any error send an email to: romanandreg [at] gmail [dot] com

0 comments on commit bd1d302

Please sign in to comment.