infopark_reactor 1.22.6 → 1.23.0.beta2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 411243dbe16d77f7eb90a4db5971c1311a4d5572
4
- data.tar.gz: 9a78a8c682728552b701b6c9fec5f1de1d23adf1
3
+ metadata.gz: 07d1a2447746fc85e6dbbec92b8999053f9a1f9a
4
+ data.tar.gz: 1fc2128aafa6d33799f34f030bf5fb817a249ecd
5
5
  SHA512:
6
- metadata.gz: a0b887b0cc7e81fddada0d55e0d745401fe757f41fef3dc3d4f0f59a6a33d0016f2bd18fdced5cf26c9fc952497f300e93816c922d1f37180ee658737d94cfa9
7
- data.tar.gz: e370727be51373b5f8a834805c99ca5d9b0f227cfb8e1dfe2bdfe9264c6c72759f554b95b23edd189509e09c192a2f0b5fd475143b85044b766fa3e9a623a7f6
6
+ metadata.gz: df3a64681d484882e178f6331f4ecf668ea9827579a3521555d9840dad8bb6bbb976719ba6d12b441384676362b7bae388160898c59b6c3c0aa825ec3a80c8d1
7
+ data.tar.gz: 7998b90a010e9e8e77bcfddcde22ca2d268ab630f7324b0c5eee9d2a48617bef59065479c86a3ea27acc735bef5a5cbbb92c94d8ef91b080e6878ee67a8f78d1
@@ -1,3 +1,5 @@
1
+ require 'reactor/session_helper'
2
+
1
3
  # -*- encoding : utf-8 -*-
2
4
  module Reactor
3
5
 
@@ -14,36 +16,10 @@ module Reactor
14
16
  end
15
17
 
16
18
  initializer "reactor.rsession" do |app|
17
- if app.config.action_dispatch.cookies_serializer && app.config.action_dispatch.cookies_serializer != :marshal
18
- Rails.logger.info "Cookie session serializer #{app.config.action_dispatch.cookies_serializer} unsupported. Enforcing :marshal instead."
19
- app.config.action_dispatch.cookies_serializer = :marshal
20
- end
21
-
22
- # FIXME: extract !
23
- AbstractController::Base.__send__(:define_method, :rsession) do
24
- self.session[:rsession] ||= Reactor::Session.instance
25
- end
19
+ ActionController::Base.__send__(:include, Reactor::SessionHelper::RsessionHelper)
26
20
  ActionController::Base.__send__(:helper_method, :rsession)
27
21
 
28
- ActionController::Base.__send__(:define_method, :rsession_auth) do
29
- if RailsConnector::Configuration.mode == :editor && (jsessionid = cookies['JSESSIONID']).present?
30
- # Why the gsub? It's a dirty hack! Reason: JSESSIONIDs are unescaped
31
- # when read through Rails and hence all + are converted into spaces.
32
- # CM Kernel though stores escaped IDs.
33
- # From the possible generated characters only the + seems to be
34
- # problematic.
35
- # CGI.escape would be the solution, but it's deprecated
36
- # URI.escape does too much
37
- jsessionid.gsub!(' ','+')
38
-
39
- Rails.logger.info "Trying to log in at #{Reactor::Configuration.xml_access[:host]}:#{Reactor::Configuration.xml_access[:port]} with JSESSIONID=#{jsessionid}."
40
- rsession.login(jsessionid)
41
- Rails.logger.info %|Logged in as "#{rsession.user_name}".| if rsession.user?
42
- else
43
- rsession.destroy
44
- end
45
- end
46
- ActionController::Base.__send__(:before_filter, :rsession_auth)
22
+ ActionController::Base.__send__(:include, Reactor::SessionHelper::AuthHelper)
47
23
  end
48
24
 
49
25
  end
@@ -6,34 +6,37 @@ require 'reactor/cache/user'
6
6
  require 'reactor/session/observers'
7
7
 
8
8
  class Reactor::Session
9
- attr_reader :user_name, :session_id
10
9
  include Observable
11
10
 
12
- def self.instance
13
- self.for(Reactor::Configuration.xml_access[:username])
14
- end
11
+ class State < Struct.new(:user_name, :session_id)
12
+ def serialize
13
+ [self.user_name, self.session_id]
14
+ end
15
15
 
16
- def self.for(user_name)
17
- self.new.tap do |instance|
18
- instance.instance_variable_set(:@user_name, user_name)
19
- instance.send(:proper_notify_observers, user_name, false)
16
+ def self.deserialize(array)
17
+ self.new(*array)
20
18
  end
21
19
  end
22
20
 
23
- def marshal_dump
24
- [@user_name, @session_id]
21
+ def initialize(state=State.new)
22
+ self.initialize_and_notify(state)
25
23
  end
26
24
 
27
- def marshal_load(array)
28
- @user_name, @session_id = array
29
- self.add_observers
30
- self.proper_notify_observers(@user_name, false)
25
+ def user_name
26
+ self.state.user_name
31
27
  end
32
28
 
33
- def initialize
34
- self.add_observers
29
+ def session_id
30
+ self.state.session_id
35
31
  end
36
32
 
