authn-rails 1.0.0

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.
@@ -0,0 +1,40 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore
6
+
7
+ # Ignore all of the generated gem stuff
8
+ /pkg
9
+ /*.gem
10
+
11
+ # Ignore bundler config
12
+ /.bundle
13
+ /Gemfile.lock
14
+
15
+ # Ignore all bundler caching
16
+ /vendor/cache
17
+ /vendor/ruby
18
+
19
+ # Ignore all tempfiles
20
+ /tmp
21
+
22
+ # Ignores that should be in the global gitignore
23
+ # /*.rbc
24
+ # /.config
25
+ # /.yardoc
26
+ # /InstalledFiles
27
+ # /_yardoc
28
+ # /coverage/
29
+ # /doc/
30
+ # /lib/bundler/man/
31
+ # /rdoc/
32
+ # /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 ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p194@authn-rails"
10
+
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
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
@@ -0,0 +1 @@
1
+ - 1.9.3
@@ -0,0 +1,8 @@
1
+ CHANGELOG
2
+ ---------
3
+
4
+
5
+ 1.0.0 / YYYY-MM-DD
6
+ ==================
7
+
8
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in example.gemspec
4
+ gemspec
5
+
6
+ gem 'rails'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Kurtis Rainbolt-Greene
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
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.
@@ -0,0 +1,144 @@
1
+ AuthN (Rails)
2
+ -------------
3
+
4
+ authn-rails is an extention of the AuthN library.
5
+
6
+ Using AuthN
7
+ ===========
8
+
9
+ To start using authn you simply need to install and hook up to your existing "user" model:
10
+
11
+ ``` ruby
12
+ # create_table :accounts do |t|
13
+ # t.string :email, null: false, default: nil
14
+ # t.binary :password_digest, null: false, default: nil
15
+ # t.timestamps
16
+ # end
17
+ # add_index :accounts, :email, unique: true
18
+ #
19
+
20
+ class Account < ActiveRecord::Base
21
+ include AuthN::Model
22
+
23
+ has_authentication
24
+ has_secure_password
25
+
26
+ validates :email, uniqueness: true, presence: true, length: 5..255
27
+ validates :password, length: 10..1024
28
+
29
+ attr_accessible :email
30
+ attr_accessible :password, :password_confirmation
31
+ end
32
+ ```
33
+
34
+ See?
35
+ No muss, no fuss.
36
+ Now what about all those addons?
37
+ We'll you can see their own pages, but here's a taste:
38
+
39
+ ``` ruby
40
+ # create_table :accounts do |t|
41
+ # t.string :email, null: false, default: nil
42
+ # t.binary :password_digest, null: false, default: nil
43
+ #
44
+ # t.string :activation_token, default: nil
45
+ # t.boolean :activation_state, null: false, default: false
46
+ # t.datetime :activation_expires_at, default: nil
47
+ #
48
+ # t.string :password_recovery_token, default: nil
49
+ # t.datetime :password_recovery_expires_at, default: nil
50
+ #
51
+ # t.string :login_protection_token, default: nil
52
+ # t.datetime :login_protection_expires_at, default: nil
53
+ # t.integer :login_protection_attempts, default: 0
54
+ #
55
+ # t.timestamps
56
+ # end
57
+ # add_index :accounts, :email, unique: true
58
+ # add_index :accounts, :activation_token, unique: true
59
+ # add_index :accounts, :activation_state
60
+ # add_index :accounts, :password_recovery_token, unique: true
61
+ # add_index :accounts, :login_protection_token, unique: true
62
+ #
63
+
64
+ class Account < ActiveRecord::Base
65
+ include AuthN::Model
66
+
67
+ has_authentication
68
+ has_password_recovery mailer: PasswordRecoveryMailer
69
+ has_activation mailer: ActivationMailer, on_create: false
70
+ has_login_protection maximum: 3, redirect: { controller: :accounts, action: :maximum_login_failure }
71
+ has_secure_password
72
+
73
+ validates :email, uniqueness: true, presence: true, length: 5..255
74
+ validates :password, length: 10..1024
75
+
76
+ attr_accessible :email
77
+ attr_accessible :password, :password_confirmation
78
+ end
79
+ ```
80
+
81
+ You'll notice that there are options after some of the addon singleton methods.
82
+ These are used to overwrite the global configuration.
83
+ authn assumes quite a few things, but never stops you from changing how it works.
84
+ As above you can change how each of your "user" models functions (for say admin recovery emails vs support recovery emails).
85
+ In addition you can either programatically write the "global" configuration or have a `authn.yml` file ready to be loaded.
86
+
87
+ Installing AuthN (Rails)
88
+ ========================
89
+
90
+ Add this line to your application's Gemfile:
91
+
92
+ gem 'authn-rails'
93
+
94
+ And then execute:
95
+
96
+ $ bundle
97
+
98
+ Or install it yourself as:
99
+
100
+ $ gem install authn-rails
101
+
102
+ You're all setup and can follow the examples above.
103
+ However if you want to fine tune your AuthN install simply run this generator:
104
+
105
+ $ rails generate authen:config
106
+
107
+ To install the config files of the addons simply use:
108
+
109
+ $ rails generate authen:config:[addonname]
110
+
111
+ Contributing
112
+ ============
113
+
114
+ 1. Fork it
115
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
116
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
117
+ 4. Push to the branch (`git push origin my-new-feature`)
118
+ 5. Create new Pull Request
119
+
120
+ License
121
+ =======
122
+
123
+ Copyright (c) 2012 Kurtis Rainbolt-Greene
124
+
125
+ MIT License
126
+
127
+ Permission is hereby granted, free of charge, to any person obtaining
128
+ a copy of this software and associated documentation files (the
129
+ "Software"), to deal in the Software without restriction, including
130
+ without limitation the rights to use, copy, modify, merge, publish,
131
+ distribute, sublicense, and/or sell copies of the Software, and to
132
+ permit persons to whom the Software is furnished to do so, subject to
133
+ the following conditions:
134
+
135
+ The above copyright notice and this permission notice shall be
136
+ included in all copies or substantial portions of the Software.
137
+
138
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
139
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
140
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
141
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
142
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
143
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
144
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'yard'
6
+
7
+ begin
8
+ Bundler.setup :default, :development
9
+ rescue Bundler::BundlerError => error
10
+ $stderr.puts error.message
11
+ $stderr.puts "Run `bundle install` to install missing gems"
12
+ exit error.status_code
13
+ end
14
+
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ desc "Run all of the tests"
18
+ Rake::TestTask.new do |config|
19
+ config.libs << 'test'
20
+ config.pattern = 'test/**/*_test*'
21
+ config.verbose = true
22
+ config.warning = true
23
+ end
24
+
25
+ desc "Generate all of the docs"
26
+ YARD::Rake::YardocTask.new do |config|
27
+ config.files = Dir['lib/**/*.rb']
28
+ end
29
+
30
+ desc 'Default: run tests, and generate docs'
31
+ task :default => [ :test, :yard ]
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'authn/rails/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "authn-rails"
8
+ gem.version = AuthN::Rails::VERSION
9
+ gem.authors = ["Kurtis Rainbolt-Greene"]
10
+ gem.email = ["kurtisrainboltgreene@gmail.com"]
11
+ gem.summary = %q{The plugin library for AuthN and Rails}
12
+ gem.description = gem.summary
13
+ gem.homepage = "http://github.com/krainboltgreene/authn-rails"
14
+
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"]
19
+
20
+ gem.add_runtime_dependency 'authn', '~> 1.0'
21
+ gem.add_runtime_dependency 'rails', '~> 3.2'
22
+ gem.add_runtime_dependency 'astruct', '~> 2.9'
23
+ gem.add_runtime_dependency 'bcrypt-ruby', '~> 3.0'
24
+ gem.add_development_dependency 'yard'
25
+ gem.add_development_dependency 'kramdown'
26
+ # gem.add_runtime_dependency 'gemname', '~> 1.0'
27
+ # gem.add_development_dependency 'gemname', '~> 1.0'
28
+ end
@@ -0,0 +1,2 @@
1
+ require 'authn'
2
+ require 'rails'
@@ -0,0 +1,16 @@
1
+ require 'authn'
2
+ require 'rails'
3
+
4
+ module AuthN
5
+ # The AuthN engine takes care of extending ActiveRecord (if used) and ActionController,
6
+ # With the plugin logic.
7
+ class Engine < Rails::Engine
8
+ config.authn = AuthN.config
9
+
10
+ initializer "extend Controller with AuthN" do |app|
11
+ ActionController::Base.send :include, AuthN::Session
12
+ ActionController::Base.helper_method :current_user
13
+ ActionController::Base.helper_method :logged_in?
14
+ end
15
+ end
16
+ end
@@ -0,0 +1 @@
1
+ require 'authn'
@@ -0,0 +1,12 @@
1
+ require 'minitest/autorun'
2
+ require_relative '../../../helper'
3
+
4
+ class TestAuthNRailsVersion < MiniTest::Unit::TestCase
5
+ def setup
6
+ # Setup logic here
7
+ end
8
+
9
+ def test_that_version_is_latest
10
+ assert_equal "1.0.0", AuthN::Rails::VERSION
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: authn-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kurtis Rainbolt-Greene
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: authn
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.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: '1.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.2'
38
+ type: :runtime
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: astruct
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.9'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.9'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bcrypt-ruby
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '3.0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: yard
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: kramdown
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
+ description: The plugin library for AuthN and Rails
111
+ email:
112
+ - kurtisrainboltgreene@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - .rvmrc
119
+ - .travis.yml
120
+ - CHANGELOG.md
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - authn-rails.gemspec
126
+ - lib/authn.rb
127
+ - lib/authn/engine.rb
128
+ - test/helper.rb
129
+ - test/lib/authn/rails/version_test.rb
130
+ homepage: http://github.com/krainboltgreene/authn-rails
131
+ licenses: []
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ segments:
143
+ - 0
144
+ hash: 3489654314563009080
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ! '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ segments:
152
+ - 0
153
+ hash: 3489654314563009080
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 1.8.24
157
+ signing_key:
158
+ specification_version: 3
159
+ summary: The plugin library for AuthN and Rails
160
+ test_files:
161
+ - test/helper.rb
162
+ - test/lib/authn/rails/version_test.rb
163
+ has_rdoc: