global_session 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -10
- data/global_session.gemspec +3 -2
- data/lib/global_session/configuration.rb +5 -2
- data/lib/global_session/directory.rb +0 -1
- data/lib/global_session/encoding.rb +13 -1
- data/lib/global_session/rack.rb +1 -1
- data/lib/global_session/rails/action_controller_instance_methods.rb +0 -23
- data/lib/global_session/rails.rb +0 -2
- data/lib/global_session/session/abstract.rb +83 -0
- data/lib/global_session/session/v1.rb +352 -0
- data/lib/global_session/session/v2.rb +357 -0
- data/lib/global_session/session.rb +34 -398
- data/lib/global_session.rb +6 -7
- data/rails_generators/global_session/templates/global_session.yml.erb +8 -14
- metadata +24 -7
- data/lib/global_session/integrated_session.rb +0 -146
data/lib/global_session.rb
CHANGED
@@ -75,15 +75,14 @@ require 'json'
|
|
75
75
|
require 'openssl'
|
76
76
|
|
77
77
|
#Require the core suite of GlobalSession classes and modules
|
78
|
-
|
79
|
-
require
|
80
|
-
require
|
81
|
-
require
|
82
|
-
require File.join(basedir, 'global_session', 'session')
|
83
|
-
require File.join(basedir, 'global_session', 'integrated_session')
|
78
|
+
require 'global_session/configuration'
|
79
|
+
require 'global_session/directory'
|
80
|
+
require 'global_session/encoding'
|
81
|
+
require 'global_session/session'
|
84
82
|
|
85
83
|
#Preemptively try to activate the Rails plugin, ignoring errors
|
86
84
|
begin
|
87
|
-
require
|
85
|
+
require 'global_session/rails'
|
88
86
|
rescue Exception => e
|
87
|
+
#no-op
|
89
88
|
end
|
@@ -1,27 +1,21 @@
|
|
1
|
-
# Common
|
2
|
-
#
|
1
|
+
# Common attributes.
|
2
|
+
# May be overidden by per-environment settings; see below
|
3
3
|
common:
|
4
4
|
attributes:
|
5
|
-
#
|
6
|
-
signed:
|
5
|
+
signed: # integrity-protected attributes
|
7
6
|
- user
|
8
|
-
#
|
9
|
-
insecure:
|
7
|
+
insecure: # Insecure (unsigned) attributes
|
10
8
|
- account
|
11
|
-
|
12
|
-
|
13
|
-
ephemeral: false
|
14
|
-
|
9
|
+
ephemeral: true # Ephemeral cookies go away when the browser closes
|
10
|
+
|
15
11
|
# Test/spec runs
|
16
12
|
test:
|
17
13
|
timeout: 15 #minutes
|
18
14
|
renew: 5 #minutes before expiration
|
19
15
|
cookie:
|
20
16
|
name: global_session
|
21
|
-
#the name of the local authority (optional)
|
22
|
-
|
23
|
-
#which authorities this app will trust
|
24
|
-
trust:
|
17
|
+
authority: test # the name of the local authority (optional)
|
18
|
+
trust: #which authorities this app will trust
|
25
19
|
- test
|
26
20
|
|
27
21
|
# Development mode
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: global_session
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
- 1
|
7
|
+
- 2
|
9
8
|
- 0
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
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: 2012-11-
|
18
|
+
date: 2012-11-06 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -66,6 +66,21 @@ dependencies:
|
|
66
66
|
type: :runtime
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
- 4
|
77
|
+
version: "0.4"
|
78
|
+
requirement: *id004
|
79
|
+
name: msgpack
|
80
|
+
prerelease: false
|
81
|
+
type: :runtime
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
69
84
|
none: false
|
70
85
|
requirements:
|
71
86
|
- - ~>
|
@@ -75,7 +90,7 @@ dependencies:
|
|
75
90
|
- 1
|
76
91
|
- 0
|
77
92
|
version: "1.0"
|
78
|
-
requirement: *
|
93
|
+
requirement: *id005
|
79
94
|
name: rack-contrib
|
80
95
|
prerelease: false
|
81
96
|
type: :runtime
|
@@ -96,12 +111,14 @@ files:
|
|
96
111
|
- lib/global_session/configuration.rb
|
97
112
|
- lib/global_session/directory.rb
|
98
113
|
- lib/global_session/encoding.rb
|
99
|
-
- lib/global_session/integrated_session.rb
|
100
114
|
- lib/global_session/rack.rb
|
101
115
|
- lib/global_session/rails.rb
|
102
116
|
- lib/global_session/rails/action_controller_class_methods.rb
|
103
117
|
- lib/global_session/rails/action_controller_instance_methods.rb
|
104
118
|
- lib/global_session/session.rb
|
119
|
+
- lib/global_session/session/abstract.rb
|
120
|
+
- lib/global_session/session/v1.rb
|
121
|
+
- lib/global_session/session/v2.rb
|
105
122
|
- rails/init.rb
|
106
123
|
- rails_generators/global_session/USAGE
|
107
124
|
- rails_generators/global_session/global_session_generator.rb
|
@@ -1,146 +0,0 @@
|
|
1
|
-
# Copyright (c) 2012 RightScale Inc
|
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.
|
21
|
-
|
22
|
-
module GlobalSession
|
23
|
-
# Helper class that enables the end user to treat the global and local session as if
|
24
|
-
# they were the same object. This is accomplished by implementing approximately the
|
25
|
-
# same interface as a Hash, and dispatching to one or the other session object depending
|
26
|
-
# on various factors.
|
27
|
-
#
|
28
|
-
# This class isn't intended to be used directly by the end user. Instead, set integrated: true
|
29
|
-
# in the configuration file and the Web framework integration code will manage an integrated
|
30
|
-
# session object for you, as well as overriding the framework's default session accessor to
|
31
|
-
# return an integrated session instead.
|
32
|
-
#
|
33
|
-
# When using an integrated session, you can always get to the underlying objects by
|
34
|
-
# using the #local and #global readers of this class.
|
35
|
-
#
|
36
|
-
class GlobalSession::IntegratedSession
|
37
|
-
# Return the local-session objects, whose type may vary depending on the Web framework.
|
38
|
-
attr_reader :local
|
39
|
-
|
40
|
-
# Return the global-session object.
|
41
|
-
attr_reader :global
|
42
|
-
|
43
|
-
# Construct a new integrated session.
|
44
|
-
#
|
45
|
-
# === Parameters
|
46
|
-
# local(Object):: Local session that acts like a Hash
|
47
|
-
# global(Session):: Session
|
48
|
-
def initialize(local, global)
|
49
|
-
@local = local
|
50
|
-
@global = global
|
51
|
-
end
|
52
|
-
|
53
|
-
# Retrieve a value from the global session if the supplied key is supported by
|
54
|
-
# the global session, else retrieve it from the local session.
|
55
|
-
#
|
56
|
-
# === Parameters
|
57
|
-
# key(String):: the key
|
58
|
-
#
|
59
|
-
# === Return
|
60
|
-
# value(Object):: The value associated with +key+, or nil if +key+ is not present
|
61
|
-
def [](key)
|
62
|
-
key = key.to_s
|
63
|
-
if @global.supports_key?(key)
|
64
|
-
@global[key]
|
65
|
-
else
|
66
|
-
@local[key]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# Set a value in the global session (if the supplied key is supported) or the local
|
71
|
-
# session otherwise.
|
72
|
-
#
|
73
|
-
# === Parameters
|
74
|
-
# key(String):: The key to set
|
75
|
-
# value(Object):: The value to set
|
76
|
-
#
|
77
|
-
# === Return
|
78
|
-
# value(Object):: Always returns the value that was set
|
79
|
-
def []=(key, value)
|
80
|
-
key = key.to_s
|
81
|
-
if @global.supports_key?(key)
|
82
|
-
@global[key] = value
|
83
|
-
else
|
84
|
-
@local[key] = value
|
85
|
-
end
|
86
|
-
|
87
|
-
return value
|
88
|
-
end
|
89
|
-
|
90
|
-
# Determine whether the global or local session contains a value with the specified key.
|
91
|
-
#
|
92
|
-
# === Parameters
|
93
|
-
# key(String):: The name of the key
|
94
|
-
#
|
95
|
-
# === Return
|
96
|
-
# contained(true|false):: Whether the session currently has a value for the specified key.
|
97
|
-
def has_key?(key)
|
98
|
-
key = key.to_s
|
99
|
-
@global.has_key?(key) || @local.has_key?(key)
|
100
|
-
end
|
101
|
-
|
102
|
-
alias :key? :has_key?
|
103
|
-
|
104
|
-
# Return the keys that are currently present in either the global or local session.
|
105
|
-
#
|
106
|
-
# === Return
|
107
|
-
# keys(Array):: List of keys contained in the global or local session.
|
108
|
-
def keys
|
109
|
-
@global.keys + @local.keys
|
110
|
-
end
|
111
|
-
|
112
|
-
# Return the values that are currently present in the global or local session.
|
113
|
-
#
|
114
|
-
# === Return
|
115
|
-
# values(Array):: List of values contained in the global or local session.
|
116
|
-
def values
|
117
|
-
@global.values + @local.values
|
118
|
-
end
|
119
|
-
|
120
|
-
# Iterate over each key/value pair in both the global and local session.
|
121
|
-
#
|
122
|
-
# === Block
|
123
|
-
# An iterator which will be called with each key/value pair
|
124
|
-
#
|
125
|
-
# === Return
|
126
|
-
# Returns the value of the last expression evaluated by the block
|
127
|
-
def each_pair(&block)
|
128
|
-
@global.each_pair(&block)
|
129
|
-
@local.each_pair(&block)
|
130
|
-
end
|
131
|
-
|
132
|
-
def respond_to?(meth) # :nodoc:
|
133
|
-
return @global.respond_to?(meth) || @local.respond_to?(meth) || super
|
134
|
-
end
|
135
|
-
|
136
|
-
def method_missing(meth, *args) # :nodoc:
|
137
|
-
if @global.respond_to?(meth)
|
138
|
-
@global.__send__(meth, *args)
|
139
|
-
elsif @local.respond_to?(meth)
|
140
|
-
@local.__send__(meth, *args)
|
141
|
-
else
|
142
|
-
super
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|