sinatra_omniauth 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.document +5 -0
  2. data/Gemfile +17 -0
  3. data/Gemfile.lock +108 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +111 -0
  6. data/Rakefile +53 -0
  7. data/VERSION +1 -0
  8. data/config.ru +25 -0
  9. data/css/auth.css +47 -0
  10. data/lib/models/authorization.rb +16 -0
  11. data/lib/models/user.rb +14 -0
  12. data/lib/sinatra/omniauth.rb +273 -0
  13. data/models/authentication.rb +12 -0
  14. data/models/user.rb +12 -0
  15. data/omniauth.yml +71 -0
  16. data/public/css/omniauth.css +34 -0
  17. data/public/images/authbuttons/aol_128.png +0 -0
  18. data/public/images/authbuttons/aol_256.png +0 -0
  19. data/public/images/authbuttons/aol_32.png +0 -0
  20. data/public/images/authbuttons/aol_64.png +0 -0
  21. data/public/images/authbuttons/basecamp_128.png +0 -0
  22. data/public/images/authbuttons/basecamp_256.png +0 -0
  23. data/public/images/authbuttons/basecamp_32.png +0 -0
  24. data/public/images/authbuttons/basecamp_64.png +0 -0
  25. data/public/images/authbuttons/campfire_128.png +0 -0
  26. data/public/images/authbuttons/campfire_256.png +0 -0
  27. data/public/images/authbuttons/campfire_32.png +0 -0
  28. data/public/images/authbuttons/campfire_64.png +0 -0
  29. data/public/images/authbuttons/facebook_128.png +0 -0
  30. data/public/images/authbuttons/facebook_256.png +0 -0
  31. data/public/images/authbuttons/facebook_32.png +0 -0
  32. data/public/images/authbuttons/facebook_64.png +0 -0
  33. data/public/images/authbuttons/github_128.png +0 -0
  34. data/public/images/authbuttons/github_256.png +0 -0
  35. data/public/images/authbuttons/github_32.png +0 -0
  36. data/public/images/authbuttons/github_64.png +0 -0
  37. data/public/images/authbuttons/google_128.png +0 -0
  38. data/public/images/authbuttons/google_256.png +0 -0
  39. data/public/images/authbuttons/google_32.png +0 -0
  40. data/public/images/authbuttons/google_64.png +0 -0
  41. data/public/images/authbuttons/linkedin_128.png +0 -0
  42. data/public/images/authbuttons/linkedin_256.png +0 -0
  43. data/public/images/authbuttons/linkedin_32.png +0 -0
  44. data/public/images/authbuttons/linkedin_64.png +0 -0
  45. data/public/images/authbuttons/myspace_128.png +0 -0
  46. data/public/images/authbuttons/myspace_256.png +0 -0
  47. data/public/images/authbuttons/myspace_32.png +0 -0
  48. data/public/images/authbuttons/myspace_64.png +0 -0
  49. data/public/images/authbuttons/openid_128.png +0 -0
  50. data/public/images/authbuttons/openid_256.png +0 -0
  51. data/public/images/authbuttons/openid_32.png +0 -0
  52. data/public/images/authbuttons/openid_64.png +0 -0
  53. data/public/images/authbuttons/presently_128.png +0 -0
  54. data/public/images/authbuttons/presently_256.png +0 -0
  55. data/public/images/authbuttons/presently_32.png +0 -0
  56. data/public/images/authbuttons/presently_64.png +0 -0
  57. data/public/images/authbuttons/twitter_128.png +0 -0
  58. data/public/images/authbuttons/twitter_256.png +0 -0
  59. data/public/images/authbuttons/twitter_32.png +0 -0
  60. data/public/images/authbuttons/twitter_64.png +0 -0
  61. data/public/images/authbuttons/yahoo_128.png +0 -0
  62. data/public/images/authbuttons/yahoo_256.png +0 -0
  63. data/public/images/authbuttons/yahoo_32.png +0 -0
  64. data/public/images/authbuttons/yahoo_64.png +0 -0
  65. data/sinatra_omniauth.gemspec +137 -0
  66. data/test/helper.rb +18 -0
  67. data/test/test_sinatra_omniauth.rb +7 -0
  68. data/views/auth.haml +62 -0
  69. metadata +292 -0
