islock 0.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 cowboycoded
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = lock
2
2
 
3
- This is a minor modification to lock gem by cowboycoded
3
+ minor modification to cowboycoded's lock gem
4
4
 
5
5
  == Contributing to lock
6
6
 
metadata CHANGED
@@ -1,54 +1,86 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: islock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - i.stanczyk
8
+ - ! 'orig: cowboycoded'
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2011-07-05 00:00:00.000000000Z
13
- dependencies: []
14
- description: ''
15
- email:
16
- - ian.stanczyk@gmail.com
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &17452340 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.1.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *17452340
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &17451780 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *17451780
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &17451200 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.5.1
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *17451200
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &17440820 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *17440820
58
+ - !ruby/object:Gem::Dependency
59
+ name: bcrypt-ruby
60
+ requirement: &17440220 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *17440220
69
+ description: ! 'orig: Simple engine that can lock down controllers/actions with a
70
+ password. Useful for locking a new feature (or an entire site) while it is being
71
+ beta tested.'
72
+ email: ! 'orig: john.mcaliley@gmail.com'
17
73
  executables: []
18
74
  extensions: []
19
- extra_rdoc_files: []
75
+ extra_rdoc_files:
76
+ - LICENSE.txt
77
+ - README.rdoc
20
78
  files:
21
- - Manifest
79
+ - LICENSE.txt
22
80
  - README.rdoc
23
- - Rakefile
24
- - app/controllers/lock_application_controller.rb
25
- - app/controllers/lock_controller.rb
26
- - app/views/lock/login.html.erb
27
- - app/views/lock/refused.html.erb
28
- - app/views/lock/unlock.html.erb
29
- - config/routes.rb
30
- - lib/generators/lock/create_password_file/USAGE
31
- - lib/generators/lock/create_password_file/create_password_file_generator.rb
32
- - lib/lock.rb
33
- - lib/lock/engine.rb
34
- - pkg/islock-0.1.0.gem
35
- - pkg/islock-0.1.0.tar.gz
36
- - pkg/islock-0.1.0/Manifest
37
- - pkg/islock-0.1.0/README.rdoc
38
- - pkg/islock-0.1.0/Rakefile
39
- - pkg/islock-0.1.0/app/controllers/lock_application_controller.rb
40
- - pkg/islock-0.1.0/app/controllers/lock_controller.rb
41
- - pkg/islock-0.1.0/app/views/lock/login.html.erb
42
- - pkg/islock-0.1.0/app/views/lock/refused.html.erb
43
- - pkg/islock-0.1.0/app/views/lock/unlock.html.erb
44
- - pkg/islock-0.1.0/config/routes.rb
45
- - pkg/islock-0.1.0/islock.gemspec
46
- - pkg/islock-0.1.0/lib/generators/lock/create_password_file/USAGE
47
- - pkg/islock-0.1.0/lib/generators/lock/create_password_file/create_password_file_generator.rb
48
- - pkg/islock-0.1.0/lib/lock.rb
49
- - pkg/islock-0.1.0/lib/lock/engine.rb
50
81
  homepage: http://github.com/istan/islock
51
- licenses: []
82
+ licenses:
83
+ - MIT
52
84
  post_install_message:
53
85
  rdoc_options: []
54
86
  require_paths:
@@ -64,11 +96,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
96
  requirements:
65
97
  - - ! '>='
66
98
  - !ruby/object:Gem::Version
67
- version: 1.3.6
99
+ version: '0'
68
100
  requirements: []
69
- rubyforge_project: islock
101
+ rubyforge_project:
70
102
  rubygems_version: 1.8.5
71
103
  signing_key:
72
104
  specification_version: 3
73
- summary: modified lock gem
105
+ summary: minor mod to lock gem
74
106
  test_files: []
