authn 3.7.4 → 3.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -22,19 +22,8 @@
22
22
  # Ignores that should be in the global gitignore
23
23
  # /*.rbc
24
24
  # /.config
25
- # /.yardoc
26
- # /InstalledFiles
27
- # /_yardoc
28
- # /coverage/
29
- # /doc/
30
- # /lib/bundler/man/
25
+ /.yardoc
26
+ /coverage/
27
+ /doc/
31
28
  # /rdoc/
32
29
  # /spec/reports/
33
- # /test/tmp/
34
- # /test/version_tmp/
35
-
36
- # Ignore sub-gems
37
- /lib/authn/activation
38
- /lib/authn/recovery
39
- /lib/authn/protection
40
- /lib/authn/rails
data/.rvmrc CHANGED
@@ -6,10 +6,10 @@
6
6
  # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
7
  # Only full ruby name is supported here, for short names use:
8
8
  # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3-p194@authn"
9
+ environment_id="ruby-1.9.3-p392@authn"
10
10
 
11
11
  # Uncomment the following lines if you want to verify rvm version per project
12
- # rvmrc_rvm_version="1.13.8 (master)" # 1.10.1 seams as a safe start
12
+ # rvmrc_rvm_version="1.18.18 (stable)" # 1.10.1 seams as a safe start
13
13
  # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
14
  # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
15
  # return 1
@@ -1,6 +1,12 @@
1
1
  CHANGELOG
2
2
  ---------
3
3
 
4
+ 3.8.4 / 2013-03-20
5
+ ==================
6
+
7
+ * Fixing a bug with current user getting called
8
+ * Cleaning up documentation
9
+
4
10
  3.7.4 / 2012-09-21
5
11
  ==================
6
12
 
@@ -17,7 +23,7 @@ CHANGELOG
17
23
 
18
24
  * Updating the readme with new details about authn-rails
19
25
  * Commenting out non-working tests
20
- * Adding a convience before filter to require login
26
+ * Adding a convenience before filter to require login
21
27
 
22
28
  1.0.0 / 2012-MM-DD
23
29
  ==================
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Kurtis Rainbolt-Greene
1
+ Copyright (c) 2013 Kurtis Rainbolt-Greene
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  AuthN
2
2
  -----
3
3
 
