devise-token_authenticatable 0.1.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. data/.gitignore +21 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +20 -0
  4. data/README.md +31 -0
  5. data/Rakefile +1 -0
  6. data/devise-token_authenticatable.gemspec +36 -0
  7. data/lib/devise-token_authenticatable.rb +1 -0
  8. data/lib/devise/token_authenticatable.rb +27 -0
  9. data/lib/devise/token_authenticatable/model.rb +90 -0
  10. data/lib/devise/token_authenticatable/strategy.rb +102 -0
  11. data/lib/devise/token_authenticatable/version.rb +5 -0
  12. data/spec/factories/admin.rb +24 -0
  13. data/spec/factories/user.rb +25 -0
  14. data/spec/models/devise/token_authenticatable/model_spec.rb +79 -0
  15. data/spec/requests/devise/token_authenticatable/strategy_spec.rb +340 -0
  16. data/spec/spec_helper.rb +42 -0
  17. data/spec/support/helpers.rb +33 -0
  18. data/spec/support/integration.rb +8 -0
  19. data/spec/support/rails_app.rb +19 -0
  20. data/spec/support/rails_app/Rakefile +6 -0
  21. data/spec/support/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
  22. data/spec/support/rails_app/app/controllers/admins_controller.rb +11 -0
  23. data/spec/support/rails_app/app/controllers/application_controller.rb +9 -0
  24. data/spec/support/rails_app/app/controllers/home_controller.rb +25 -0
  25. data/spec/support/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  26. data/spec/support/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  27. data/spec/support/rails_app/app/controllers/users_controller.rb +31 -0
  28. data/spec/support/rails_app/app/mailers/users/mailer.rb +12 -0
  29. data/spec/support/rails_app/app/models/admin.rb +9 -0
  30. data/spec/support/rails_app/app/models/user.rb +25 -0
  31. data/spec/support/rails_app/app/views/users/index.html.erb +1 -0
  32. data/spec/support/rails_app/config.ru +4 -0
  33. data/spec/support/rails_app/config/database.yml +11 -0
  34. data/spec/support/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  35. data/spec/support/rails_app/config/initializers/devise.rb +173 -0
  36. data/spec/support/rails_app/config/initializers/inflections.rb +2 -0
  37. data/spec/support/rails_app/config/initializers/secret_token.rb +4 -0
  38. data/spec/support/rails_app/config/routes.rb +104 -0
  39. data/spec/support/rails_app/db/migrate/20100401102949_create_tables.rb +74 -0
  40. data/spec/support/rails_app/db/schema.rb +52 -0
  41. data/spec/support/rails_app/public/404.html +26 -0
  42. data/spec/support/rails_app/public/422.html +26 -0
  43. data/spec/support/rails_app/public/500.html +26 -0
  44. data/spec/support/rails_app/public/favicon.ico +0 -0
  45. data/spec/support/session_helper.rb +27 -0
  46. metadata +289 -0