data/Manifest DELETED
@@ -1,13 +0,0 @@
1
- README.rdoc
2
- Rakefile
3
- app/controllers/lock_application_controller.rb
4
- app/controllers/lock_controller.rb
5
- app/views/lock/login.html.erb
6
- app/views/lock/refused.html.erb
7
- app/views/lock/unlock.html.erb
8
- config/routes.rb
9
- lib/generators/lock/create_password_file/USAGE
10
- lib/generators/lock/create_password_file/create_password_file_generator.rb
11
- lib/lock.rb
12
- lib/lock/engine.rb
13
- Manifest
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- require 'psych'
2
- require 'rubygems'
3
- require 'rake'
4
- require 'echoe'
5
-
6
- Echoe.new('islock', '0.1.0') do |p|
7
- p.description = "lock gem for is_bf."
8
- p.summary = "summary"
9
- p.url = "http://github.com/istan/islock"
10
- p.author = "i. stan."
11
- p.email = "ian@bostonflip.com"
12
- p.development_dependencies = []
13
- end
14
-
@@ -1,21 +0,0 @@
1
- module LockApplicationController
2
- module ClassMethods
3
- def lock(opts={})
4
- before_filter { |c| c.lock_filter opts[:actions] }
5
- end
6
- end
7
-
8
- module InstanceMethods
9
- def lock_filter(actions=nil)
10
- if locked_action?(actions) and session[:lock_opened]!=true
11
- redirect_to lock_login_url
12
- end
13
- #otherwise proceed to where ya going
14
- end
15
-
16
- def locked_action?(actions)
17
- return false if controller_name=="lock"
18
- actions.blank? or actions.include?("#{controller_name}") or actions.include?("#{controller_name}##{action_name}")
19
- end
20
- end
21
- end
@@ -1,10 +0,0 @@
1
- class LockController < ApplicationController
2
- def unlock
3
- if Lock.passwords_match?(params[:password])
4
- session[:lock_opened] = true
5
- redirect_to root_path
6
- else
7
- redirect_to :action=>:login
8
- end
9
- end
10
- end
@@ -1,7 +0,0 @@
1
- <div class="lock-login" id="lock-login-form">
2
- <p>What's the secret ingedient?</p>
3
- <%= form_tag unlock_url do %>
4
- <%=password_field_tag "password" %>
5
- <%=submit_tag "Go"%>
6
- <% end %>
7
- </div>
@@ -1 +0,0 @@
1
- <p>This page is locked.</p>
@@ -1,3 +0,0 @@
1
- <p>
2
- <%=link_to "Go to home page", "/" %>
3
- </p>
data/config/routes.rb DELETED
@@ -1,5 +0,0 @@
1
- Rails.application.routes.draw do
2
- match "lock/login", :to=>"lock#login", :as=>"lock_login", :via=>:get
3
- match "lock/refused", :to=>"lock#refused", :as=>"unlock_refused", :via=>:get
4
- match "lock/unlock", :to=>"lock#unlock", :as=>"unlock", :via=>:post
5
- end
@@ -1,5 +0,0 @@
1
- Description:
2
- The lock generator is used to create an encrypted password and store it in config/lock_password
3
-
4
- Example:
5
- rails g lock:create_password_file mypassword
@@ -1,14 +0,0 @@
1
- require 'bcrypt'
2
-
3
- module Lock
4
- class CreatePasswordFileGenerator < Rails::Generators::Base
5
- argument :password, :type => :string
6
- source_root File.expand_path('../templates', __FILE__)
7
-
8
- def create_password_file
9
- password_salt = BCrypt::Engine.generate_salt
10
- password_hash = BCrypt::Engine.hash_secret(password, password_salt)
11
- create_file "config/lock_password", "#{password_hash}"
12
- end
13
- end
14
- end
data/lib/lock.rb DELETED
@@ -1,15 +0,0 @@
1
- LOCK_PATH = File.dirname(__FILE__) + "/lock"
2
- require "#{LOCK_PATH}/engine.rb"
3
- require "bcrypt"
4
-
5
- module Lock
6
- def self.passwords_match?(password)
7
- begin
8
- hashed_combo = IO.read("#{Rails.root}/config/lock_password")
9
- rescue
10
- return false
11
- end
12
- salt = hashed_combo[0,29]
13
- hashed_combo==BCrypt::Engine.hash_secret(password, salt)
14
- end
15
- end
data/lib/lock/engine.rb DELETED
@@ -1,13 +0,0 @@
1
- require "lock"
2
- require "rails"
3
-
4
- module Lock
5
- class Engine < Rails::Engine
6
- initializer "lock.extend_application_controller" do
7
- ActiveSupport.on_load(:action_controller) do
8
- include LockApplicationController::InstanceMethods
9
- extend LockApplicationController::ClassMethods
10
- end
11
- end
12
- end
13
- end
data/pkg/islock-0.1.0.gem DELETED
Binary file
Binary file
@@ -1,13 +0,0 @@
1
- README.rdoc
2
- Rakefile
3
- app/controllers/lock_application_controller.rb
4
- app/controllers/lock_controller.rb
5
- app/views/lock/login.html.erb
6
- app/views/lock/refused.html.erb
7
- app/views/lock/unlock.html.erb
8
- config/routes.rb
9
- lib/generators/lock/create_password_file/USAGE
10
- lib/generators/lock/create_password_file/create_password_file_generator.rb
11
- lib/lock.rb
12
- lib/lock/engine.rb
13
- Manifest
@@ -1,19 +0,0 @@
1
- = lock
2
-
3
- This is a minor modification to lock gem by cowboycoded
4
-
5
- == Contributing to lock
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2011 cowboycoded. See LICENSE.txt for
18
- further details.
19
-
@@ -1,14 +0,0 @@
1
- require 'psych'
2
- require 'rubygems'
3
- require 'rake'
4
- require 'echoe'
5
-
6
- Echoe.new('islock', '0.1.0') do |p|
7
- p.description = "lock gem for is_bf."
8
- p.summary = "summary"
9
- p.url = "http://github.com/istan/islock"
10
- p.author = "i. stan."
11
- p.email = "ian@bostonflip.com"
12
- p.development_dependencies = []
13
- end
14
-
@@ -1,21 +0,0 @@
1
- module LockApplicationController
2
- module ClassMethods
3
- def lock(opts={})
4
- before_filter { |c| c.lock_filter opts[:actions] }
5
- end
6
- end
7
-
8
- module InstanceMethods
9
- def lock_filter(actions=nil)
10
- if locked_action?(actions) and session[:lock_opened]!=true
11
- redirect_to lock_login_url
12
- end
13
- #otherwise proceed to where ya going
14
- end
15
-
16
- def locked_action?(actions)
17
- return false if controller_name=="lock"
18
- actions.blank? or actions.include?("#{controller_name}") or actions.include?("#{controller_name}##{action_name}")
19
- end
20
- end
21
- end
@@ -1,10 +0,0 @@
1
- class LockController < ApplicationController
2
- def unlock
3
- if Lock.passwords_match?(params[:password])
4
- session[:lock_opened] = true
5
- redirect_to root_path
6
- else
7
- redirect_to :action=>:login
8
- end
9
- end
10
- end
@@ -1,7 +0,0 @@
1
- <div class="lock-login" id="lock-login-form">
2
- <p>What's the secret ingedient?</p>
3
- <%= form_tag unlock_url do %>
4
- <%=password_field_tag "password" %>
5
- <%=submit_tag "Go"%>
6
- <% end %>
7
- </div>
@@ -1 +0,0 @@
1
- <p>This page is locked.</p>
@@ -1,3 +0,0 @@
1
- <p>
2
- <%=link_to "Go to home page", "/" %>
3
- </p>
@@ -1,5 +0,0 @@
1
- Rails.application.routes.draw do
2
- match "lock/login", :to=>"lock#login", :as=>"lock_login", :via=>:get
3
- match "lock/refused", :to=>"lock#refused", :as=>"unlock_refused", :via=>:get
4
- match "lock/unlock", :to=>"lock#unlock", :as=>"unlock", :via=>:post
5
- end
@@ -1,29 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{islock}
5
- s.version = "0.1.0"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = [%q{i. stan.}]
9
- s.date = %q{2011-07-05}
10
- s.description = %q{lock gem for is_bf.}
11
- s.email = %q{ian@bostonflip.com}
12
- s.extra_rdoc_files = [%q{README.rdoc}, %q{lib/generators/lock/create_password_file/USAGE}, %q{lib/generators/lock/create_password_file/create_password_file_generator.rb}, %q{lib/lock.rb}, %q{lib/lock/engine.rb}]
13
- s.files = [%q{README.rdoc}, %q{Rakefile}, %q{app/controllers/lock_application_controller.rb}, %q{app/controllers/lock_controller.rb}, %q{app/views/lock/login.html.erb}, %q{app/views/lock/refused.html.erb}, %q{app/views/lock/unlock.html.erb}, %q{config/routes.rb}, %q{lib/generators/lock/create_password_file/USAGE}, %q{lib/generators/lock/create_password_file/create_password_file_generator.rb}, %q{lib/lock.rb}, %q{lib/lock/engine.rb}, %q{Manifest}, %q{islock.gemspec}]
14
- s.homepage = %q{http://github.com/istan/islock}
15
- s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Islock}, %q{--main}, %q{README.rdoc}]
16
- s.require_paths = [%q{lib}]
17
- s.rubyforge_project = %q{islock}
18
- s.rubygems_version = %q{1.8.5}
19
- s.summary = %q{summary}
20
-
21
- if s.respond_to? :specification_version then
22
- s.specification_version = 3
23
-
24
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
- else
26
- end
27
- else
28
- end
29
- end
@@ -1,5 +0,0 @@
1
- Description:
2
- The lock generator is used to create an encrypted password and store it in config/lock_password
3
-
4
- Example:
5
- rails g lock:create_password_file mypassword
@@ -1,14 +0,0 @@
1
- require 'bcrypt'
2
-
3
- module Lock
4
- class CreatePasswordFileGenerator < Rails::Generators::Base
5
- argument :password, :type => :string
6
- source_root File.expand_path('../templates', __FILE__)
7
-
8
- def create_password_file
9
- password_salt = BCrypt::Engine.generate_salt
10
- password_hash = BCrypt::Engine.hash_secret(password, password_salt)
11
- create_file "config/lock_password", "#{password_hash}"
12
- end
13
- end
14
- end
@@ -1,15 +0,0 @@
1
- LOCK_PATH = File.dirname(__FILE__) + "/lock"
2
- require "#{LOCK_PATH}/engine.rb"
3
- require "bcrypt"
4
-
5
- module Lock
6
- def self.passwords_match?(password)
7
- begin
8
- hashed_combo = IO.read("#{Rails.root}/config/lock_password")
9
- rescue
10
- return false
11
- end
12
- salt = hashed_combo[0,29]
13
- hashed_combo==BCrypt::Engine.hash_secret(password, salt)
14
- end
15
- end
@@ -1,13 +0,0 @@
1
- require "lock"
2
- require "rails"
3
-
4
- module Lock
5
- class Engine < Rails::Engine
6
- initializer "lock.extend_application_controller" do
7
- ActiveSupport.on_load(:action_controller) do
8
- include LockApplicationController::InstanceMethods
9
- extend LockApplicationController::ClassMethods
10
- end
11
- end
12
- end
13
- end