has_global_session 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,13 +7,13 @@ spec = Gem::Specification.new do |s|
7
7
  s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
8
8
 
9
9
  s.name = 'has_global_session'
10
- s.version = '1.1.0'
11
- s.date = '2010-07-27'
10
+ s.version = '1.1.2'
11
+ s.date = '2010-10-29'
12
12
 
13
13
  s.authors = ['Tony Spataro']
14
14
  s.email = 'code@tracker.xeger.net'
15
15
  s.homepage= 'http://github.com/xeger/has_global_session'
16
-
16
+
17
17
  s.summary = %q{Secure single-domain session sharing plugin for Rails.}
18
18
  s.description = %q{This plugin for Rails allows several web apps in an authentication domain to share session state, facilitating single sign-on in a distributed web app. It only provides session sharing and does not concern itself with authentication or replication of the user database.}
19
19
 
@@ -21,6 +21,8 @@ spec = Gem::Specification.new do |s|
21
21
  s.add_runtime_dependency('json', [">= 1.1.7"])
22
22
  s.add_runtime_dependency('activesupport', [">= 2.1.2"])
23
23
 
24
+ s.add_development_dependency('rake', ["~> 0.8.7"])
25
+ s.add_development_dependency('ruby-debug', ["~> 0.10.3"])
24
26
  s.add_development_dependency('rspec', [">= 1.3.0"])
25
27
  s.add_development_dependency('flexmock', [">= 0.8.6"])
26
28
  s.add_development_dependency('actionpack', [">= 2.1.2"])
@@ -40,7 +40,7 @@ module HasGlobalSession
40
40
  # In addition to having one section for each operating environment, the configuration
41
41
  # file can specify a 'common' section for settings that apply
42
42
  #
43
- # === Lookup Mechanism
43
+ # === Lookup Mechanism
44
44
  # When the code asks for +Configuration['foo']+, we first check whether the current
45
45
  # environment's config section has a value for foo. If one is found, we return that.
46
46
  #
@@ -62,9 +62,10 @@ module HasGlobalSession
62
62
  # MissingConfiguration:: if config file is missing or unreadable
63
63
  # TypeError:: if config file does not contain a YAML-serialized Hash
64
64
  def initialize(config_file, environment)
65
- raise MissingConfiguration, "Missing or unreadable configuration file" unless File.readable?(config_file)
66
- @config = YAML.load(File.read(config_file))
65
+ @config_file = config_file
67
66
  @environment = environment
67
+ raise MissingConfiguration, "Missing or unreadable configuration file" unless File.readable?(@config_file)
68
+ @config = YAML.load(File.read(@config_file))
68
69
  raise TypeError, "#{config_file} must contain a Hash!" unless Hash === @config
69
70
  validate
70
71
  end
@@ -83,17 +84,30 @@ module HasGlobalSession
83
84
  end
84
85
 
85
86
  def validate # :nodoc
86
- ['attributes/signed', 'integrated', 'cookie/name', 'timeout'].each do |path|
87
- elements = path.split '/'
88
- object = get(elements.shift, false)
89
- elements.each do |element|
90
- object = object[element] if object
91
- if object.nil?
92
- msg = "#{File.basename(config_file)} does not specify required element #{elements.map { |x| "['#{x}']"}.join('')}"
93
- raise MissingConfiguration, msg
94
- end
87
+ ['attributes/signed', 'integrated', 'cookie/name',
88
+ 'timeout'].each {|k| validate_presence_of k}
89
+ end
90
+
91
+ protected
92
+
93
+ # Helper method to check the presence of a key. Used in #validate.
94
+ #
95
+ # === Parameters
96
+ # key(String):: key name; for nested hashes, separate keys with /
97
+ #
98
+ # === Return
99
+ # true always
100
+ def validate_presence_of(key)
101
+ elements = key.split '/'
102
+ object = get(elements.shift, false)
103
+ elements.each do |element|
104
+ object = object[element] if object
105
+ if object.nil?
106
+ msg = "#{File.basename(@config_file)} does not specify required element #{elements.map { |x| "['#{x}']"}.join('')}"
107
+ raise MissingConfiguration, msg
95
108
  end
96
109
  end
110
+ true
97
111
  end
98
112
 
99
113
  private
@@ -108,5 +122,5 @@ module HasGlobalSession
108
122
  rescue NoMethodError
109
123
  raise MissingConfiguration, "Configuration key '#{key}' not found"
110
124
  end
111
- end
112
- end
125
+ end
126
+ end
@@ -7,7 +7,6 @@ module HasGlobalSession
7
7
  unless @global_session_config
8
8
  config_file = File.join(RAILS_ROOT, 'config', 'global_session.yml')
9
9
  @global_session_config = HasGlobalSession::Configuration.new(config_file, RAILS_ENV)
10
- @global_session_config.config_file = config_file
11
10
  end
12
11
 
13
12
  return @global_session_config
@@ -187,7 +187,7 @@ module HasGlobalSession
187
187
  klass = Directory
188
188
  end
189
189
 
190
- return klass.new(File.join(RAILS_ROOT, 'config', 'authorities'))
190
+ return klass.new(global_session_config, File.join(RAILS_ROOT, 'config', 'authorities'))
191
191
  end
192
192
  end
193
193
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_global_session
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 2
10
+ version: 1.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Spataro
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-27 00:00:00 -07:00
18
+ date: 2010-10-29 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -67,9 +67,41 @@ dependencies:
67
67
  type: :runtime
68
68
  version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: rake
71
71
  prerelease: false
72
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 49
78
+ segments:
79
+ - 0
80
+ - 8
81
+ - 7
82
+ version: 0.8.7
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: ruby-debug
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ hash: 49
94
+ segments:
95
+ - 0
96
+ - 10
97
+ - 3
98
+ version: 0.10.3
99
+ type: :development
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: rspec
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
73
105
  none: false
74
106
  requirements:
75
107
  - - ">="
@@ -81,11 +113,11 @@ dependencies:
81
113
  - 0
82
114
  version: 1.3.0
83
115
  type: :development
84
- version_requirements: *id004
116
+ version_requirements: *id006
85
117
  - !ruby/object:Gem::Dependency
86
118
  name: flexmock
87
119
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
120
+ requirement: &id007 !ruby/object:Gem::Requirement
89
121
  none: false
90
122
  requirements:
91
123
  - - ">="
@@ -97,11 +129,11 @@ dependencies:
97
129
  - 6
98
130
  version: 0.8.6
99
131
  type: :development
100
- version_requirements: *id005
132
+ version_requirements: *id007
101
133
  - !ruby/object:Gem::Dependency
102
134
  name: actionpack
103
135
  prerelease: false
104
- requirement: &id006 !ruby/object:Gem::Requirement
136
+ requirement: &id008 !ruby/object:Gem::Requirement
105
137
  none: false
106
138
  requirements:
107
139
  - - ">="
@@ -113,7 +145,7 @@ dependencies:
113
145
  - 2
114
146
  version: 2.1.2
115
147
  type: :development
116
- version_requirements: *id006
148
+ version_requirements: *id008
117
149
  description: This plugin for Rails allows several web apps in an authentication domain to share session state, facilitating single sign-on in a distributed web app. It only provides session sharing and does not concern itself with authentication or replication of the user database.
118
150
  email: code@tracker.xeger.net
119
151
  executables: []