configvars_rails 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -45,6 +45,13 @@ username:password combo is config:vars. The credentials can be tweaked by
45
45
  (you guessed!) changing the config_vars.http_user and config_vars.http_password
46
46
  configuration variables.
47
47
 
48
+ You can get HTTP Basic authentication for your other actions by calling
49
+ config_vars_auth in your controllers, as if it was before_filter. This is
50
+ particularly handy as a quick patch the authorization issues that come up when
51
+ open-sourcing an application that's running in production.
52
+ config_vars_auth, :except => :index
53
+
54
+
48
55
  == Note on Patches/Pull Requests
49
56
 
50
57
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
@@ -1,78 +1,75 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{configvars_rails}
8
- s.version = "0.3.1"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Victor Costan"]
12
- s.date = %q{2010-09-02}
12
+ s.date = %q{2011-03-09}
13
13
  s.description = %q{This gem provides a model and simple controller for
14
14
  storing global application configuration in a database. This allows the
15
15
  configuration to change without source code modifications.}
16
16
  s.email = %q{victor@costan.us}
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE",
19
- "README.rdoc"
19
+ "README.rdoc"
20
20
  ]
21
21
  s.files = [
22
- ".gitignore",
23
- ".project",
24
- "LICENSE",
25
- "README.rdoc",
26
- "Rakefile",
27
- "VERSION",
28
- "app/helpers/config_vars_helper.rb",
29
- "configvars_rails.gemspec",
30
- "lib/configvars_rails.rb",
31
- "lib/configvars_rails/controller.rb",
32
- "lib/configvars_rails/descriptor.rb",
33
- "lib/configvars_rails/engine.rb",
34
- "lib/configvars_rails/generators/all_generator.rb",
35
- "lib/configvars_rails/generators/templates/001_create_config_vars.rb",
36
- "lib/configvars_rails/generators/templates/config_var.rb",
37
- "lib/configvars_rails/generators/templates/config_vars.yml",
38
- "lib/configvars_rails/generators/templates/config_vars/edit.html.erb",
39
- "lib/configvars_rails/generators/templates/config_vars/index.html.erb",
40
- "lib/configvars_rails/generators/templates/config_vars_controller.rb",
41
- "lib/configvars_rails/generators/templates/config_vars_controller_test.rb",
42
- "lib/configvars_rails/generators/templates/config_vars_initializer.rb",
43
- "lib/configvars_rails/model.rb",
44
- "lib/configvars_rails/routes.rb",
45
- "test/config_var_test.rb",
46
- "test/config_vars_controller_api_test.rb",
47
- "test/descriptor_test.rb",
48
- "test/helpers/application_controller.rb",
49
- "test/helpers/db_setup.rb",
50
- "test/helpers/initializers.rb",
51
- "test/helpers/routes.rb",
52
- "test/helpers/view_helpers.rb",
53
- "test/routes_test.rb",
54
- "test/test_helper.rb"
22
+ ".project",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "app/helpers/config_vars_helper.rb",
28
+ "configvars_rails.gemspec",
29
+ "lib/configvars_rails.rb",
30
+ "lib/configvars_rails/controller.rb",
31
+ "lib/configvars_rails/descriptor.rb",
32
+ "lib/configvars_rails/engine.rb",
33
+ "lib/configvars_rails/generators/all_generator.rb",
34
+ "lib/configvars_rails/generators/templates/001_create_config_vars.rb",
35
+ "lib/configvars_rails/generators/templates/config_var.rb",
36
+ "lib/configvars_rails/generators/templates/config_vars.yml",
37
+ "lib/configvars_rails/generators/templates/config_vars/edit.html.erb",
38
+ "lib/configvars_rails/generators/templates/config_vars/index.html.erb",
39
+ "lib/configvars_rails/generators/templates/config_vars_controller.rb",
40
+ "lib/configvars_rails/generators/templates/config_vars_controller_test.rb",
41
+ "lib/configvars_rails/generators/templates/config_vars_initializer.rb",
42
+ "lib/configvars_rails/model.rb",
43
+ "lib/configvars_rails/routes.rb",
44
+ "test/config_var_test.rb",
45
+ "test/config_vars_controller_api_test.rb",
46
+ "test/descriptor_test.rb",
47
+ "test/helpers/application_controller.rb",
48
+ "test/helpers/db_setup.rb",
49
+ "test/helpers/initializers.rb",
50
+ "test/helpers/routes.rb",
51
+ "test/helpers/view_helpers.rb",
52
+ "test/routes_test.rb",
53
+ "test/test_helper.rb"
55
54
  ]
