muck-auth 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.rdoc +38 -1
- data/VERSION +1 -1
- data/app/controllers/muck/authentications_controller.rb +2 -1
- data/app/helpers/muck_auth_helper.rb +29 -4
- data/app/views/authentications/_available_services.html.erb +3 -7
- data/app/views/authentications/_current_services.html.erb +1 -1
- data/db/migrate/20110216045051_create_authentications.rb +21 -0
- data/lib/muck-auth/config.rb +1 -6
- data/lib/muck-auth/engine.rb +6 -6
- data/lib/muck-auth/models/authentication.rb +6 -4
- data/lib/muck-auth/models/user.rb +1 -1
- data/muck-auth.gemspec +3 -2
- metadata +5 -4
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,5 +1,42 @@
|
|
1
1
|
= muck-auth
|
2
2
|
This gem wraps the omniauth gem to make it simple to authenticate with multiple services.
|
3
3
|
|
4
|
+
== Installation
|
4
5
|
|
5
|
-
|
6
|
+
Add muck-auth to your Gemfile:
|
7
|
+
gem 'muck-auth'
|
8
|
+
|
9
|
+
|
10
|
+
After installing muck-auth be sure to sync the gem:
|
11
|
+
|
12
|
+
rake muck:sync:auth
|
13
|
+
|
14
|
+
or to sync everything from the muck framework:
|
15
|
+
|
16
|
+
rake muck:sync
|
17
|
+
|
18
|
+
== Configuration
|
19
|
+
Add services by including the proper credentials in secrets.yml:
|
20
|
+
|
21
|
+
auth_credentials:
|
22
|
+
twitter: # Twitter api access: http://www.twitter.com/apps
|
23
|
+
key: '{get a key}'
|
24
|
+
secret: '{it comes with a secret}'
|
25
|
+
|
26
|
+
=== OAuth Services
|
27
|
+
Here's a list of common oauth services. For a complete list of all available services please consult the omniauth documentation as the available services are constantly changing:
|
28
|
+
https://github.com/intridea/omniauth
|
29
|
+
|
30
|
+
Twitter: http://www.twitter.com/apps
|
31
|
+
Google: http://code.google.com/apis/accounts/docs/RegistrationForWebAppsAuto.html#register
|
32
|
+
Yahoo: http://developer.yahoo.com/flickr/
|
33
|
+
Flick: http://www.flickr.com/services/apps/create/apply
|
34
|
+
Linked In: https://www.linkedin.com/secure/developer
|
35
|
+
Friendfeed: https://friendfeed.com/account/login?next=%2Fapi%2Fregister
|
36
|
+
|
37
|
+
== Usage
|
38
|
+
Render a full list of all services with links to authorize the service and icons:
|
39
|
+
<%= render :partial => 'authentications/available_services', :locals => { :include_icons => true } %>
|
40
|
+
|
41
|
+
|
42
|
+
Copyright (c) 2009-2011 Tatemae.com. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.0
|
@@ -15,7 +15,8 @@ class Muck::AuthenticationsController < ApplicationController
|
|
15
15
|
@omniauth = request.env["omniauth.auth"]
|
16
16
|
# Associated the account with the user
|
17
17
|
if current_user
|
18
|
-
current_user.authentications.create!(:provider => @omniauth['provider'], :uid => @omniauth['uid'], :raw_auth => @omniauth.to_json
|
18
|
+
current_user.authentications.create!(:provider => @omniauth['provider'], :uid => @omniauth['uid'], :raw_auth => @omniauth.to_json,
|
19
|
+
:token => @omniauth['credentials']['token'], :secret => @omniauth['credentials']['secret'] )
|
19
20
|
flash[:notice] = t('muck.auth.authentication_success')
|
20
21
|
redirect_to authentications_url
|
21
22
|
# Try to log the user in via the service
|
@@ -1,10 +1,35 @@
|
|
1
1
|
module MuckAuthHelper
|
2
|
+
|
3
|
+
def auth_list(include_icons)
|
4
|
+
list = ''
|
5
|
+
Secrets.auth_credentials.keys.each do |auth|
|
6
|
+
list << %Q{<li class="#{auth_css_class(auth)} auth_service service-link" #{auth_icon_back(auth, include_icons)} title="#{auth_title(auth)}">#{auth_link(auth)}</li>}
|
7
|
+
end
|
8
|
+
list.html_safe
|
9
|
+
end
|
10
|
+
|
11
|
+
def auth_icon_back(auth, include_icons = true)
|
12
|
+
if include_icons
|
13
|
+
icon = service_icon_background(auth)
|
14
|
+
else
|
15
|
+
icon = ''
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def auth_link(auth)
|
20
|
+
link_to(auth.titleize, "/auth/#{auth}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def auth_name(auth)
|
24
|
+
auth.titleize
|
25
|
+
end
|
2
26
|
|
3
|
-
|
4
|
-
|
27
|
+
def auth_title(auth)
|
28
|
+
translate('muck.auth.connect_to_account_title', :service => auth.to_s.humanize)
|
29
|
+
end
|
5
30
|
|
6
|
-
def
|
7
|
-
|
31
|
+
def auth_css_class(auth)
|
32
|
+
auth.to_s.parameterize
|
8
33
|
end
|
9
34
|
|
10
35
|
end
|
@@ -1,12 +1,8 @@
|
|
1
1
|
<div id="auth_available_services" class="auth-services">
|
2
|
-
<% unless
|
2
|
+
<% unless Secrets.auth_credentials.empty? %>
|
3
3
|
<h3><%=translate('muck.auth.you_can_connect_to_the_following_services') %></h3>
|
4
|
-
<ul <%='class="icon-list"' if include_icons%>>
|
5
|
-
|
6
|
-
<li class="<%=authentication.to_s.parameterize%> auth_service service-link" <%= service_icon_background(authentication) if include_icons%> title="<%=translate('muck.auth.connect_to_account_title', :service => authentication.to_s.humanize) %>">
|
7
|
-
<%= link_to auth_service_name(authentication), "/auth/#{authentication}" %>
|
8
|
-
</li>
|
9
|
-
<% end -%>
|
4
|
+
<ul <%='class="icon-list"'.html_safe if include_icons%>>
|
5
|
+
<%= auth_list(include_icons) %>
|
10
6
|
</ul>
|
11
7
|
<% end %>
|
12
8
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<ul <%='class="icon-list"' if include_icons%>>
|
7
7
|
<% authentications.each do |authentication| -%>
|
8
8
|
<li class="<%=token.class.service_name.to_s.parameterize%> oauth_service service-link" <%= service_icon_background(token.class.service_name) if include_icons %>>
|
9
|
-
<%= link_to
|
9
|
+
<%= link_to auth_name(authentication.provider), oauth_consumer_path(token.class.service_name), :class => 'authfancybox' %>
|
10
10
|
<%= link_to "X", authentication, :confirm => 'Are you sure you want to remove this authentication option?', :method => :delete, :class => "remove" %>
|
11
11
|
</li>
|
12
12
|
<% end -%>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateAuthentications < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :authentications do |t|
|
4
|
+
t.integer :authenticatable_id
|
5
|
+
t.string :authenticatable_type
|
6
|
+
t.string :provider
|
7
|
+
t.string :uid
|
8
|
+
t.string :name
|
9
|
+
t.string :nickname
|
10
|
+
t.string :token
|
11
|
+
t.string :secret
|
12
|
+
t.text :raw_auth
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
add_index :authentications, [:authenticatable_id, :authenticatable_type], :name => 'authenticatable'
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.down
|
19
|
+
drop_table :authentications
|
20
|
+
end
|
21
|
+
end
|
data/lib/muck-auth/config.rb
CHANGED
data/lib/muck-auth/engine.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rails'
|
|
2
2
|
require 'omniauth/oauth'
|
3
3
|
require 'muck-auth'
|
4
4
|
|
5
|
-
module
|
5
|
+
module MuckAuth
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
|
8
8
|
def muck_name
|
@@ -22,12 +22,12 @@ module MuckProfiles
|
|
22
22
|
end
|
23
23
|
|
24
24
|
initializer "muck_auth.add_middleware" do |app|
|
25
|
-
raise MuckAuth::Exceptions::InvalidConfiguration, "Please provide a valid configuration for Muck Auth." if
|
26
|
-
|
27
|
-
|
28
|
-
provider key,
|
25
|
+
raise MuckAuth::Exceptions::InvalidConfiguration, "Please provide a valid configuration for Muck Auth." if Secrets.auth_credentials.blank?
|
26
|
+
Secrets.auth_credentials.each_key do |key|
|
27
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
28
|
+
provider key, Secrets.auth_credentials[key]['key'], Secrets.auth_credentials[key]['secret']
|
29
29
|
end
|
30
|
-
end
|
30
|
+
end
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
@@ -5,21 +5,23 @@ module MuckAuth
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
belongs_to :
|
8
|
+
belongs_to :authenticatable, :polymorphic => true
|
9
9
|
end
|
10
10
|
|
11
11
|
module ClassMethods
|
12
|
+
|
12
13
|
def all_services
|
13
14
|
services = []
|
14
|
-
|
15
|
+
Secrets.auth_credentials.each_key{ |s| services << s }
|
15
16
|
services
|
16
17
|
end
|
18
|
+
|
17
19
|
def unused_services(current_authentications)
|
18
20
|
all_services.find_all{ |s| !current_authentications.any?{ |c| c.provider == s } }
|
19
21
|
end
|
22
|
+
|
20
23
|
end
|
21
24
|
|
22
25
|
end
|
23
26
|
end
|
24
|
-
end
|
25
|
-
|
27
|
+
end
|
data/muck-auth.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{muck-auth}
|
8
|
-
s.version = "3.
|
8
|
+
s.version = "3.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Ball"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-02-16}
|
13
13
|
s.description = %q{A simple wrapper for the omniauth gem so that it is faster to include oauth in muck based applications.}
|
14
14
|
s.email = %q{justin@tatemae.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"app/views/authentications/signup.html.erb",
|
32
32
|
"config/locales/en.yml",
|
33
33
|
"config/routes.rb",
|
34
|
+
"db/migrate/20110216045051_create_authentications.rb",
|
34
35
|
"lib/muck-auth.rb",
|
35
36
|
"lib/muck-auth/config.rb",
|
36
37
|
"lib/muck-auth/engine.rb",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muck-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 3.
|
10
|
+
version: 3.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Ball
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-16 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- app/views/authentications/signup.html.erb
|
113
113
|
- config/locales/en.yml
|
114
114
|
- config/routes.rb
|
115
|
+
- db/migrate/20110216045051_create_authentications.rb
|
115
116
|
- lib/muck-auth.rb
|
116
117
|
- lib/muck-auth/config.rb
|
117
118
|
- lib/muck-auth/engine.rb
|