monban 0.0.8 → 0.0.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1eea738a714fc0f03f4e0a62079eb8fe979a925d
4
- data.tar.gz: b169d1d7730f4ff61ff1f5783a7588ded2dd63bf
3
+ metadata.gz: b85066515d8a269e94b2716637b08b008070cca5
4
+ data.tar.gz: 032a727fa968f9fc87ca361c91fd5caf8a4251ef
5
5
  SHA512:
6
- metadata.gz: df2ae9cdac6f2b795c4b5eb034c712aa0a63ccfe04717431a9ea4b5a4b3d5dc0adc39c749891a81e5d2de93b0183578344dd7e736de6290341ae9deb27a36bd0
7
- data.tar.gz: 348dd3613602134b6b956a56cac76262927329b6a5d0ca16db0fcb818c27e3da05ed3d8e1d9b0e243ac39ecbab8587fcf0d565fe316fecccd5bec700097f2913
6
+ metadata.gz: 1f269fe95461228bfc61df0a541d98ba970aa884b7069dff4f4893b4c0e7f41db2589be0928d51154afd6dc0f273156cce10554ba1a9e70a3cce6bfa560e67c6
7
+ data.tar.gz: 02fd73c726d461da78cc952848d83e367eb05952a97a08491dd9a87c0e2462ca6a7ab98f66f02e8210859b4192d431b6f51812592951089889065e28005a72da
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monban (0.0.7)
4
+ monban (0.0.8)
5
5
  bcrypt-ruby
6
6
  rails
7
7
  warden
@@ -38,8 +38,8 @@ GEM
38
38
  activesupport (3.2.11)
39
39
  i18n (~> 0.6)
40
40
  multi_json (~> 1.0)
41
- arel (3.0.2)
42
- bcrypt-ruby (3.0.1)
41
+ arel (3.0.3)
42
+ bcrypt-ruby (3.1.2)
43
43
  builder (3.0.4)
44
44
  capybara (2.0.2)
45
45
  mime-types (>= 1.16)
@@ -50,7 +50,6 @@ GEM
50
50
  xpath (~> 1.0.0)
51
51
  childprocess (0.3.7)
52
52
  ffi (~> 1.0, >= 1.0.6)
53
- coderay (1.0.8)
54
53
  diff-lcs (1.1.3)
55
54
  erubis (2.7.0)
56
55
  ffi (1.3.1)
@@ -62,15 +61,10 @@ GEM
62
61
  i18n (>= 0.4.0)
63
62
  mime-types (~> 1.16)
64
63
  treetop (~> 1.4.8)
65
- method_source (0.8.1)
66
64
  mime-types (1.20.1)
67
65
  multi_json (1.5.0)
68
66
  nokogiri (1.5.6)
69
67
  polyglot (0.3.3)
70
- pry (0.9.11.4)
71
- coderay (~> 1.0.5)
72
- method_source (~> 0.8)
73
- slop (~> 3.4)
74
68
  rack (1.4.4)
75
69
  rack-cache (1.2)
76
70
  rack (>= 0.4)
@@ -117,7 +111,6 @@ GEM
117
111
  multi_json (~> 1.0)
118
112
  rubyzip
119
113
  websocket (~> 1.0.4)
120
- slop (3.4.3)
121
114
  sprockets (2.2.2)
122
115
  hike (~> 1.2)
123
116
  multi_json (~> 1.0)
@@ -126,11 +119,11 @@ GEM
126
119
  sqlite3 (1.3.7)
127
120
  thor (0.17.0)
128
121
  tilt (1.3.3)
129
- treetop (1.4.14)
122
+ treetop (1.4.15)
130
123
  polyglot
131
124
  polyglot (>= 0.3.1)
132
- tzinfo (0.3.37)
133
- warden (1.2.1)
125
+ tzinfo (0.3.38)
126
+ warden (1.2.3)
134
127
  rack (>= 1.0)
135
128
  websocket (1.0.7)
136
129
  xpath (1.0.0)
@@ -143,7 +136,6 @@ DEPENDENCIES
143
136
  active_hash
144
137
  capybara