33
+ def self.instance
34
+ self.for(Reactor::Configuration.xml_access[:username])
35
+ end
36
+
37
+ def self.for(user_name)
38
+ self.new(State.new(user_name, nil))
39
+ end
37
40
 
38
41
  def login(session_id)
39
42
  if !logged_in?(session_id)
@@ -58,13 +61,26 @@ class Reactor::Session
58
61
  end
59
62
 
60
63
  def user_name=(new_user_name)
61
- @user_name = new_user_name
62
- self.proper_notify_observers(@user_name, true)
63
- @user_name
64
+ self.state.user_name = new_user_name
65
+ self.proper_notify_observers(new_user_name, true)
66
+ new_user_name
67
+ end
68
+
69
+ def marshal_dump
70
+ self.state.serialize
71
+ end
72
+
73
+ def marshal_load(array)
74
+ self.initialize_and_notify(State.deserialize(array))
64
75
  end
65
76
 
66
77
  protected
67
- attr_writer :session_id
78
+ attr_accessor :state
79
+ def initialize_and_notify(state)
80
+ self.state = state
81
+ self.add_observers
82
+ self.proper_notify_observers(self.user_name, false)
83
+ end
68
84
 
69
85
  def authenticate(session_id)
70
86
  self.session_id = session_id
@@ -84,4 +100,8 @@ class Reactor::Session
84
100
  self.changed(true)
85
101
  self.notify_observers(*args)
86
102
  end
103
+
104
+ def session_id=(new_session_id)
105
+ self.state.session_id = new_session_id
106
+ end
87
107
  end
@@ -0,0 +1,70 @@
1
+ module Reactor
2
+ module SessionHelper
3
+ module AuthHelper
4
+ def rsession_auth
5
+ if RailsConnector::Configuration.mode == :editor && (jsessionid = cookies['JSESSIONID']).present?
6
+ # Why the gsub? It's a dirty hack! Reason: JSESSIONIDs are unescaped
7
+ # when read through Rails and hence all + are converted into spaces.
8
+ # CM Kernel though stores escaped IDs.
9
+ # From the possible generated characters only the + seems to be
10
+ # problematic.
11
+ # CGI.escape would be the solution, but it's deprecated
12
+ # URI.escape does too much
13
+ jsessionid.gsub!(' ','+')
14
+
15
+ Rails.logger.info "Trying to log in at #{Reactor::Configuration.xml_access[:host]}:#{Reactor::Configuration.xml_access[:port]} with JSESSIONID=#{jsessionid}."
16
+ rsession.login(jsessionid)
17
+ if rsession.user?
18
+ Rails.logger.info %|Logged in as "#{rsession.user_name}".|
19
+ end
20
+ else
21
+ rsession.destroy
22
+ end
23
+ end
24
+
25
+ def self.included(base)
26
+ base.__send__(:before_filter, :rsession_auth)
27
+ end
28
+ end
29
+
30
+ module RsessionHelper
31
+ def rsession
32
+ @__rsession ||= RsessionHelper.from_session(self.session)
33
+ end
34
+
35
+ def self.from_session(session)
36
+ Reactor::Session.new(
37
+ # This passes the very powerfull rails session object
38
+ SessionState.new(session)
39
+ )
40
+ end
41
+ end
42
+
43
+ class SessionState < Reactor::Session::State
44
+ USER_NAME_KEY = "rsession$user_name"
45
+ SESSION_ID_KEY = "rsession$session_id"
46
+
47
+ def initialize(session)
48
+ self.session = session
49
+ super(session[USER_NAME_KEY], session[SESSION_ID_KEY])
50
+ end
51
+
52
+ def user_name=(new_user_name)
53
+ # this is a little bit of magic: it will trigger
54
+ # the the session serialization routine, and will
55
+ # persist the new information after processing the request
56
+ self.session[USER_NAME_KEY] = new_user_name
57
+ new_user_name
58
+ end
59
+
60
+ def session_id=(new_session_id)
61
+ # see above
62
+ self.session[SESSION_ID_KEY] = new_session_id
63
+ new_session_id
64
+ end
65
+
66
+ protected
67
+ attr_accessor :session
68
+ end
69
+ end
70
+ end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Reactor
3
- VERSION = "1.22.6"
3
+ VERSION = "1.23.0.beta2"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_reactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.6
4
+ version: 1.23.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Przedmojski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-04 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -178,6 +178,7 @@ files:
178
178
  - lib/reactor/session.rb
179
179
  - lib/reactor/session/observers.rb
180
180
  - lib/reactor/session/user.rb
181
+ - lib/reactor/session_helper.rb
181
182
  - lib/reactor/streaming_upload.rb
182
183
  - lib/reactor/sudo.rb
183
184
  - lib/reactor/support/link_matcher.rb
@@ -213,9 +214,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
214
  version: '0'
214
215
  required_rubygems_version: !ruby/object:Gem::Requirement
215
216
  requirements:
216
- - - '>='
217
+ - - '>'
217
218
  - !ruby/object:Gem::Version
218
- version: '0'
219
+ version: 1.3.1
219
220
  requirements: []
220
221
  rubyforge_project:
221
222
  rubygems_version: 2.0.14.1