@@ -0,0 +1,12 @@
1
+ class Authentication
2
+ include DataMapper::Resource
3
+
4
+ belongs_to :user
5
+
6
+ property :id, Serial
7
+ property :user_id, Integer
8
+ property :provider, String
9
+ property :uid, String
10
+ property :user_name, String
11
+ property :user_email, String
12
+ end
@@ -0,0 +1,12 @@
1
+ class User
2
+ include DataMapper::Resource
3
+
4
+ devise :registerable, # handles signing up users through a registration process, also edit/destroy account.
5
+ :rememberable, # "Remember me" from a cookie
6
+ :trackable # Tracks sign in count, timestamps and IP address
7
+
8
+ property :id, Serial
9
+
10
+ # Each user may log in using different methods:
11
+ has n, :authentications
12
+ end
@@ -0,0 +1,71 @@
1
+ # Using an array means we can control the order of display of the authentication methods:
2
+ -
3
+ provider: twitter
4
+ name: Twitter
5
+ key: --- enter your key here ---
6
+ secret: --- enter your secret here ---
7
+
8
+ -
9
+ provider: facebook
10
+ # Facebook registration: https://www.facebook.com/developers/apps.php?app_id=216576775042338
11
+ name: Facebook
12
+ key: "--- enter your key here ---"
13
+ secret: --- enter your secret here ---
14
+ client_options:
15
+ ssl:
16
+ ca_file: /opt/local/etc/ssl/certs/ca-certificates.crt
17
+
18
+ -
19
+ provider: google
20
+ name: Google Apps
21
+ store: ./tmp
22
+ key: "--- enter your key here ---"
23
+ secret: --- enter your secret here ---
24
+
25
+ -
26
+ provider: linked_in
27
+ name: LinkedIn
28
+ key: --- enter your key here ---
29
+ secret: --- enter your secret here ---
30
+ api_key: --- enter your API key here ---
31
+
32
+ -
33
+ # Github: https://github.com/account/applications/new
34
+ provider: github
35
+ name: GitHub
36
+ key: --- enter your key here ---
37
+ secret: --- enter your secret here ---
38
+
39
+ -
40
+ provider: openid
41
+ # Generic OpenID:
42
+ name: OpenID
43
+ store: ./tmp
44
+ key: --- enter your key here ---
45
+ secret: --- enter your secret here ---
46
+
47
+
48
+ -
49
+ provider: openid
50
+ name: MyOpenID
51
+ store: ./tmp
52
+ identifier: 'myopenid.com'
53
+ key: --- enter your key here ---
54
+ secret: --- enter your secret here ---
55
+
56
+
57
+ -
58
+ provider: openid
59
+ name: Yahoo
60
+ identifier: 'yahoo.com'
61
+ key: --- enter your key here ---
62
+ secret: --- enter your secret here ---
63
+
64
+
65
+ -
66
+ provider: openid
67
+ name: AOL
68
+ identifier: 'openid.aol.com'
69
+ key: --- enter your key here ---
70
+ secret: --- enter your secret here ---
71
+
@@ -0,0 +1,34 @@
1
+ /* Authentication "badge" */
2
+ .authentication {
3
+ position: relative;
4
+ display: inline-block;
5
+ padding: 0.2em 2em 0.2em 0.5em;
6
+ background-color: #EEE;
7
+ border-radius: 0.5em; border: 2px black;
8
+ -webkit-box-shadow: 0 0 5px #000; -moz-box-shadow: 0 0 5px #000; box-shadow: 0 0 5px #000;
9
+ }
10
+ .authentication {
11
+ background-repeat: no-repeat;
12
+ background-position: left center;
13
+ }
14
+ .authentication * {
15
+ margin-left: 32px;
16
+ }
17
+ .authentication .provider {
18
+ font-weight: bold;
19
+ }
20
+ .authentication a { /* The X to delete this authentication method */
21
+ position: absolute;
22
+ right: 0.3em;
23
+ top: 0px;
24
+ }
25
+
26
+ /* Alternate auth providers */
27
+ .auth_provider {
28
+ position: relative;
29
+ display: inline-block;
30
+ text-align: center;
31
+ }
32
+ .auth_provider * {
33
+ display:block;
34
+ }
@@ -0,0 +1,137 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{sinatra_omniauth}
8
+ s.version = "0.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Clifford Heath}]
12
+ s.date = %q{2011-08-05}
13
+ s.description = %q{This Sinatra extension, derived from omniauth_pure by Marcus Proske, adds OmniAuth authorization to your Sinatra application, so your users can login using FaceBook, Twitter and many other authorization providers, as long as you supply the API keys. It uses DataMapper and HAML.}
14
+ s.email = %q{clifford.heath@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "config.ru",
28
+ "css/auth.css",
29
+ "lib/models/authorization.rb",
30
+ "lib/models/user.rb",
31
+ "lib/sinatra/omniauth.rb",
32
+ "models/authentication.rb",
33
+ "models/user.rb",
34
+ "omniauth.yml",
35
+ "public/css/omniauth.css",
36
+ "public/images/authbuttons/aol_128.png",
37
+ "public/images/authbuttons/aol_256.png",
38
+ "public/images/authbuttons/aol_32.png",
39
+ "public/images/authbuttons/aol_64.png",
40
+ "public/images/authbuttons/basecamp_128.png",
41
+ "public/images/authbuttons/basecamp_256.png",
42
+ "public/images/authbuttons/basecamp_32.png",
43
+ "public/images/authbuttons/basecamp_64.png",
44
+ "public/images/authbuttons/campfire_128.png",
45
+ "public/images/authbuttons/campfire_256.png",
46
+ "public/images/authbuttons/campfire_32.png",
47
+ "public/images/authbuttons/campfire_64.png",
48
+ "public/images/authbuttons/facebook_128.png",
49
+ "public/images/authbuttons/facebook_256.png",
50
+ "public/images/authbuttons/facebook_32.png",
51
+ "public/images/authbuttons/facebook_64.png",
52
+ "public/images/authbuttons/github_128.png",
53
+ "public/images/authbuttons/github_256.png",
54
+ "public/images/authbuttons/github_32.png",
55
+ "public/images/authbuttons/github_64.png",
56
+ "public/images/authbuttons/google_128.png",
57
+ "public/images/authbuttons/google_256.png",
58
+ "public/images/authbuttons/google_32.png",
59
+ "public/images/authbuttons/google_64.png",
60
+ "public/images/authbuttons/linkedin_128.png",
61
+ "public/images/authbuttons/linkedin_256.png",
62
+ "public/images/authbuttons/linkedin_32.png",
63
+ "public/images/authbuttons/linkedin_64.png",
64
+ "public/images/authbuttons/myspace_128.png",
65
+ "public/images/authbuttons/myspace_256.png",
66
+ "public/images/authbuttons/myspace_32.png",
67
+ "public/images/authbuttons/myspace_64.png",
68
+ "public/images/authbuttons/openid_128.png",
69
+ "public/images/authbuttons/openid_256.png",
70
+ "public/images/authbuttons/openid_32.png",
71
+ "public/images/authbuttons/openid_64.png",
72
+ "public/images/authbuttons/presently_128.png",
73
+ "public/images/authbuttons/presently_256.png",
74
+ "public/images/authbuttons/presently_32.png",
75
+ "public/images/authbuttons/presently_64.png",
76
+ "public/images/authbuttons/twitter_128.png",
77
+ "public/images/authbuttons/twitter_256.png",
78
+ "public/images/authbuttons/twitter_32.png",
79
+ "public/images/authbuttons/twitter_64.png",
80
+ "public/images/authbuttons/yahoo_128.png",
81
+ "public/images/authbuttons/yahoo_256.png",
82
+ "public/images/authbuttons/yahoo_32.png",
83
+ "public/images/authbuttons/yahoo_64.png",
84
+ "sinatra_omniauth.gemspec",
85
+ "test/helper.rb",
86
+ "test/test_sinatra_omniauth.rb",
87
+ "views/auth.haml"
88
+ ]
89
+ s.homepage = %q{http://github.com/cjheath/sinatra_omniauth}
90
+ s.licenses = [%q{MIT}]
91
+ s.require_paths = [%q{lib}]
92
+ s.rubygems_version = %q{1.8.5}
93
+ s.summary = %q{A Sinatra extension that provides pure OmniAuth goodness to your application (with DataMapper)}
94
+
95
+ if s.respond_to? :specification_version then
96
+ s.specification_version = 3
97
+
98
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
99
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
100
+ s.add_runtime_dependency(%q<omniauth>, [">= 0"])
101
+ s.add_runtime_dependency(%q<dm-core>, [">= 0"])
102
+ s.add_runtime_dependency(%q<dm-migrations>, [">= 0"])
103
+ s.add_runtime_dependency(%q<dm-postgres-adapter>, [">= 0"])
104
+ s.add_runtime_dependency(%q<sqlite3>, [">= 0"])
105
+ s.add_runtime_dependency(%q<rack-flash>, [">= 0"])
106
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
107
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
108
+ s.add_development_dependency(%q<rcov>, [">= 0"])
109
+ s.add_development_dependency(%q<rdoc>, [">= 2.4.0"])
110
+ else
111
+ s.add_dependency(%q<sinatra>, [">= 0"])
112
+ s.add_dependency(%q<omniauth>, [">= 0"])
113
+ s.add_dependency(%q<dm-core>, [">= 0"])
114
+ s.add_dependency(%q<dm-migrations>, [">= 0"])
115
+ s.add_dependency(%q<dm-postgres-adapter>, [">= 0"])
116
+ s.add_dependency(%q<sqlite3>, [">= 0"])
117
+ s.add_dependency(%q<rack-flash>, [">= 0"])
118
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
119
+ s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
120
+ s.add_dependency(%q<rcov>, [">= 0"])
121
+ s.add_dependency(%q<rdoc>, [">= 2.4.0"])
122
+ end
123
+ else
124
+ s.add_dependency(%q<sinatra>, [">= 0"])
125
+ s.add_dependency(%q<omniauth>, [">= 0"])
126
+ s.add_dependency(%q<dm-core>, [">= 0"])
127
+ s.add_dependency(%q<dm-migrations>, [">= 0"])
128
+ s.add_dependency(%q<dm-postgres-adapter>, [">= 0"])
129
+ s.add_dependency(%q<sqlite3>, [">= 0"])
130
+ s.add_dependency(%q<rack-flash>, [">= 0"])
131
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
132
+ s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
133
+ s.add_dependency(%q<rcov>, [">= 0"])
134
+ s.add_dependency(%q<rdoc>, [">= 2.4.0"])
135
+ end
136
+ end
137
+
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'sinatra_omniauth'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestSinatraOmniauth < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,62 @@
1
+ !!!
2
+ %html(lang="en-au")
3
+ %head
4
+ %meta(charset="utf-8")
5
+ = include_stylesheets :auth
6
+ = include_javascripts :jquery
7
+ %title APRIMO Sign In
8
+
9
+ %body
10
+ .authentications
11
+ - if current_user
12
+ %section.current
13
+ = current_auth.user_name+','
14
+ you are currently signed in using your
15
+ .authentication.current{:style=>"background-image: url(/images/authbuttons/#{@authentication_current.provider}_32.png)"}
16
+ .provider= @authentication_current.provider.titleize
17
+ .uid= @authentication_current.uid
18
+ account.
19
+ %section.logout
20
+ %a.signout{:href=>'/auth/signout'}Click here
21
+ to sign out.
22
+ %section.alternatives
23
+ - if @authentications_available.size > 1
24
+ .clear
25
+ You can switch to being signed in using one of your other accounts:
26
+ - @authentications_unused.each do |a|
27
+ .authentication.available{:style=>"background-image: url(/images/authbuttons/#{a.provider}_32.png)",:onclick=>"location = '/auth/#{a.provider}';"}
28
+ .provider= a.provider.titleize
29
+ .uid= a.uid
30
+ %a.remove{:href=>"/auth/#{a.id}", :method => :delete, :rel => 'nofollow', :'data-confirm' => 'Are you sure you want to remove this authentication option?'} x
31
+ %section.join
32
+ - if current_user
33
+ - if @authentications_possible.size > 0
34
+ .clear
35
+ You may add one of the following as an alternative way to log in:
36
+ - else
37
+ Sign in or join using any of your existing accounts:
38
+
39
+ - if @authentications_possible.size > 0
40
+ .clear
41
+ - @authentications_possible.each do |authentication|
42
+ .authentication{:style=>"background-image: url(/images/authbuttons/#{authentication['provider']}_32.png)",:onclick=>"location = '/auth/#{authentication['provider']}';"}
43
+ .provider= authentication['name']
44
+ - if !current_user
45
+ %p.clear
46
+ Don't have any of these accounts? Get your
47
+ %a{href='http://www.myopenid.com/'} MyOpenID
48
+ or
49
+ %a{href='http://mail.google.com/mail/signup'} GoogleID
50
+ now!
51
+ If you want to learn more about OpenID or find more OpenID providers,
52
+ you can get more information at
53
+ %a{href='http://myopenid.net/'} openid.net
54
+
55
+ %script{:type=>'text/javascript'}
56
+ $(document).ready(function() {
57
+ $('.remove').click(function() { if (confirm($(this).attr('data-confirm'))) {
58
+ var f = document.createElement('form');
59
+ f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;
60
+ var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method');
61
+ m.setAttribute('value', 'delete'); f.appendChild(m);f.submit();
62
+ };return false;});});