cz_auth 0.0.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +45 -0
  3. data/Rakefile +9 -15
  4. data/app/controllers/cz_auth/application_controller.rb +1 -22
  5. data/app/controllers/cz_auth/authentication_controller.rb +26 -0
  6. data/app/controllers/cz_auth/concerns/authentication.rb +118 -0
  7. data/app/views/cz_auth/authentication/create.json.erb +4 -0
  8. data/app/views/cz_auth/authentication/invalid.json +1 -0
  9. data/config/environment.rb +1 -0
  10. data/config/routes.rb +3 -11
  11. data/lib/cz_auth.rb +1 -4
  12. data/lib/cz_auth/engine.rb +6 -0
  13. data/lib/cz_auth/requires_authentication.rb +39 -8
  14. data/lib/cz_auth/version.rb +1 -1
  15. data/lib/generators/cz_auth/install_generator.rb +1 -1
  16. data/spec/dummy/README.rdoc +28 -0
  17. data/spec/dummy/Rakefile +6 -0
  18. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  19. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  20. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  21. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  22. data/spec/dummy/app/models/user.rb +3 -0
  23. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  24. data/spec/dummy/bin/bundle +3 -0
  25. data/spec/dummy/bin/rails +4 -0
  26. data/spec/dummy/bin/rake +4 -0
  27. data/spec/dummy/config.ru +4 -0
  28. data/spec/dummy/config/application.rb +28 -0
  29. data/spec/dummy/config/boot.rb +5 -0
  30. data/spec/dummy/config/database.yml +13 -0
  31. data/spec/dummy/config/environment.rb +5 -0
  32. data/spec/dummy/config/environments/development.rb +29 -0
  33. data/spec/dummy/config/environments/production.rb +80 -0
  34. data/spec/dummy/config/environments/test.rb +36 -0
  35. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  36. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  37. data/spec/dummy/config/initializers/inflections.rb +16 -0
  38. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  39. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  40. data/spec/dummy/config/initializers/session_store.rb +3 -0
  41. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/spec/dummy/config/locales/en.yml +23 -0
  43. data/spec/dummy/config/routes.rb +3 -0
  44. data/spec/dummy/db/migrate/20130725213651_create_users.rb +12 -0
  45. data/spec/dummy/db/schema.rb +25 -0
  46. data/spec/dummy/log/test.log +1180 -0
  47. data/spec/dummy/public/404.html +58 -0
  48. data/spec/dummy/public/422.html +58 -0
  49. data/spec/dummy/public/500.html +57 -0
  50. data/spec/dummy/public/favicon.ico +0 -0
  51. data/spec/dummy/spec/factories/user.rb +9 -0
  52. data/spec/dummy/spec/models/user_spec.rb +40 -0
  53. data/spec/dummy/spec/spec_helper.rb +37 -0
  54. data/spec/spec_helper.rb +37 -0
  55. metadata +58 -26
  56. data/README.rdoc +0 -19
  57. data/app/controllers/cz_auth/registrations_controller.rb +0 -19
  58. data/app/controllers/cz_auth/sessions_controller.rb +0 -22
  59. data/app/helpers/cz_auth/application_helper.rb +0 -11
  60. data/app/views/cz_auth/registrations/new.html.erb +0 -1
  61. data/app/views/cz_auth/sessions/new.html.erb +0 -1
  62. data/lib/tasks/cz_auth_tasks.rake +0 -4
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :user do
4
+ sequence(:email) { |n| "test_#{n}@bqsoft.com" }
5
+ password 'p@ssw0rd'
6
+ password_confirmation 'p@ssw0rd'
7
+ end
8
+
9
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe User do
4
+ subject { FactoryGirl.create(:user) }
5
+
6
+ context "class" do
7
+ its(:class) { should respond_to(:requires_authentication) }
8
+ end
9
+
10
+ context "instance" do
11
+ it { should respond_to(:authenticate) }
12
+ it { should respond_to(:auth_token) }
13
+ it { should respond_to(:password) }
14
+ it { should respond_to(:email) }
15
+
16
+ its(:auth_token) { should_not be_nil }
17
+ its(:password_reset_token) { should be_nil }
18
+ end
19
+
20
+ #
21
+ # Local Authentication
22
+ #
23
+
24
+ context "local authentication" do
25
+
26
+ it "should return false if unable to authenticate" do
27
+ subject.authenticate("notright").should be_false
28
+ end
29
+
30
+ it "should return an instance of the authenticated object when authenticating with a password" do
31
+ subject.authenticate(subject.password).should eq subject
32
+ end
33
+
34
+ it "should return an instance of the authenticated object when authenticating with a token" do
35
+ subject.authenticate(subject.auth_token).should eq subject
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,37 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+
3
+ require File.expand_path("../../config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+ require 'factory_girl_rails'
7
+ require 'generator_spec'
8
+ require 'json_spec'
9
+ require 'database_cleaner'
10
+
11
+ Rails.backtrace_cleaner.remove_silencers!
12
+
13
+ # Load support files
14
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
15
+
16
+ RSpec.configure do |config|
17
+ config.include FactoryGirl::Syntax::Methods
18
+ config.include JsonSpec::Helpers
19
+
20
+ # Run tests in a random order
21
+ config.order = "random"
22
+
23
+ #
24
+ # Run this before each test
25
+ #
26
+ config.before :suite do
27
+ DatabaseCleaner.strategy = :truncation
28
+ DatabaseCleaner.orm = "mongoid"
29
+ end
30
+
31
+ #
32
+ # Run this after all tests
33
+ #
34
+ config.after do
35
+ DatabaseCleaner.clean
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+ require 'factory_girl_rails'
7
+ require 'generator_spec'
8
+ require 'json_spec'
9
+ require 'database_cleaner'
10
+
11
+ Rails.backtrace_cleaner.remove_silencers!
12
+
13
+ # Load support files
14
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
15
+
16
+ RSpec.configure do |config|
17
+ config.include FactoryGirl::Syntax::Methods
18
+ config.include JsonSpec::Helpers
19
+
20
+ # Run tests in a random order
21
+ config.order = "random"
22
+
23
+ #
24
+ # Run this before each test
25
+ #
26
+ config.before :suite do
27
+ DatabaseCleaner.strategy = :truncation
28
+ DatabaseCleaner.orm = "mongoid"
29
+ end
30
+
31
+ #
32
+ # Run this after all tests
33
+ #
34
+ config.after do
35
+ DatabaseCleaner.clean
36
+ end
37
+ end
metadata CHANGED
@@ -1,48 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cz_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mike Kelley
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-21 00:00:00.000000000 Z
11
+ date: 2013-08-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 3.2.12
19
+ version: 4.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 3.2.12
26
+ version: 4.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bcrypt-ruby
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: 3.0.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: 3.0.0
46
41
  description: A Simple has_secure_password implementation
47
42
  email:
48
43
  - mike@codezombie.org
@@ -51,43 +46,80 @@ extensions: []
51
46
  extra_rdoc_files: []
52
47
  files:
53
48
  - app/controllers/cz_auth/application_controller.rb
54
- - app/controllers/cz_auth/registrations_controller.rb
55
- - app/controllers/cz_auth/sessions_controller.rb
56
- - app/helpers/cz_auth/application_helper.rb
57
- - app/views/cz_auth/registrations/new.html.erb
58
- - app/views/cz_auth/sessions/new.html.erb
49
+ - app/controllers/cz_auth/authentication_controller.rb
50
+ - app/controllers/cz_auth/concerns/authentication.rb
51
+ - app/views/cz_auth/authentication/create.json.erb
52
+ - app/views/cz_auth/authentication/invalid.json
53
+ - config/environment.rb
59
54
  - config/routes.rb
60
55
  - lib/cz_auth/engine.rb
61
56
  - lib/cz_auth/requires_authentication.rb
62
57
  - lib/cz_auth/version.rb
63
58
  - lib/cz_auth.rb
64
59
  - lib/generators/cz_auth/install_generator.rb
65
- - lib/tasks/cz_auth_tasks.rake
60
+ - spec/dummy/app/assets/javascripts/application.js
61
+ - spec/dummy/app/assets/stylesheets/application.css
62
+ - spec/dummy/app/controllers/application_controller.rb
63
+ - spec/dummy/app/helpers/application_helper.rb
64
+ - spec/dummy/app/models/user.rb
65
+ - spec/dummy/app/views/layouts/application.html.erb
66
+ - spec/dummy/bin/bundle
67
+ - spec/dummy/bin/rails
68
+ - spec/dummy/bin/rake
69
+ - spec/dummy/config/application.rb
70
+ - spec/dummy/config/boot.rb
71
+ - spec/dummy/config/database.yml
72
+ - spec/dummy/config/environment.rb
73
+ - spec/dummy/config/environments/development.rb
74
+ - spec/dummy/config/environments/production.rb
75
+ - spec/dummy/config/environments/test.rb
76
+ - spec/dummy/config/initializers/backtrace_silencers.rb
77
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
78
+ - spec/dummy/config/initializers/inflections.rb
79
+ - spec/dummy/config/initializers/mime_types.rb
80
+ - spec/dummy/config/initializers/secret_token.rb
81
+ - spec/dummy/config/initializers/session_store.rb
82
+ - spec/dummy/config/initializers/wrap_parameters.rb
83
+ - spec/dummy/config/locales/en.yml
84
+ - spec/dummy/config/routes.rb
85
+ - spec/dummy/config.ru
86
+ - spec/dummy/db/migrate/20130725213651_create_users.rb
87
+ - spec/dummy/db/schema.rb
88
+ - spec/dummy/log/test.log
89
+ - spec/dummy/public/404.html
90
+ - spec/dummy/public/422.html
91
+ - spec/dummy/public/500.html
92
+ - spec/dummy/public/favicon.ico
93
+ - spec/dummy/Rakefile
94
+ - spec/dummy/README.rdoc
95
+ - spec/dummy/spec/factories/user.rb
96
+ - spec/dummy/spec/models/user_spec.rb
97
+ - spec/dummy/spec/spec_helper.rb
98
+ - spec/spec_helper.rb
66
99
  - MIT-LICENSE
67
100
  - Rakefile
68
- - README.rdoc
101
+ - README.md
69
102
  homepage:
70
103
  licenses: []
104
+ metadata: {}
71
105
  post_install_message:
72
106
  rdoc_options: []
73
107
  require_paths:
74
108
  - lib
75
109
  required_ruby_version: !ruby/object:Gem::Requirement
76
- none: false
77
110
  requirements:
78
- - - ! '>='
111
+ - - '>='
79
112
  - !ruby/object:Gem::Version
80
113
  version: '0'
81
114
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
115
  requirements:
84
- - - ! '>='
116
+ - - '>='
85
117
  - !ruby/object:Gem::Version
86
118
  version: '0'
87
119
  requirements: []
88
120
  rubyforge_project:
89
- rubygems_version: 1.8.25
121
+ rubygems_version: 2.0.5
90
122
  signing_key:
91
- specification_version: 3
123
+ specification_version: 4
92
124
  summary: A Simple has_secure_password implementation
93
125
  test_files: []