multiauth 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ # Rails
5
+ .bundle
6
+
7
+ ## TEXTMATE
8
+ *.tmproj
9
+ tmtags
10
+
11
+ ## EMACS
12
+ *~
13
+ \#*
14
+ .\#*
15
+
16
+ ## VIM
17
+ *.swp
18
+
19
+ ## PROJECT::GENERAL
20
+ coverage
21
+ rdoc
22
+ pkg
23
+
24
+ ## PROJECT::SPECIFIC
25
+
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '>=3.0.0'
4
+ gem 'mm-devise', '1.2.0'
5
+ gem 'devise_openid_authenticatable', '1.0.0.alpha7'
6
+ gem 'devise-twitter', '0.1.1'
7
+ gem 'devise_invitable', '0.3.2'
8
+ gem 'oauth2', '0.0.13'
9
+
data/Gemfile.lock ADDED
@@ -0,0 +1,109 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.0)
6
+ actionpack (= 3.0.0)
7
+ mail (~> 2.2.5)
8
+ actionpack (3.0.0)
9
+ activemodel (= 3.0.0)
10
+ activesupport (= 3.0.0)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4.1)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.12)
16
+ rack-test (~> 0.5.4)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.0)
19
+ activesupport (= 3.0.0)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.4.1)
22
+ activerecord (3.0.0)
23
+ activemodel (= 3.0.0)
24
+ activesupport (= 3.0.0)
25
+ arel (~> 1.0.0)
26
+ tzinfo (~> 0.3.23)
27
+ activeresource (3.0.0)
28
+ activemodel (= 3.0.0)
29
+ activesupport (= 3.0.0)
30
+ activesupport (3.0.0)
31
+ addressable (2.2.1)
32
+ arel (1.0.1)
33
+ activesupport (~> 3.0.0)
34
+ bcrypt-ruby (2.1.2)
35
+ builder (2.1.2)
36
+ devise (1.1.2)
37
+ bcrypt-ruby (~> 2.1.2)
38
+ warden (~> 0.10.7)
39
+ devise-twitter (0.1.1)
40
+ devise (>= 1.1.0)
41
+ warden_oauth (~> 0.1.1)
42
+ devise_invitable (0.3.2)
43
+ devise (~> 1.1.0)
44
+ devise_openid_authenticatable (1.0.0.alpha7)
45
+ devise (>= 1.0.6)
46
+ rack-openid (>= 1.2.0)
47
+ erubis (2.6.6)
48
+ abstract (>= 1.0.0)
49
+ faraday (0.4.6)
50
+ addressable (>= 2.1.1)
51
+ rack (>= 1.0.1)
52
+ i18n (0.4.1)
53
+ mail (2.2.6.1)
54
+ activesupport (>= 2.3.6)
55
+ mime-types
56
+ treetop (>= 1.4.5)
57
+ mime-types (1.16)
58
+ mm-devise (1.2.0)
59
+ bcrypt-ruby (~> 2.1.2)
60
+ warden (~> 0.10.7)
61
+ multi_json (0.0.4)
62
+ oauth (0.4.3)
63
+ oauth2 (0.0.13)
64
+ faraday (~> 0.4.1)
65
+ multi_json (>= 0.0.4)
66
+ polyglot (0.3.1)
67
+ rack (1.2.1)
68
+ rack-mount (0.6.13)
69
+ rack (>= 1.0.0)
70
+ rack-openid (1.2.0)
71
+ rack (>= 1.1.0)
72
+ ruby-openid (>= 2.1.8)
73
+ rack-test (0.5.4)
74
+ rack (>= 1.0)
75
+ rails (3.0.0)
76
+ actionmailer (= 3.0.0)
77
+ actionpack (= 3.0.0)
78
+ activerecord (= 3.0.0)
79
+ activeresource (= 3.0.0)
80
+ activesupport (= 3.0.0)
81
+ bundler (~> 1.0.0)
82
+ railties (= 3.0.0)
83
+ railties (3.0.0)
84
+ actionpack (= 3.0.0)
85
+ activesupport (= 3.0.0)
86
+ rake (>= 0.8.4)
87
+ thor (~> 0.14.0)
88
+ rake (0.8.7)
89
+ ruby-openid (2.1.8)
90
+ thor (0.14.0)
91
+ treetop (1.4.8)
92
+ polyglot (>= 0.3.1)
93
+ tzinfo (0.3.23)
94
+ warden (0.10.7)
95
+ rack (>= 1.0.0)
96
+ warden_oauth (0.1.1)
97
+ oauth
98
+ warden (>= 0.8.1)
99
+
100
+ PLATFORMS
101
+ ruby
102
+
103
+ DEPENDENCIES
104
+ devise-twitter (= 0.1.1)
105
+ devise_invitable (= 0.3.2)
106
+ devise_openid_authenticatable (= 1.0.0.alpha7)
107
+ mm-devise (= 1.2.0)
108
+ oauth2 (= 0.0.13)
109
+ rails (>= 3.0.0)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 David A. Cuadrado
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = multiauth
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 David A. Cuadrado. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "multiauth"
8
+ gem.summary = %Q{multi authentication gem using devise & co}
9
+ gem.description = %Q{multi authentication gem using devise & co}
10
+ gem.email = "krawek@gmail.com"
11
+ gem.homepage = "http://github.com/dcu/multiauth"
12
+ gem.authors = ["David A. Cuadrado"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ gem.add_dependency "rails", "3.0.0"
16
+ gem.add_dependency "mm-devise", "1.2.0"
17
+ gem.add_dependency 'devise_openid_authenticatable', '1.0.0.alpha7'
18
+ gem.add_dependency 'devise-twitter', '0.1.1'
19
+ gem.add_dependency 'devise_invitable', '0.3.2'
20
+ gem.add_dependency 'oauth2', '0.0.13'
21
+ end
22
+ Jeweler::GemcutterTasks.new
23
+ rescue LoadError
24
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
+ end
26
+
27
+ require 'spec/rake/spectask'
28
+ Spec::Rake::SpecTask.new(:spec) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.spec_files = FileList['spec/**/*_spec.rb']
31
+ end
32
+
33
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
34
+ spec.libs << 'lib' << 'spec'
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :spec => :check_dependencies
40
+
41
+ task :default => :spec
42
+
43
+ require 'rake/rdoctask'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "multiauth #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,28 @@
1
+ module Multiauth
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+ namespace 'multiauth'
6
+ desc "initializes the required files"
7
+
8
+ def copy_js
9
+ copy_file "multiauth.js", "public/javascripts/multiauth.js"
10
+ end
11
+
12
+ def copy_openid
13
+ directory "openid-realselector", "public/javascripts/openid-realselector"
14
+ end
15
+
16
+ def copy_twitter
17
+ copy_file "devise_twitter.rb", "config/initializers/devise_twitter.rb"
18
+ end
19
+
20
+ def show_readme
21
+ readme "README"
22
+ end
23
+
24
+ protected
25
+ end
26
+ end # Generators
27
+ end # Multiauth
28
+
@@ -0,0 +1,93 @@
1
+
2
+ ===============================================================================
3
+
4
+ Some setup you must do manually if you haven't yet:
5
+
6
+ 1. configure your model, for example:
7
+
8
+ class User
9
+ devise :database_authenticatable, :openid_authenticatable, :rememberable,
10
+ :trackable, :validatable, :twitter_oauth, :oauthable
11
+
12
+ def self.find_for_github_oauth(access_token, signed_in_resource=nil)
13
+ data = ActiveSupport::JSON.decode(access_token.get('/api/v2/json/user/show'))["user"]
14
+
15
+ if user = User.find_by_email(data["email"])
16
+ user
17
+ else
18
+ User.create!(:name => data["name"], :email => data["email"],
19
+ :github_id => data["id"])
20
+ end
21
+ end
22
+
23
+ def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
24
+ data = ActiveSupport::JSON.decode(access_token.get('/me'))
25
+
26
+ if user = User.find_by_email(data["email"])
27
+ user
28
+ else
29
+ User.create!(:name => data["name"], :email => data["email"],
30
+ :facebook_id => data["id"], :facebook_profile => data["link"])
31
+ end
32
+ end
33
+
34
+ def self.create_from_identity_url(identity_url)
35
+ self.create(:identity_url => identity_url)
36
+ end
37
+
38
+ def self.openid_required_fields
39
+ ["fullname", "email", "http://axschema.org/pref/language", "http://axschema.org/contact/email"]
40
+ end
41
+
42
+ def self.openid_optional_fields
43
+ %w[
44
+ http://axschema.org/namePerson/friendly
45
+ http://axschema.org/namePerson
46
+ http://axschema.org/birthDate
47
+ gender
48
+ http://axschema.org/person/gender
49
+ http://axschema.org/contact/postalCode/home
50
+ country
51
+ http://axschema.org/contact/country/home
52
+ language
53
+ http://axschema.org/pref/language
54
+ http://axschema.org/pref/timezone
55
+ ]
56
+ end
57
+
58
+ def openid_fields=(fields)
59
+ logger.info "OPENID FIELDS: #{fields.inspect}"
60
+ fields.each do |key, value|
61
+ if value.is_a? Array
62
+ value = value.first
63
+ end
64
+
65
+ case key.to_s
66
+ when "fullname", "http://axschema.org/namePerson"
67
+ self.full_name = value
68
+ when "email", "http://axschema.org/contact/email"
69
+ self.email = value
70
+ when "gender", "http://axschema.org/person/gender"
71
+ self.gender = value
72
+ else
73
+ logger.error "Unknown OpenID field: #{key}"
74
+ end
75
+ end
76
+ end
77
+
78
+ def password_required?
79
+ return false if self[:identity_url].present? || self[:facebook_id].present? || self[:github_id].present?
80
+
81
+ (encrypted_password.blank? || !password.blank?)
82
+ end
83
+ end
84
+
85
+ 2. to include the javascripts do
86
+ <%= multiauth_assets %>
87
+
88
+ to render the multiauth box do
89
+ <%= multiauth_box %>
90
+
91
+ 3. configure your twitter, facebook and github keys
92
+
93
+ ===============================================================================
@@ -0,0 +1,7 @@
1
+ Devise::Twitter.setup do |config|
2
+ # Generate them at http::/twitter.com/apps
3
+ config.consumer_key = "my consumer key"
4
+ config.consumer_secret = "my consumer secret"
5
+ config.scope = :user
6
+ end
7
+
@@ -0,0 +1,11 @@
1
+ jQuery(function ($) {
2
+ var oid = $("#openid");
3
+
4
+ if(oid.length > 0) {
5
+ $("form#openid #nojsopenid").remove();
6
+ $("#openid").openid({
7
+ img_path: '/javascripts/openid-realselector/img/',
8
+ param: 'user[identity_url]'
9
+ })
10
+ }
11
+ });
@@ -0,0 +1,79 @@
1
+ body {
2
+ font: 14px 'Arial';
3
+ }
4
+
5
+ #openid {
6
+ background: url(../img/indicator.gif) center center no-repeat;
7
+ margin: 0 auto;
8
+ width: 440px;
9
+ height: 162px;
10
+ }
11
+
12
+ #openid_inputarea {
13
+ clear: both;
14
+ display: none;
15
+ background: url(../img/balloon.png) no-repeat;
16
+ width: 410px;
17
+ height: 48px;
18
+ color: white;
19
+ text-align: center;
20
+ margin-top: 35px;
21
+ padding-top: 17px;
22
+ }
23
+
24
+ #openid_inputarea #openid_username {
25
+ margin: 0 4px 0 8px;
26
+ width: 120px;
27
+ }
28
+
29
+ #openid_btns, #openid_btns br {
30
+ clear: both;
31
+ }
32
+
33
+ #openid_highlight {
34
+ -moz-border-radius: 10px;
35
+ -webkit-border-radius: 10px;
36
+ padding: 2px;
37
+ background-color: #FFFCC9;
38
+ float: left;
39
+ }
40
+
41
+ .openid_large_btn, .openid_small_btn {
42
+ background: url(../img/openid-icons.png) no-repeat;
43
+ margin: 3px;
44
+ float: left;
45
+ }
46
+
47
+ .openid_large_btn {
48
+ width: 91px;
49
+ height: 51px;
50
+ }
51
+
52
+ .openid_small_btn {
53
+ width: 16px;
54
+ height: 16px;
55
+ }
56
+
57
+ .Google { background-position: 0 0; }
58
+ .Yahoo { background-position: 0 -51px; }
59
+ .AOL { background-position: 0 -102px; }
60
+ .OpenID { background-position: 0 -153px; }
61
+ .MyOpenID { background-position: 0 -204px; }
62
+ .Flickr { background-position: 0 -220px; }
63
+ .Technorati { background-position: -17px -220px; }
64
+ .Wordpress { background-position: -17px -204px; }
65
+ .Blogger { background-position: -34px -204px; }
66
+ .Verisign { background-position: -51px -220px; }
67
+ .Vidoop { background-position: -34px -220px; }
68
+ .ClaimID { background-position: -68px -204px; }
69
+ .LiveJournal { background-position: -51px -204px; }
70
+ .Launchpad { background-position: 0 -236.9px; }
71
+ .Facebook { background-position: 0 -287px; }
72
+ .Twitter { background-position: 0 -338px; }
73
+ .Github { background-position: 0 -389px; }
74
+ .MySpace { background-position: 0px -220px; }
75
+
76
+ a.openid_large_btn:focus {
77
+ outline: none;
78
+ -moz-outline-style: none;
79
+ }
@@ -0,0 +1,217 @@
1
+ /*
2
+ OpenID Plugin
3
+ http://code.google.com/p/openid-realselector/
4
+
5
+ Martin Conte Mac Donell <Reflejo@gmail.com>
6
+ */
7
+
8
+ (function($) {
9
+ $.fn.openid = function(opt) {
10
+ var gprovider;
11
+ var INPUTID = 'openid_username';
12
+ var inputarea = $('#openid_inputarea').length ? $('#openid_inputarea'): $('<div id="openid_inputarea" />');
13
+
14
+ var defaults = {
15
+ txt: {
16
+ label: 'Enter your {provider} {username}',
17
+ username: 'username',
18
+ title: 'Select your openID provider',
19
+ sign: 'Sign-In'
20
+ },
21
+ /*
22
+ Default providers with url. "big" variable means that icon
23
+ will be big.
24
+ */
25
+ providers: [
26
+ {
27
+ name: 'Google',
28
+ url: 'https://www.google.com/accounts/o8/id',
29
+ label: null,
30
+ big: true
31
+ },
32
+ {
33
+ name: 'Yahoo',
34
+ url: 'http://yahoo.com/',
35
+ label: null,
36
+ big: true
37
+ },
38
+ {
39
+ name: 'Twitter',
40
+ url: '/users/sign_in/twitter',
41
+ real: true,
42
+ big: true
43
+ },
44
+ {
45
+ name: 'Facebook',
46
+ selector: '#facebook_signin',
47
+ real: true,
48
+ big: true
49
+ },
50
+ {
51
+ name: 'MyOpenID',
52
+ url: 'http://{username}.myopenid.com/'
53
+ },
54
+ {
55
+ name: 'Flickr',
56
+ url: 'http://flickr.com/{username}/'
57
+ },
58
+ {
59
+ name: 'AOL',
60
+ username_txt: 'screenname',
61
+ url: 'http://openid.aol.com/{username}',
62
+ big: true
63
+ },
64
+ {
65
+ name: 'OpenID',
66
+ username_txt: 'url',
67
+ big: true
68
+ },
69
+ {
70
+ name: 'Vidoop',
71
+ url: 'http://{username}.myvidoop.com/'
72
+ },
73
+ {
74
+ name: 'ClaimID',
75
+ url: 'http://claimid.com/{username}'
76
+ },
77
+ {
78
+ name: 'Technorati',
79
+ url: 'http://technorati.com/people/technorati/{username}/'
80
+ },
81
+ {
82
+ name: 'Wordpress',
83
+ url: 'http://{username}.wordpress.com/'
84
+ },
85
+ {
86
+ name: 'Blogger',
87
+ url: 'http://{username}.blogspot.com/'
88
+ },
89
+ {
90
+ name: 'Verisign',
91
+ url: 'http://{username}.pip.verisignlabs.com/'
92
+ },
93
+ {
94
+ name: 'LiveJournal',
95
+ url: 'http://{username}.livejournal.com'
96
+ },
97
+ {
98
+ name: 'MySpace',
99
+ url: 'http://www.myspace.com/{username}'
100
+ },
101
+ {
102
+ name: 'Launchpad',
103
+ url: 'https://launchpad.net/~{username}',
104
+ big: true
105
+ },
106
+ {
107
+ name: 'Github',
108
+ selector: '#github_signin',
109
+ real: true,
110
+ big: true
111
+ }
112
+ ],
113
+ cookie_expires: 6 * 30, // in days.
114
+ cookie_path: '/',
115
+ img_path: '/img/'
116
+ };
117
+
118
+ var getBox = function(provider, idx, box_size) {
119
+ var a = $('<a title="' + provider.name + '" href="#" id="btn_' + idx +
120
+ '" class="openid_' + box_size + '_btn ' + provider.name + '" />');
121
+
122
+ if(provider.real) {
123
+ if(provider.url){
124
+ a.attr("href", provider.url);
125
+ } else {
126
+ var target = $(provider.selector);
127
+ a.attr("href", target.attr('href'));
128
+ target.remove();
129
+ }
130
+ return a;
131
+ }
132
+
133
+ return a.click(signIn);
134
+ };
135
+
136
+ var setCookie = function(value) {
137
+ var date = new Date();
138
+ date.setTime(date.getTime() + (settings.cookie_expires * 24 * 60 * 60 * 1000));
139
+ document.cookie = "openid_prov=" + value + "; expires=" + date.toGMTString() +
140
+ "; path=" + settings.cookie_path;
141
+ };
142
+
143
+ var readCookie = function(){
144
+ var c = document.cookie.split(';');
145
+ for(i in c){
146
+ if ((pos = c[i].indexOf("openid_prov=")) != -1)
147
+ return $.trim(c[i].slice(pos + 12));
148
+ }
149
+ };
150
+
151
+ var signIn = function(obj, tidx) {
152
+ var idx = $(tidx || this).attr('id').replace('btn_', '');
153
+ if (!(gprovider = settings.providers[idx]))
154
+ return;
155
+
156
+ // Hightlight
157
+ if (highlight = $('#openid_highlight'))
158
+ highlight.replaceWith($('#openid_highlight a')[0]);
159
+
160
+ $('#btn_' + idx).wrap('<div id="openid_highlight" />');
161
+ setCookie(idx);
162
+
163
+ // prompt user for input?
164
+ showInputBox();
165
+ if (gprovider.label === null) {
166
+ inputarea.text(settings.txt.title);
167
+ if (!tidx) {
168
+ inputarea.fadeOut();
169
+ form.submit();
170
+ }
171
+ }
172
+ return false;
173
+ };
174
+
175
+ var showInputBox = function() {
176
+ var lbl = (gprovider.label || settings.txt.label).replace(
177
+ '{username}', (gprovider.username_txt !== undefined) ? gprovider.username_txt: settings.txt.username
178
+ ).replace('{provider}', gprovider.name);
179
+
180
+ inputarea.empty().show().append('<span class="oidlabel">' + lbl + '</span><input id="' + INPUTID + '" type="text" ' +
181
+ ' name="username_txt" class="Verisign"/><input type="submit" value="' + settings.txt.sign + '"/>');
182
+
183
+ $('#' + INPUTID).focus();
184
+ };
185
+
186
+ var submit = function(){
187
+ var prov = (gprovider.url) ? gprovider.url.replace('{username}', $('#' + INPUTID).val()): $('#' + INPUTID).val();
188
+ form.append($('<input type="hidden" name="'+settings.param+'" value="' + prov + '" />'));
189
+ };
190
+
191
+ var settings = $.extend(defaults, opt || {});
192
+
193
+ var btns = $('<div id="openid_btns" />');
194
+
195
+ // Add box for each provider
196
+ var addbr = true;
197
+ $.each(settings.providers, function(i, val) {
198
+ if (!val.big && addbr) {
199
+ btns.append('<br />');
200
+ addbr = false;
201
+ }
202
+ btns.append(getBox(val, i, (val.big) ? 'large': 'small'));
203
+ });
204
+
205
+ var form = this;
206
+ form.css({'background-image': 'none'});
207
+ form.append(btns).submit(submit);
208
+ btns.append(inputarea);
209
+
210
+ if (idx = readCookie())
211
+ signIn(null, '#btn_' + idx);
212
+ else
213
+ inputarea.text(settings.txt.title).show();
214
+
215
+ return this;
216
+ };
217
+ })(jQuery);
@@ -0,0 +1,7 @@
1
+ /*
2
+ OpenID Plugin
3
+ http://code.google.com/p/openid-realselector/
4
+
5
+ Martin Conte Mac Donell <Reflejo@gmail.com>
6
+ */
7
+ (function($){$.fn.openid=function(e){var f;var g='openid_username';var h=$('#openid_inputarea').length?$('#openid_inputarea'):$('<div id="openid_inputarea" />');var j={txt:{label:'Enter your {provider} {username}',username:'username',title:'Select your openID provider',sign:'Sign-In'},providers:[{name:'Google',url:'https://www.google.com/accounts/o8/id',label:null,big:true},{name:'Yahoo',url:'http://yahoo.com/',label:null,big:true},{name:'AOL',username_txt:'screenname',url:'http://openid.aol.com/{username}',big:true},{name:'OpenID',username_txt:'url',big:true},{name:'MyOpenID',url:'http://{username}.myopenid.com/'},{name:'Flickr',url:'http://flickr.com/{username}/'},{name:'Technorati',url:'http://technorati.com/people/technorati/{username}/'},{name:'Wordpress',url:'http://{username}.wordpress.com/'},{name:'Blogger',url:'http://{username}.blogspot.com/'},{name:'Verisign',url:'http://{username}.pip.verisignlabs.com/'},{name:'Vidoop',url:'http://{username}.myvidoop.com/'},{name:'ClaimID',url:'http://claimid.com/{username}'},{name:'LiveJournal',url:'http://{username}.livejournal.com'},{name:'MySpace',url:'http://www.myspace.com/{username}'}],cookie_expires:6*30,cookie_path:'/',img_path:'/img/'};var k=function(b,c,d){var a=$('<a title="'+b+'" href="#" id="btn_'+c+'" class="openid_'+d+'_btn '+b+'" />');return a.click(n)};var l=function(a){var b=new Date();b.setTime(b.getTime()+(q.cookie_expires*24*60*60*1000));document.cookie="openid_prov="+a+"; expires="+b.toGMTString()+"; path="+q.cookie_path};var m=function(){var c=document.cookie.split(';');for(i in c){if((pos=c[i].indexOf("openid_prov="))!=-1)return $.trim(c[i].slice(pos+12))}};var n=function(a,b){var c=$(b||this).attr('id').replace('btn_','');if(!(f=q.providers[c]))return;if(highlight=$('#openid_highlight'))highlight.replaceWith($('#openid_highlight a')[0]);$('#btn_'+c).wrap('<div id="openid_highlight" />');l(c);o();if(f.label===null){h.text(q.txt.title);if(!b){h.fadeOut();t.submit()}}return false};var o=function(){var a=(f.label||q.txt.label).replace('{username}',(f.username_txt!==undefined)?f.username_txt:q.txt.username).replace('{provider}',f.name);h.empty().show().append('<span class="oidlabel">'+a+'</span><input id="'+g+'" type="text" '+' name="username_txt" class="Verisign"/><input type="submit" value="'+q.txt.sign+'"/>');$('#'+g).focus()};var p=function(){var a=(f.url)?f.url.replace('{username}',$('#'+g).val()):$('#'+g).val();t.append($('<input type="hidden" name="url" value="'+a+'" />'))};var q=$.extend(j,e||{});var r=$('<div id="openid_btns" />');var s=true;$.each(q.providers,function(i,a){if(!a.big&&s){r.append('<br />');s=false}r.append(k(a.name,i,(a.big)?'large':'small'))});var t=this;t.css({'background-image':'none'});t.append(r).submit(p);r.append(h);if(idx=m())n(null,'#btn_'+idx);else h.text(q.txt.title).show();return this}})(jQuery);
File without changes
@@ -0,0 +1,19 @@
1
+ module Multiauth
2
+ module ViewsHelper
3
+ def multiauth_box(url = nil)
4
+ url = session_path(resource_name) if !url
5
+
6
+ form_for(resource, :as => resource_name, :url => url, :html => {:id => "openid"}) do |f|
7
+ %@<div id="nojsopenid">#{f.text_field(:identity_url)}#{f.submit('Sign in')}</div>@
8
+ end
9
+ end
10
+
11
+ def multiauth_assets
12
+ javascript_include_tag('openid-realselector/js/jquery.openid.js')+
13
+ javascript_include_tag('multiauth')+
14
+ stylesheet_link_tag('/javascripts/openid-realselector/css/style')
15
+ end
16
+ end
17
+ end
18
+
19
+ ::ActionView::Base.send :include, Multiauth::ViewsHelper
data/lib/multiauth.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'multiauth/rails'
2
+ require 'multiauth/views_helper'
3
+
data/multiauth.gemspec ADDED
@@ -0,0 +1,87 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{multiauth}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["David A. Cuadrado"]
12
+ s.date = %q{2010-09-16}
13
+ s.description = %q{multi authentication gem using devise & co}
14
+ s.email = %q{krawek@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/generators/multiauth/multiauth_generator.rb",
29
+ "lib/generators/templates/README",
30
+ "lib/generators/templates/devise_twitter.rb",
31
+ "lib/generators/templates/multiauth.js",
32
+ "lib/generators/templates/openid-realselector/css/style.css",
33
+ "lib/generators/templates/openid-realselector/img/balloon.png",
34
+ "lib/generators/templates/openid-realselector/img/indicator.gif",
35
+ "lib/generators/templates/openid-realselector/img/openid-icons.png",
36
+ "lib/generators/templates/openid-realselector/js/jquery.openid.js",
37
+ "lib/generators/templates/openid-realselector/js/jquery.openid.min.js",
38
+ "lib/multiauth.rb",
39
+ "lib/multiauth/rails.rb",
40
+ "lib/multiauth/views_helper.rb",
41
+ "multiauth.gemspec",
42
+ "spec/multiauth_spec.rb",
43
+ "spec/spec.opts",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+ s.homepage = %q{http://github.com/dcu/multiauth}
47
+ s.rdoc_options = ["--charset=UTF-8"]
48
+ s.require_paths = ["lib"]
49
+ s.rubygems_version = %q{1.3.7}
50
+ s.summary = %q{multi authentication gem using devise & co}
51
+ s.test_files = [
52
+ "spec/multiauth_spec.rb",
53
+ "spec/spec_helper.rb"
54
+ ]
55
+
56
+ if s.respond_to? :specification_version then
57
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
+ s.specification_version = 3
59
+
60
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
62
+ s.add_runtime_dependency(%q<rails>, ["= 3.0.0"])
63
+ s.add_runtime_dependency(%q<mm-devise>, ["= 1.2.0"])
64
+ s.add_runtime_dependency(%q<devise_openid_authenticatable>, ["= 1.0.0.alpha7"])
65
+ s.add_runtime_dependency(%q<devise-twitter>, ["= 0.1.1"])
66
+ s.add_runtime_dependency(%q<devise_invitable>, ["= 0.3.2"])
67
+ s.add_runtime_dependency(%q<oauth2>, ["= 0.0.13"])
68
+ else
69
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
70
+ s.add_dependency(%q<rails>, ["= 3.0.0"])
71
+ s.add_dependency(%q<mm-devise>, ["= 1.2.0"])
72
+ s.add_dependency(%q<devise_openid_authenticatable>, ["= 1.0.0.alpha7"])
73
+ s.add_dependency(%q<devise-twitter>, ["= 0.1.1"])
74
+ s.add_dependency(%q<devise_invitable>, ["= 0.3.2"])
75
+ s.add_dependency(%q<oauth2>, ["= 0.0.13"])
76
+ end
77
+ else
78
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
79
+ s.add_dependency(%q<rails>, ["= 3.0.0"])
80
+ s.add_dependency(%q<mm-devise>, ["= 1.2.0"])
81
+ s.add_dependency(%q<devise_openid_authenticatable>, ["= 1.0.0.alpha7"])
82
+ s.add_dependency(%q<devise-twitter>, ["= 0.1.1"])
83
+ s.add_dependency(%q<devise_invitable>, ["= 0.3.2"])
84
+ s.add_dependency(%q<oauth2>, ["= 0.0.13"])
85
+ end
86
+ end
87
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Multiauth" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'multiauth'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: multiauth
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - David A. Cuadrado
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-09-16 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 2
31
+ - 9
32
+ version: 1.2.9
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rails
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 3
45
+ - 0
46
+ - 0
47
+ version: 3.0.0
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: mm-devise
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - "="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 1
60
+ - 2
61
+ - 0
62
+ version: 1.2.0
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: devise_openid_authenticatable
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - "="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 1
75
+ - 0
76
+ - 0
77
+ - alpha7
78
+ version: 1.0.0.alpha7
79
+ type: :runtime
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: devise-twitter
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - "="
88
+ - !ruby/object:Gem::Version
89
+ segments:
90
+ - 0
91
+ - 1
92
+ - 1
93
+ version: 0.1.1
94
+ type: :runtime
95
+ version_requirements: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ name: devise_invitable
98
+ prerelease: false
99
+ requirement: &id006 !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - "="
103
+ - !ruby/object:Gem::Version
104
+ segments:
105
+ - 0
106
+ - 3
107
+ - 2
108
+ version: 0.3.2
109
+ type: :runtime
110
+ version_requirements: *id006
111
+ - !ruby/object:Gem::Dependency
112
+ name: oauth2
113
+ prerelease: false
114
+ requirement: &id007 !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - "="
118
+ - !ruby/object:Gem::Version
119
+ segments:
120
+ - 0
121
+ - 0
122
+ - 13
123
+ version: 0.0.13
124
+ type: :runtime
125
+ version_requirements: *id007
126
+ description: multi authentication gem using devise & co
127
+ email: krawek@gmail.com
128
+ executables: []
129
+
130
+ extensions: []
131
+
132
+ extra_rdoc_files:
133
+ - LICENSE
134
+ - README.rdoc
135
+ files:
136
+ - .document
137
+ - .gitignore
138
+ - Gemfile
139
+ - Gemfile.lock
140
+ - LICENSE
141
+ - README.rdoc
142
+ - Rakefile
143
+ - VERSION
144
+ - lib/generators/multiauth/multiauth_generator.rb
145
+ - lib/generators/templates/README
146
+ - lib/generators/templates/devise_twitter.rb
147
+ - lib/generators/templates/multiauth.js
148
+ - lib/generators/templates/openid-realselector/css/style.css
149
+ - lib/generators/templates/openid-realselector/img/balloon.png
150
+ - lib/generators/templates/openid-realselector/img/indicator.gif
151
+ - lib/generators/templates/openid-realselector/img/openid-icons.png
152
+ - lib/generators/templates/openid-realselector/js/jquery.openid.js
153
+ - lib/generators/templates/openid-realselector/js/jquery.openid.min.js
154
+ - lib/multiauth.rb
155
+ - lib/multiauth/rails.rb
156
+ - lib/multiauth/views_helper.rb
157
+ - multiauth.gemspec
158
+ - spec/multiauth_spec.rb
159
+ - spec/spec.opts
160
+ - spec/spec_helper.rb
161
+ has_rdoc: true
162
+ homepage: http://github.com/dcu/multiauth
163
+ licenses: []
164
+
165
+ post_install_message:
166
+ rdoc_options:
167
+ - --charset=UTF-8
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ segments:
176
+ - 0
177
+ version: "0"
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ segments:
184
+ - 0
185
+ version: "0"
186
+ requirements: []
187
+
188
+ rubyforge_project:
189
+ rubygems_version: 1.3.7
190
+ signing_key:
191
+ specification_version: 3
192
+ summary: multi authentication gem using devise & co
193
+ test_files:
194
+ - spec/multiauth_spec.rb
195
+ - spec/spec_helper.rb