4
+ - [![Gem Version](https://badge.fury.io/rb/authn.png)](https://rubygems.org/gems/authn)
5
+ - [![Code Climate](https://codeclimate.com/github/krainboltgreene/authn.png)](https://codeclimate.com/github/krainboltgreene/authn)
6
+ - [![Build Status](https://travis-ci.org/krainboltgreene/authn.png)](https://travis-ci.org/krainboltgreene/authn)
7
+ - [![Dependency Status](https://gemnasium.com/krainboltgreene/authn.png)](https://gemnasium.com/krainboltgreene/authn)
8
+ - [![Coverage Status](https://coveralls.io/repos/krainboltgreene/authn/badge.png?branch=master)](https://coveralls.io/r/krainboltgreene/authn)
9
+
10
+
11
+
4
12
  authn is a simplistic and barebones authentication library.
5
13
  It only does a few things for you, such as:
6
14
 
@@ -19,7 +27,17 @@ In addition you can bring in other behavior sets like:
19
27
  Using AuthN
20
28
  ===========
21
29
 
22
- To start using authn you simply need to install and hook up to your existing "user" model:
30
+ **The Model**
31
+
32
+ In order to use AuthN in your model you'll only need to follow a few steps:
33
+
34
+ * ActiveModel's SecurePassword requires the model have an accessor called `password_digest`. (See schema below, for the ActiveRecord version)
35
+ * The `AuthN::Model` module will need to be included into the model. (See codeblock below)
36
+ * The singleton method `has_authentication` will need to be called.
37
+ * The singleton method `has_secure_password` will need to be called.
38
+
39
+ That's it!
40
+ Now for those fun code examples:
23
41
 
24
42
  ``` ruby
25
43
  # create_table :accounts do |t|
@@ -46,8 +64,9 @@ end
46
64
 
47
65
  See?
48
66
  No muss, no fuss.
49
- Now what about all those addons?
50
- We'll you can see their own pages, but here's a taste:
67
+ Of course authn does (and will) provide extras, like activation or rails integration.
68
+ You'll need to read those repositories for more information.
69
+ Here's a taste of what a "fully loaded" model looks like:
51
70
 
52
71
  ``` ruby
53
72
  # create_table :accounts do |t|
@@ -79,8 +98,8 @@ class Account < ActiveRecord::Base
79
98
 
80
99
  has_authentication
81
100
  has_password_recovery mailer: "PasswordRecoveryMailer"
82
- has_activation mailer: "ActivationMailer", on_create: false
83
- has_login_protection maximum: 3, redirect: { controller: :accounts, action: :maximum_login_failure }
101
+ has_activation mailer: "ActivationMailer", on_create_send: false
102
+ has_login_protection maximum: 3
84
103
  has_secure_password
85
104
 
86
105
  validates :email, uniqueness: true, presence: true, length: 5..255
@@ -90,11 +109,23 @@ class Account < ActiveRecord::Base
90
109
  end
91
110
  ```
92
111
 
93
- You'll notice that there are options after some of the addon singleton methods.
94
- These are used to overwrite the global configuration.
95
- authn assumes quite a few things, but never stops you from changing how it works.
96
- As above you can change how each of your "user" models functions (for say admin recovery emails vs support recovery emails).
97
- In addition you can either programatically write the "global" configuration or have a `authn.yml` file ready to be loaded.
112
+ You'll notice that each singleton method can take some options passed to it in the form of a Hash (or similar).
113
+ These options *supercede* the global config options given by your AuthN config.
114
+ Those options supercede the default config in the gem.
115
+
116
+
117
+ **The Controller**
118
+
119
+ Inside your controllers you have access to these methods:
120
+
121
+ * `login email: "jpublic@mail.com", password: "12341234"`, for logging accounts in if the creds match
122
+ * `auto_login Account.find(23)`, for automatically logging in a certain account
123
+ * `logged_in?` for checking if there's a current user
124
+ * `current_user` which returns the current user instance
125
+ * `require_login`, which redirects to the `unauthorized` action if the user isn't logged in
126
+ * `logout`, for logging out of the current user
127
+
128
+ For more information, check the [wiki](/wiki)
98
129
 
99
130
  Installing AuthN
100
131
  ================
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require 'bundler/gem_tasks'
3
- require 'rake/clean'
4
- require 'rake/testtask'
5
- require 'yard'
2
+ require "bundler/gem_tasks"
3
+ require "rake/clean"
4
+ require "rake/testtask"
5
+ require "yard"
6
6
 
7
7
  begin
8
8
  Bundler.setup :default, :development
@@ -16,16 +16,14 @@ Bundler::GemHelper.install_tasks
16
16
 
17
17
  desc "Run all of the tests"
18
18
  Rake::TestTask.new do |config|
19
- config.libs << 'test'
20
- config.pattern = 'test/**/*_test*'
21
- config.verbose = true
22
- config.warning = true
19
+ config.libs << "test"
20
+ config.pattern = "test/**/*_test.rb"
23
21
  end
24
22
 
25
23
  desc "Generate all of the docs"
26
24
  YARD::Rake::YardocTask.new do |config|
27
- config.files = Dir['lib/**/*.rb']
25
+ config.files = Dir["lib/**/*.rb"]
28
26
  end
29
27
 
30
- desc 'Default: run tests, and generate docs'
28
+ desc "Default: run tests, and generate docs"
31
29
  task :default => [ :test, :yard ]
@@ -1,27 +1,31 @@
1
- # encoding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'authn/version'
4
+ require "authn/version"
5
5
 
6
- Gem::Specification.new do |gem|
7
- gem.name = "authn"
8
- gem.version = AuthN::VERSION
9
- gem.authors = ["Kurtis Rainbolt-Greene"]
10
- gem.email = ["me@kurtisrainboltgreene.name"]
11
- gem.summary = %q{An incredibly bare bones authentication library}
12
- gem.description = gem.summary
13
- gem.homepage = "http://krainboltgreene.github.com/authn"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "authn"
8
+ spec.version = AuthN::VERSION
9
+ spec.authors = ["Kurtis Rainbolt-Greene"]
10
+ spec.email = ["me@kurtisrainboltgreene.name"]
11
+ spec.summary = %q{An incredibly bare bones authentication library}
12
+ spec.description = spec.summary
13
+ spec.homepage = "http://krainboltgreene.github.com/authn"
14
+ spec.license = "MIT"
14
15
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
19
20
 
20
- gem.add_runtime_dependency 'activemodel', '~> 3.0'
21
- gem.add_runtime_dependency 'astruct', '~> 2.9'
22
- gem.add_runtime_dependency 'bcrypt-ruby', '~> 3.0'
23
- gem.add_development_dependency 'yard'
24
- gem.add_development_dependency 'kramdown'
25
- # gem.add_runtime_dependency 'gemname', '~> 1.0'
26
- # gem.add_development_dependency 'gemname', '~> 1.0'
21
+ spec.add_runtime_dependency 'activemodel', '~> 3.0'
22
+ spec.add_runtime_dependency 'astruct', '~> 2.9'
23
+ spec.add_runtime_dependency 'bcrypt-ruby', '~> 3.0'
24
+ spec.add_development_dependency "bundler"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "minitest"
27
+ spec.add_development_dependency "yard"
28
+ spec.add_development_dependency "kramdown"
29
+ spec.add_development_dependency "pry"
30
+ spec.add_development_dependency "coveralls"
27
31
  end
@@ -1,6 +1,7 @@
1
1
  module AuthN
2
2
  module Session
3
3
  private
4
+
4
5
  def login(identifiers, klass = AuthN.config.account_klass)
5
6
  generate_session_and_instance_from find_instance_klass(klass).authenticate identifiers
6
7
  end
@@ -36,7 +37,7 @@ module AuthN
36
37
  end
37
38
 
38
39
  def klass_as_name(klass)
39
- klass.name.downcase
40
+ (klass.respond_to?(:name) ? klass.name : klass).downcase
40
41
  end
41
42
 
42
43
  def generate_session_and_instance_from(instance)
@@ -1,3 +1,3 @@
1
1
  module AuthN
2
- VERSION = "3.7.4"
2
+ VERSION = "3.8.4"
3
3
  end
@@ -6,7 +6,7 @@ class TestAuthN < MiniTest::Unit::TestCase
6
6
  assert true
7
7
  end
8
8
 
9
- def test_that_AuthN_is_defined
9
+ def test_that_namespace_defined
10
10
  assert(defined?(AuthN))
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authn
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.4
4
+ version: 3.8.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,88 +9,168 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-21 00:00:00.000000000 Z
12
+ date: 2013-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ none: false
21
+ prerelease: false
15
22
  name: activemodel
16
23
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
24
  requirements:
19
25
  - - ~>
20
26
  - !ruby/object:Gem::Version
21
27
  version: '3.0'
28
+ none: false
22
29
  type: :runtime
23
- prerelease: false
30
+ - !ruby/object:Gem::Dependency
24
31
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
32
  requirements:
27
33
  - - ~>
28
34
  - !ruby/object:Gem::Version
29
- version: '3.0'
30
- - !ruby/object:Gem::Dependency
35
+ version: '2.9'
36
+ none: false
37
+ prerelease: false
31
38
  name: astruct
32
39
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
40
  requirements:
35
41
  - - ~>
36
42
  - !ruby/object:Gem::Version
37
43
  version: '2.9'
44
+ none: false
38
45
  type: :runtime
39
- prerelease: false
46
+ - !ruby/object:Gem::Dependency
40
47
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
48
  requirements:
43
49
  - - ~>
44
50
  - !ruby/object:Gem::Version
45
- version: '2.9'
46
- - !ruby/object:Gem::Dependency
51
+ version: '3.0'
52
+ none: false
53
+ prerelease: false
47
54
  name: bcrypt-ruby
48
55
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
56
  requirements:
51
57
  - - ~>
52
58
  - !ruby/object:Gem::Version
53
59
  version: '3.0'
60
+ none: false
54
61
  type: :runtime
55
- prerelease: false
62
+ - !ruby/object:Gem::Dependency
56
63
  version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
57
68
  none: false
69
+ prerelease: false
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ~>
73
+ - - ! '>='
60
74
  - !ruby/object:Gem::Version
61
- version: '3.0'
75
+ version: '0'
76
+ none: false
77
+ type: :development
62
78
  - !ruby/object:Gem::Dependency
63
- name: yard
64
- requirement: !ruby/object:Gem::Requirement
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
65
84
  none: false
85
+ prerelease: false
86
+ name: rake
87
+ requirement: !ruby/object:Gem::Requirement
66
88
  requirements:
67
89
  - - ! '>='
68
90
  - !ruby/object:Gem::Version
69
91
  version: '0'
92
+ none: false
70
93
  type: :development
94
+ - !ruby/object:Gem::Dependency
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ none: false
71
101
  prerelease: false
102
+ name: minitest
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ none: false
109
+ type: :development
110
+ - !ruby/object:Gem::Dependency
72
111
  version_requirements: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
73
116
  none: false
117
+ prerelease: false
118
+ name: yard
119
+ requirement: !ruby/object:Gem::Requirement
74
120
  requirements:
75
121
  - - ! '>='
76
122
  - !ruby/object:Gem::Version
77
123
  version: '0'
124
+ none: false
125
+ type: :development
78
126
  - !ruby/object:Gem::Dependency
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ none: false
133
+ prerelease: false
79
134
  name: kramdown
80
135
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
136
  requirements:
83
137
  - - ! '>='
84
138
  - !ruby/object:Gem::Version
85
139
  version: '0'
140
+ none: false
86
141
  type: :development
142
+ - !ruby/object:Gem::Dependency
143
+ version_requirements: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ none: false
87
149
  prerelease: false
150
+ name: pry
151
+ requirement: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ none: false
157
+ type: :development
158
+ - !ruby/object:Gem::Dependency
88
159
  version_requirements: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
89
164
  none: false
165
+ prerelease: false
166
+ name: coveralls
167
+ requirement: !ruby/object:Gem::Requirement
90
168
  requirements:
91
169
  - - ! '>='
92
170
  - !ruby/object:Gem::Version
93
171
  version: '0'
172
+ none: false
173
+ type: :development
94
174
  description: An incredibly bare bones authentication library
95
175
  email:
96
176
  - me@kurtisrainboltgreene.name
@@ -118,32 +198,33 @@ files:
118
198
  - test/lib/authn/session_test.rb
119
199
  - test/lib/authn_test.rb
120
200
  homepage: http://krainboltgreene.github.com/authn
121
- licenses: []
201
+ licenses:
202
+ - MIT
122
203
  post_install_message:
123
204
  rdoc_options: []
124
205
  require_paths:
125
206
  - lib
126
207
  required_ruby_version: !ruby/object:Gem::Requirement
127
- none: false
128
208
  requirements:
129
209
  - - ! '>='
130
210
  - !ruby/object:Gem::Version
211
+ hash: 2952794838346421510
131
212
  version: '0'
132
213
  segments:
133
214
  - 0
134
- hash: 2261638177236117174
135
- required_rubygems_version: !ruby/object:Gem::Requirement
136
215
  none: false
216
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
217
  requirements:
138
218
  - - ! '>='
139
219
  - !ruby/object:Gem::Version
220
+ hash: 2952794838346421510
140
221
  version: '0'
141
222
  segments:
142
223
  - 0
143
- hash: 2261638177236117174
224
+ none: false
144
225
  requirements: []
145
226
  rubyforge_project:
146
- rubygems_version: 1.8.24
227
+ rubygems_version: 1.8.25
147
228
  signing_key:
148
229
  specification_version: 3
149
230
  summary: An incredibly bare bones authentication library