-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Blanco
committed
Apr 25, 2010
0 parents
commit 3c4332a
Showing
13 changed files
with
604 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
pkg | ||
*.log | ||
.*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2010 Nicolas Blanco | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
h1. Devise RPX Connectable | ||
|
||
_Devise << RPX_ | ||
|
||
h2. What is Devise? | ||
|
||
A great authentication gem for Rails applications. | ||
|
||
"http://github.com/plataformatec/devise":http://github.com/plataformatec/devise | ||
|
||
h2. What is RPX? | ||
|
||
RPX is a Software as a Service (SaaS) that helps you manage multiple authentication methods (FacebookConnect, Google, Twitter, OpenID, MySpace...) using a single API. | ||
It also provides a multilingual connection widget. | ||
Instead of managing multiple authentication providers and APIs, you just need to handle one. | ||
|
||
RPX provides free and paid accounts. | ||
|
||
See *"RPX official homepage":https://rpxnow.com/*. If you want to see what it looks like, you may signup on the RPX website as it uses RPX for signup :). | ||
|
||
h2. What is Devise RPX Connectable? | ||
|
||
Devise RPX Connectable is a gem to integrate RPX authentication in a Rails application using Devise. | ||
|
||
h2. Dependencies | ||
|
||
Devise RPX Connectable was tested using latest stable Rails and Devise gems. | ||
|
||
Currently : | ||
|
||
*Rails* : version 2.3.5 | ||
*Devise* : version 1.0.6 | ||
|
||
I also want it to be compatible with latest prerelease gems of Devise, Rails and Mongoid. | ||
Therefore I also tested it with : | ||
|
||
*Rails* : version 3.0.0beta3 | ||
*Mongoid* : version 2.0.0beta4 | ||
*Devise* : master branch. | ||
|
||
h2. Installation | ||
|
||
*Gem (Rails >= 2.3.5)* | ||
|
||
<pre> | ||
$ sudo gem install devise_rpx_connectable | ||
</pre> | ||
|
||
...and in @config/environment.rb@: | ||
|
||
<pre> | ||
config.gem 'devise' | ||
config.gem 'rpx_now' | ||
config.gem 'devise_rpx_connectable' | ||
</pre> | ||
|
||
*Gem (Rails >= 3.0.0beta3)* | ||
|
||
@Gemfile@ | ||
|
||
<pre> | ||
gem 'devise', :git => 'git://github.com/plataformatec/devise.git' | ||
gem 'rpx_now' | ||
gem 'devise_rpx_connectable' | ||
</pre> | ||
|
||
h2. Setup | ||
|
||
*Devise: Setup* | ||
|
||
See "Devise":http://github.com/plataformatec/devise documentation for instructions on how to setup Devise. | ||
|
||
*Devise: Model* | ||
|
||
Add @:rpx_connectable@ in your Devise model (ie. User.rb) | ||
|
||
<pre> | ||
devise ..., :rpx_connectable | ||
</pre> | ||
|
||
*Devise:Setup* | ||
|
||
In the Devise initializer (may be @config/initializers/devise.rb@) : | ||
|
||
<pre> | ||
Devise.setup do |config| | ||
... | ||
config.rpx_application_name = "mytestingapp" # The name of your RPX application (this is the name, NOT the API key!) | ||
end | ||
</pre> | ||
|
||
*RPXNow:API Key* | ||
|
||
In @config/environment.rb@ : | ||
|
||
<pre> | ||
... | ||
config.after_initialize do # so rake gems:install works | ||
RPXNow.api_key = "aaaabbbbbccccdddddeeeeefffff" | ||
end | ||
... | ||
</pre> | ||
|
||
*Migrations* | ||
|
||
Your model needs one attribute/column to store the RPX identifier. By default, this identifier is @rpx_identifier@. | ||
|
||
*Views* | ||
|
||
I added an easy to use helper to add a link to the RPX connection popup. | ||
|
||
<pre> | ||
<%= link_to_rpx "Signin using RPX!", user_session_url %> | ||
</pre> | ||
|
||
If you use the link alone, users will be redirected to a new page. | ||
If you want the more sexy popup in overlay, you need to add the JS code before the @</body>@ of your layout. | ||
An helper is also included for this task : | ||
|
||
<pre> | ||
... | ||
<%= javascript_include_rpx(user_session_url) %> | ||
</body> | ||
</html> | ||
</pre> | ||
|
||
h2. Advanced | ||
|
||
There is some advanced features that you may use... | ||
|
||
*Devise:Setup* | ||
|
||
<pre> | ||
Devise.setup do |config| | ||
... | ||
config.rpx_auto_create_account = true # false if you don't want to create users automaticaly. True by default. | ||
end | ||
</pre> | ||
|
||
*Devise:Model* | ||
|
||
Some hooks are available to get the RPXNow user data objects before or after the connection. Read the RPXNow gem documentation for more information. | ||
|
||
<pre> | ||
def before_rpx_connect(rpx_user) | ||
# Do something with rpx_user... | ||
end | ||
|
||
def after_rpx_connect(rpx_user) | ||
# Do something with rpx_user | ||
end | ||
</pre> | ||
|
||
h2. TODO | ||
|
||
* With Rails 3 (only) I get an invalid auth token in sessions#create action. I have to skip the validation of the auth token. See why? | ||
* Handle RPX multiple accounts mapping? | ||
|
||
h2. Thanks | ||
|
||
The base of this gem was heavily inspired from the "Devise Facebook Connectable gem":http://github.com/grimen/devise_facebook_connectable by "Jonas Grimfelt":http://github.com/grimen and other Devise gems. | ||
|
||
h2. License | ||
|
||
Released under the MIT license.<br /> | ||
Copyright (c) 2010 "Nicolas Blanco":http://github.com/slainer68 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# encoding: utf-8 | ||
require 'rubygems' | ||
require 'rake' | ||
require 'rake/rdoctask' | ||
require File.join(File.dirname(__FILE__), 'lib', 'devise_rpx_connectable', 'version') | ||
|
||
NAME = "devise_rpx_connectable" | ||
|
||
begin | ||
gem 'jeweler' | ||
require 'jeweler' | ||
Jeweler::Tasks.new do |spec| | ||
spec.name = NAME | ||
spec.version = ::Devise::RpxConnectable::VERSION | ||
spec.summary = %{Devise << RPX} | ||
spec.description = spec.summary | ||
spec.homepage = "http://github.com/slainer68/#{spec.name}" | ||
spec.authors = ["Nicolas Blanco"] | ||
spec.email = "slainer68@gmail.com" | ||
|
||
spec.files = FileList['[A-Z]*', File.join(*%w[{lib,rails} ** *]).to_s] | ||
|
||
spec.add_dependency 'devise', '>= 1.0.6' | ||
spec.add_dependency 'rpx_now', '>= 0.6.19' | ||
end | ||
Jeweler::GemcutterTasks.new | ||
rescue LoadError | ||
puts "Jeweler - or one of its dependencies - is not available. " << | ||
"Install it with: sudo gem install jeweler -s http://gemcutter.org" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Generated by jeweler | ||
# DO NOT EDIT THIS FILE DIRECTLY | ||
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command | ||
# -*- encoding: utf-8 -*- | ||
|
||
Gem::Specification.new do |s| | ||
s.name = %q{devise_rpx_connectable} | ||
s.version = "0.1.0" | ||
|
||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
s.authors = ["Nicolas Blanco"] | ||
s.date = %q{2010-04-25} | ||
s.description = %q{Devise << RPX} | ||
s.email = %q{slainer68@gmail.com} | ||
s.extra_rdoc_files = [ | ||
"README.textile" | ||
] | ||
s.files = [ | ||
"MIT-LICENSE", | ||
"README.textile", | ||
"Rakefile", | ||
"lib/devise_rpx_connectable.rb", | ||
"lib/devise_rpx_connectable/locales/en.yml", | ||
"lib/devise_rpx_connectable/model.rb", | ||
"lib/devise_rpx_connectable/schema.rb", | ||
"lib/devise_rpx_connectable/strategy.rb", | ||
"lib/devise_rpx_connectable/version.rb", | ||
"lib/devise_rpx_connectable/view_helpers.rb", | ||
"rails/init.rb" | ||
] | ||
s.homepage = %q{http://github.com/slainer68/devise_rpx_connectable} | ||
s.rdoc_options = ["--charset=UTF-8"] | ||
s.require_paths = ["lib"] | ||
s.rubygems_version = %q{1.3.5} | ||
s.summary = %q{Devise << RPX} | ||
|
||
if s.respond_to? :specification_version then | ||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION | ||
s.specification_version = 3 | ||
|
||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then | ||
s.add_runtime_dependency(%q<devise>, [">= 1.0.6"]) | ||
s.add_runtime_dependency(%q<rpx_now>, [">= 0.6.19"]) | ||
else | ||
s.add_dependency(%q<devise>, [">= 1.0.6"]) | ||
s.add_dependency(%q<rpx_now>, [">= 0.6.19"]) | ||
end | ||
else | ||
s.add_dependency(%q<devise>, [">= 1.0.6"]) | ||
s.add_dependency(%q<rpx_now>, [">= 0.6.19"]) | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# encoding: utf-8 | ||
require 'devise' | ||
require 'rpx_now' | ||
|
||
require 'devise_rpx_connectable/model' | ||
require 'devise_rpx_connectable/strategy' | ||
require 'devise_rpx_connectable/schema' | ||
require 'devise_rpx_connectable/view_helpers' | ||
|
||
module Devise | ||
mattr_accessor :rpx_identifier_field | ||
@@rpx_identifier_field = :rpx_identifier | ||
|
||
mattr_accessor :rpx_auto_create_account | ||
@@rpx_auto_create_account = true | ||
|
||
mattr_accessor :rpx_application_name | ||
@@rpx_application_name = nil | ||
end | ||
|
||
I18n.load_path.unshift File.join(File.dirname(__FILE__), *%w[devise_rpx_connectable locales en.yml]) | ||
|
||
Devise.add_module(:rpx_connectable, | ||
:strategy => true, | ||
:controller => :sessions, | ||
:model => 'devise_rpx_connectable/model') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
en: | ||
devise: | ||
sessions: | ||
rpx_invalid: "Could not login. Invalid account." |
Oops, something went wrong.