56
55
  s.homepage = %q{http://github.com/pwnall/configvars_rails}
57
- s.rdoc_options = ["--charset=UTF-8"]
58
56
  s.require_paths = ["lib"]
59
- s.rubygems_version = %q{1.3.7}
57
+ s.rubygems_version = %q{1.6.0}
60
58
  s.summary = %q{Global configuration variables for Rails 3 applications.}
61
59
  s.test_files = [
62
60
  "test/config_var_test.rb",
63
- "test/config_vars_controller_api_test.rb",
64
- "test/descriptor_test.rb",
65
- "test/helpers/application_controller.rb",
66
- "test/helpers/db_setup.rb",
67
- "test/helpers/initializers.rb",
68
- "test/helpers/routes.rb",
69
- "test/helpers/view_helpers.rb",
70
- "test/routes_test.rb",
71
- "test/test_helper.rb"
61
+ "test/config_vars_controller_api_test.rb",
62
+ "test/descriptor_test.rb",
63
+ "test/helpers/application_controller.rb",
64
+ "test/helpers/db_setup.rb",
65
+ "test/helpers/initializers.rb",
66
+ "test/helpers/routes.rb",
67
+ "test/helpers/view_helpers.rb",
68
+ "test/routes_test.rb",
69
+ "test/test_helper.rb"
72
70
  ]
73
71
 
74
72
  if s.respond_to? :specification_version then
75
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
76
73
  s.specification_version = 3
77
74
 
78
75
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -23,6 +23,12 @@ module ControllerClassMethods
23
23
  def config_vars_controller
24
24
  include ControllerInstanceMethods
25
25
  end
26
+
27
+ # HTTP Basic for controller actions, using config_vars credentials.
28
+ def config_vars_auth(*args)
29
+ include AuthInstanceMethods
30
+ before_filter :config_vars_http_basic_check, *args
31
+ end
26
32
  end
27
33
 
28
34
  # Included in controllers that call config_vars_controller.
@@ -95,7 +101,19 @@ module ControllerInstanceMethods
95
101
  format.html { redirect_to(config_vars_url) }
96
102
  end
97
103
  end
98
- end
104
+ end # module ConfigvarsRails::Session::ControllerInstanceMethods
105
+
106
+ # Included in controllers that call config_vars_controller.
107
+ module AuthInstanceMethods
108
+ def config_vars_http_basic_check
109
+ authenticate_or_request_with_http_basic(
110
+ ConfigVar['config_vars.http_realm']) do |user, password|
111
+ user == ConfigVar['config_vars.http_user'] &&
112
+ password == ConfigVar['config_vars.http_password']
113
+ end
114
+ end
115
+ private :config_vars_http_basic_check
116
+ end # module ConfigvarsRails::Session::AclInstanceMethods
99
117
 
100
118
  ActionController::Base.send :include, ControllerMixin
101
119
 
@@ -1,16 +1,6 @@
1
1
  # Viewing and changing configuration variables.
2
2
  class ConfigVarsController < ApplicationController
3
3
  config_vars_controller
4
-
5
- # Configuration variables are usually sensitive, so let's put some protection
6
- # around modifying them.
7
- before_filter :http_basic_check
8
- def http_basic_check
9
- authenticate_or_request_with_http_basic(
10
- ConfigVar['config_vars.http_realm']) do |user, password|
11
- user == ConfigVar['config_vars.http_user'] &&
12
- password == ConfigVar['config_vars.http_password']
13
- end
14
- end
15
- private :http_basic_check
4
+
5
+ config_vars_auth
16
6
  end
@@ -67,6 +67,12 @@ class ConfigVarsControllerApiTest < ActionController::TestCase
67
67
  assert_redirected_to config_vars_url
68
68
  end
69
69
 
70
+ test "cannot access config vars without authentication" do
71
+ request.env.delete 'HTTP_AUTHORIZATION'
72
+ get :index
73
+ assert_response :unauthorized
74
+ end
75
+
70
76
  # Verbatim, from ActiveController's own unit tests.
71
77
  def encode_credentials(username, password)
72
78
  "Basic #{ActiveSupport::Base64.encode64("#{username}:#{password}")}"
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configvars_rails
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 15
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
- - 3
8
- - 1
9
- version: 0.3.1
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Victor Costan
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-09-02 00:00:00 -07:00
18
+ date: 2011-03-09 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 7
28
30
  segments:
29
31
  - 3
30
32
  - 0
@@ -40,6 +42,7 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
45
+ hash: 27
43
46
  segments:
44
47
  - 1
45
48
  - 3
@@ -60,7 +63,6 @@ extra_rdoc_files:
60
63
  - LICENSE
61
64
  - README.rdoc
62
65
  files:
63
- - .gitignore
64
66
  - .project
65
67
  - LICENSE
66
68
  - README.rdoc
@@ -98,8 +100,8 @@ homepage: http://github.com/pwnall/configvars_rails
98
100
  licenses: []
99
101
 
100
102
  post_install_message:
101
- rdoc_options:
102
- - --charset=UTF-8
103
+ rdoc_options: []
104
+
103
105
  require_paths:
104
106
  - lib
105
107
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -107,6 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
109
  requirements:
108
110
  - - ">="
109
111
  - !ruby/object:Gem::Version
112
+ hash: 3
110
113
  segments:
111
114
  - 0
112
115
  version: "0"
@@ -115,13 +118,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
118
  requirements:
116
119
  - - ">="
117
120
  - !ruby/object:Gem::Version
121
+ hash: 3
118
122
  segments:
119
123
  - 0
120
124
  version: "0"
121
125
  requirements: []
122
126
 
123
127
  rubyforge_project:
124
- rubygems_version: 1.3.7
128
+ rubygems_version: 1.6.0
125
129
  signing_key:
126
130
  specification_version: 3
127
131
  summary: Global configuration variables for Rails 3 applications.
data/.gitignore DELETED
@@ -1,24 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## ECLIPSE
9
- .loadpath
10
-
11
- ## EMACS
12
- *~
13
- \#*
14
- .\#*
15
-
16
- ## VIM
17
- *.swp
18
-
19
- ## PROJECT::GENERAL
20
- coverage
21
- rdoc
22
- pkg
23
-
24
- ## PROJECT::SPECIFIC