@@ -0,0 +1,74 @@
1
+ class CreateTables < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :username
5
+ t.string :facebook_token
6
+
7
+ ## Database authenticatable
8
+ t.string :email, :null => false, :default => ""
9
+ t.string :encrypted_password, :null => false, :default => ""
10
+
11
+ ## Recoverable
12
+ t.string :reset_password_token
13
+ t.datetime :reset_password_sent_at
14
+
15
+ ## Rememberable
16
+ t.datetime :remember_created_at
17
+
18
+ ## Trackable
19
+ t.integer :sign_in_count, :default => 0
20
+ t.datetime :current_sign_in_at
21
+ t.datetime :last_sign_in_at
22
+ t.string :current_sign_in_ip
23
+ t.string :last_sign_in_ip
24
+
25
+ ## Confirmable
26
+ t.string :confirmation_token
27
+ t.datetime :confirmed_at
28
+ t.datetime :confirmation_sent_at
29
+ # t.string :unconfirmed_email # Only if using reconfirmable
30
+
31
+ ## Lockable
32
+ t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
33
+ t.string :unlock_token # Only if unlock strategy is :email or :both
34
+ t.datetime :locked_at
35
+
36
+ ## Token authenticatable
37
+ t.string :authentication_token
38
+
39
+ t.timestamps
40
+ end
41
+
42
+ create_table :admins do |t|
43
+ ## Database authenticatable
44
+ t.string :email, :null => true
45
+ t.string :encrypted_password, :null => true
46
+
47
+ ## Recoverable
48
+ t.string :reset_password_token
49
+ t.datetime :reset_password_sent_at
50
+
51
+ ## Rememberable
52
+ t.datetime :remember_created_at
53
+
54
+ ## Confirmable
55
+ t.string :confirmation_token
56
+ t.datetime :confirmed_at
57
+ t.datetime :confirmation_sent_at
58
+ t.string :unconfirmed_email # Only if using reconfirmable
59
+
60
+ ## Lockable
61
+ t.datetime :locked_at
62
+
63
+ ## Attribute for testing route blocks
64
+ t.boolean :active, :default => false
65
+
66
+ t.timestamps
67
+ end
68
+ end
69
+
70
+ def self.down
71
+ drop_table :users
72
+ drop_table :admins
73
+ end
74
+ end
@@ -0,0 +1,52 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20100401102949) do
14
+
15
+ create_table "admins", :force => true do |t|
16
+ t.string "email"
17
+ t.string "encrypted_password", :limit => 128
18
+ t.string "password_salt"
19
+ t.string "remember_token"
20
+ t.datetime "remember_created_at"
21
+ t.string "reset_password_token"
22
+ t.integer "failed_attempts", :default => 0
23
+ t.string "unlock_token"
24
+ t.datetime "locked_at"
25
+ t.datetime "created_at"
26
+ t.datetime "updated_at"
27
+ end
28
+
29
+ create_table "users", :force => true do |t|
30
+ t.string "username"
31
+ t.string "facebook_token"
32
+ t.string "email", :default => "", :null => false
33
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
34
+ t.string "confirmation_token"
35
+ t.datetime "confirmed_at"
36
+ t.datetime "confirmation_sent_at"
37
+ t.string "reset_password_token"
38
+ t.datetime "remember_created_at"
39
+ t.integer "sign_in_count", :default => 0
40
+ t.datetime "current_sign_in_at"
41
+ t.datetime "last_sign_in_at"
42
+ t.string "current_sign_in_ip"
43
+ t.string "last_sign_in_ip"
44
+ t.integer "failed_attempts", :default => 0
45
+ t.string "unlock_token"
46
+ t.datetime "locked_at"
47
+ t.string "authentication_token"
48
+ t.datetime "created_at"
49
+ t.datetime "updated_at"
50
+ end
51
+
52
+ end
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,27 @@
1
+ # Helper methods for user sign in with
2
+ # authentication token.
3
+ #
4
+
5
+ # Signs in a user via different methods (i.e., HTTP AUTH,
6
+ # Token Auth, plain). If no user is given with the +options+
7
+ # a new one is created.
8
+ #
9
+ def sign_in_as_new_user_with_token(options = {})
10
+ user = options.delete(:user) || create(:user, :with_authentication_token)
11
+
12
+ options[:auth_token_key] ||= Devise::TokenAuthenticatable.token_authentication_key
13
+ options[:auth_token] ||= user.authentication_token
14
+
15
+ if options[:http_auth]
16
+ header = "Basic #{Base64.encode64("#{options[:auth_token]}:X")}"
17
+ get users_path(format: :xml), {}, "HTTP_AUTHORIZATION" => header
18
+ elsif options[:token_auth]
19
+ token_options = options[:token_options] || {}
20
+ header = ActionController::HttpAuthentication::Token.encode_credentials(options[:auth_token], token_options)
21
+ get users_path(format: :xml), {}, "HTTP_AUTHORIZATION" => header
22
+ else
23
+ get users_path(options[:auth_token_key].to_sym => options[:auth_token])
24
+ end
25
+
26
+ user
27
+ end
metadata ADDED
@@ -0,0 +1,289 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise-token_authenticatable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.beta1
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Sebastian Oelke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: devise
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: activerecord
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3.2'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '3.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: actionmailer
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '3.2'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec-rails
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: pry
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: factory_girl_rails
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: timecop
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: sqlite3
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '1.3'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '1.3'
142
+ - !ruby/object:Gem::Dependency
143
+ name: bundler
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: '1.3'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: '1.3'
158
+ - !ruby/object:Gem::Dependency
159
+ name: rake
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ description: ! "This gem provides the extracted Token Authenticatable module of devise.\n
175
+ \ It enables the user to sign in via an authentication token.
176
+ This token\n can be given via a query string or HTTP Basic
177
+ Authentication."
178
+ email:
179
+ - dev@sohleeatsworld.de
180
+ executables: []
181
+ extensions: []
182
+ extra_rdoc_files: []
183
+ files:
184
+ - .gitignore
185
+ - Gemfile
186
+ - LICENSE
187
+ - README.md
188
+ - Rakefile
189
+ - devise-token_authenticatable.gemspec
190
+ - lib/devise-token_authenticatable.rb
191
+ - lib/devise/token_authenticatable.rb
192
+ - lib/devise/token_authenticatable/model.rb
193
+ - lib/devise/token_authenticatable/strategy.rb
194
+ - lib/devise/token_authenticatable/version.rb
195
+ - spec/factories/admin.rb
196
+ - spec/factories/user.rb
197
+ - spec/models/devise/token_authenticatable/model_spec.rb
198
+ - spec/requests/devise/token_authenticatable/strategy_spec.rb
199
+ - spec/spec_helper.rb
200
+ - spec/support/helpers.rb
201
+ - spec/support/integration.rb
202
+ - spec/support/rails_app.rb
203
+ - spec/support/rails_app/Rakefile
204
+ - spec/support/rails_app/app/controllers/admins/sessions_controller.rb
205
+ - spec/support/rails_app/app/controllers/admins_controller.rb
206
+ - spec/support/rails_app/app/controllers/application_controller.rb
207
+ - spec/support/rails_app/app/controllers/home_controller.rb
208
+ - spec/support/rails_app/app/controllers/publisher/registrations_controller.rb
209
+ - spec/support/rails_app/app/controllers/publisher/sessions_controller.rb
210
+ - spec/support/rails_app/app/controllers/users_controller.rb
211
+ - spec/support/rails_app/app/mailers/users/mailer.rb
212
+ - spec/support/rails_app/app/models/admin.rb
213
+ - spec/support/rails_app/app/models/user.rb
214
+ - spec/support/rails_app/app/views/users/index.html.erb
215
+ - spec/support/rails_app/config.ru
216
+ - spec/support/rails_app/config/database.yml
217
+ - spec/support/rails_app/config/initializers/backtrace_silencers.rb
218
+ - spec/support/rails_app/config/initializers/devise.rb
219
+ - spec/support/rails_app/config/initializers/inflections.rb
220
+ - spec/support/rails_app/config/initializers/secret_token.rb
221
+ - spec/support/rails_app/config/routes.rb
222
+ - spec/support/rails_app/db/migrate/20100401102949_create_tables.rb
223
+ - spec/support/rails_app/db/schema.rb
224
+ - spec/support/rails_app/public/404.html
225
+ - spec/support/rails_app/public/422.html
226
+ - spec/support/rails_app/public/500.html
227
+ - spec/support/rails_app/public/favicon.ico
228
+ - spec/support/session_helper.rb
229
+ homepage: https://github.com/baschtl/devise-token_authenticatable
230
+ licenses:
231
+ - MIT
232
+ post_install_message:
233
+ rdoc_options: []
234
+ require_paths:
235
+ - lib
236
+ required_ruby_version: !ruby/object:Gem::Requirement
237
+ none: false
238
+ requirements:
239
+ - - ! '>='
240
+ - !ruby/object:Gem::Version
241
+ version: '0'
242
+ required_rubygems_version: !ruby/object:Gem::Requirement
243
+ none: false
244
+ requirements:
245
+ - - ! '>'
246
+ - !ruby/object:Gem::Version
247
+ version: 1.3.1
248
+ requirements: []
249
+ rubyforge_project:
250
+ rubygems_version: 1.8.23
251
+ signing_key:
252
+ specification_version: 3
253
+ summary: Provides authentication based on an authentication token for devise 3.2 and
254
+ up.
255
+ test_files:
256
+ - spec/factories/admin.rb
257
+ - spec/factories/user.rb
258
+ - spec/models/devise/token_authenticatable/model_spec.rb
259
+ - spec/requests/devise/token_authenticatable/strategy_spec.rb
260
+ - spec/spec_helper.rb
261
+ - spec/support/helpers.rb
262
+ - spec/support/integration.rb
263
+ - spec/support/rails_app.rb
264
+ - spec/support/rails_app/Rakefile
265
+ - spec/support/rails_app/app/controllers/admins/sessions_controller.rb
266
+ - spec/support/rails_app/app/controllers/admins_controller.rb
267
+ - spec/support/rails_app/app/controllers/application_controller.rb
268
+ - spec/support/rails_app/app/controllers/home_controller.rb
269
+ - spec/support/rails_app/app/controllers/publisher/registrations_controller.rb
270
+ - spec/support/rails_app/app/controllers/publisher/sessions_controller.rb
271
+ - spec/support/rails_app/app/controllers/users_controller.rb
272
+ - spec/support/rails_app/app/mailers/users/mailer.rb
273
+ - spec/support/rails_app/app/models/admin.rb
274
+ - spec/support/rails_app/app/models/user.rb
275
+ - spec/support/rails_app/app/views/users/index.html.erb
276
+ - spec/support/rails_app/config.ru
277
+ - spec/support/rails_app/config/database.yml
278
+ - spec/support/rails_app/config/initializers/backtrace_silencers.rb
279
+ - spec/support/rails_app/config/initializers/devise.rb
280
+ - spec/support/rails_app/config/initializers/inflections.rb
281
+ - spec/support/rails_app/config/initializers/secret_token.rb
282
+ - spec/support/rails_app/config/routes.rb
283
+ - spec/support/rails_app/db/migrate/20100401102949_create_tables.rb
284
+ - spec/support/rails_app/db/schema.rb
285
+ - spec/support/rails_app/public/404.html
286
+ - spec/support/rails_app/public/422.html
287
+ - spec/support/rails_app/public/500.html
288
+ - spec/support/rails_app/public/favicon.ico
289
+ - spec/support/session_helper.rb