145
138
  monban!
146
- pry
147
139
  rake
148
140
  rspec
149
141
  rspec-rails
data/README.md CHANGED
@@ -4,16 +4,16 @@
4
4
  [![Code Climate](https://codeclimate.com/github/halogenandtoast/monban.png)](https://codeclimate.com/github/halogenandtoast/monban)
5
5
 
6
6
 
7
- Monban is designed to be very simple and extensible user authentication. It's goal is to give all the power to the developer instead of
8
- forcing them to make Monban work with their system
7
+ Monban is designed to be a very simple and extensible user authentication
8
+ library for rails. Its goal is to give all the power to the developer instead
9
+ of forcing them to make Monban work with their system.
9
10
 
10
11
  # Why use Monban?
11
12
 
12
13
  Monban makes authentication simple:
13
14
 
14
- - Uses warden
15
+ - Easy to use in tests with dependency injection
15
16
  - Provides convenient controller helpers
16
- - Provides a rails generator for default controllers and views
17
17
  - Very customizable
18
18
 
19
19
  Monban doesn't do the following:
@@ -33,21 +33,29 @@ Then inside of your ApplicationController add the following:
33
33
 
34
34
  include Monban::ControllerHelpers
35
35
 
36
- You may also generate a scaffold to start with:
36
+ And you're ready to start designing your authentication system.
37
+
38
+ ## Scaffold
39
+
40
+ If you don't want to add all the components yourself, you may instead generate
41
+ a scaffold to start with by running:
37
42
 
38
43
  rails g monban:scaffold
39
44
 
40
- This will generate a bare bones starting point. If you don't want the full stack you can just generate some controllers with:
45
+ This will generate a bare bones starting point. If you don't want the full
46
+ stack you can just generate some controllers with:
41
47
 
42
48
  rails g monban:controllers
43
49
 
44
50
  ## Usage
45
51
 
46
- Monban does currently have some out of the box expectations, but you can configure any of these:
52
+ Monban does currently have some out of the box expectations, but you can
53
+ configure and change any of these:
47
54
 
48
55
  - By default the model should be called `User`
56
+ - Monban expects your user model to respond to create
49
57
  - You should have an `email` and `password_digest` column on your `User`
50
- - Passwords will be run through BCrypt
58
+ - Passwords will be handled with BCrypt
51
59
 
52
60
  ### Controller Additions
53
61
 
@@ -56,8 +64,9 @@ Monban provides the following controller methods:
56
64
  - `sign_in(user)`
57
65
  - `sign_out`
58
66
  - `sign_up(user)`
59
- - `authenticate_session(session_params)`
60
67
  - `authenticate(user, password)`
68
+ - `authenticate_session(session_params)`
69
+ - `reset_password(user, password)`
61
70
 
62
71
  These helpers:
63
72
 
@@ -41,7 +41,9 @@ module Monban
41
41
  def self.test_mode!
42
42
  Warden.test_mode!
43
43
  config.encryption_method = ->(password) { password }
44
- config.token_comparison = ->(digest, unencrypted_password) { digest == unencrypted_password }
44
+ config.token_comparison = ->(digest, unencrypted_password) do
45
+ digest == unencrypted_password
46
+ end
45
47
  end
46
48
 
47
49
  def self.test_reset!
@@ -1,11 +1,13 @@
1
1
  module Monban
2
2
  class Configuration
3
+
3
4
  attr_accessor :user_class, :user_token_field, :user_token_store_field
4
5
  attr_accessor :encryption_method, :token_comparison, :user_lookup_field
5
6
  attr_accessor :sign_in_notice
6
7
  attr_accessor :sign_in_service, :sign_up_service, :sign_out_service
7
8
  attr_accessor :authentication_service, :password_reset_service
8
9
  attr_accessor :failure_app
10
+ attr_accessor :creation_method
9
11
 
10
12
  def initialize
11
13
  setup_class_defaults
@@ -15,6 +17,10 @@ module Monban
15
17
  setup_requirements
16
18
  end
17
19
 
20
+ def default_creation_method
21
+ ->(params) { Monban.user_class.create(params) }
22
+ end
23
+
18
24
  def default_encryption_method
19
25
  ->(token) { BCrypt::Password.create(token) }
20
26
  end
@@ -41,6 +47,7 @@ module Monban
41
47
  @user_token_field = :password
42
48
  @user_token_store_field = :password_digest
43
49
  @user_lookup_field = :email
50
+ @creation_method = default_creation_method
44
51
  end
45
52
 
46
53
  def setup_services
@@ -55,4 +62,5 @@ module Monban
55
62
  @failure_app = lambda{|e|[401, {"Content-Type" => "text/plain"}, ["Authorization Failed"]] }
56
63
  end
57
64
  end
65
+
58
66
  end
@@ -29,8 +29,9 @@ module Monban
29
29
  end
30
30
 
31
31
  def authenticate_session session_params, field_map = nil
32
- password = session_params.fetch(Monban.config.user_token_field)
33
- user = Monban.lookup(session_params.except(Monban.config.user_token_field), field_map)
32
+ token_field = Monban.config.user_token_field
33
+ password = session_params.fetch(token_field)
34
+ user = Monban.lookup(session_params.except(token_field), field_map)
34
35
  authenticate(user, password)
35
36
  end
36
37
 
@@ -57,7 +58,7 @@ module Monban
57
58
  def require_login
58
59
  unless signed_in?
59
60
  flash.notice = Monban.config.sign_in_notice
60
- redirect_to controller: 'sessions', action: 'new'
61
+ redirect_to controller: '/sessions', action: 'new'
61
62
  end
62
63
  end
63
64
  end
@@ -7,7 +7,7 @@ module Monban
7
7
  end
8
8
 
9
9
  def perform
10
- Monban.user_class.create(@user_params.to_hash)
10
+ Monban.config.creation_method.call(@user_params.to_hash)
11
11
  end
12
12
 
13
13
  private
@@ -1,3 +1,3 @@
1
1
  module Monban
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -24,8 +24,6 @@ Gem::Specification.new do |gem|
24
24
  gem.add_development_dependency 'rspec'
25
25
  gem.add_development_dependency 'rspec-rails'
26
26
  gem.add_development_dependency 'capybara'
27
- gem.add_development_dependency 'pry'
28
27
  gem.add_development_dependency 'sqlite3'
29
28
  gem.add_development_dependency 'active_hash'
30
- gem.add_development_dependency 'pry'
31
29
  end
@@ -14,4 +14,15 @@ describe Monban::SignUp, '#perform' do
14
14
 
15
15
  Monban::SignUp.new(user_params).perform
16
16
  end
17
+
18
+ it 'creates a user from the configured user creation method' do
19
+ user_create_double = ->(user_params) { }
20
+ user_create_double.should_receive(:call) do |args|
21
+ Monban.compare_token(args[:password_digest], 'password').should be_true
22
+ end
23
+
24
+ user_params = { email: 'email@example.com', password: 'password' }
25
+ Monban.config.creation_method = user_create_double
26
+ Monban::SignUp.new(user_params).perform
27
+ end
17
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - halogenandtoast
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-20 00:00:00.000000000 Z
12
+ date: 2014-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -109,20 +109,6 @@ dependencies:
109
109
  - - '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: pry
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - '>='
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
112
  - !ruby/object:Gem::Dependency
127
113
  name: sqlite3
128
114
  requirement: !ruby/object:Gem::Requirement
@@ -151,20 +137,6 @@ dependencies:
151
137
  - - '>='
152
138
  - !ruby/object:Gem::Version
153
139
  version: '0'
154
- - !ruby/object:Gem::Dependency
155
- name: pry
156
- requirement: !ruby/object:Gem::Requirement
157
- requirements:
158
- - - '>='
159
- - !ruby/object:Gem::Version
160
- version: '0'
161
- type: :development
162
- prerelease: false
163
- version_requirements: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - '>='
166
- - !ruby/object:Gem::Version
167
- version: '0'
168
140
  description: simple rails authentication
169
141
  email:
170
142
  - halogenandtoast@gmail.com