infopark_reactor 1.22.6 → 1.23.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reactor/engine.rb +4 -28
- data/lib/reactor/session.rb +40 -20
- data/lib/reactor/session_helper.rb +70 -0
- data/lib/reactor/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07d1a2447746fc85e6dbbec92b8999053f9a1f9a
|
4
|
+
data.tar.gz: 1fc2128aafa6d33799f34f030bf5fb817a249ecd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df3a64681d484882e178f6331f4ecf668ea9827579a3521555d9840dad8bb6bbb976719ba6d12b441384676362b7bae388160898c59b6c3c0aa825ec3a80c8d1
|
7
|
+
data.tar.gz: 7998b90a010e9e8e77bcfddcde22ca2d268ab630f7324b0c5eee9d2a48617bef59065479c86a3ea27acc735bef5a5cbbb92c94d8ef91b080e6878ee67a8f78d1
|
data/lib/reactor/engine.rb
CHANGED
@@ -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
|
-
|
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__(:
|
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
|
data/lib/reactor/session.rb
CHANGED
@@ -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
|
-
|
13
|
-
|
14
|
-
|
11
|
+
class State < Struct.new(:user_name, :session_id)
|
12
|
+
def serialize
|
13
|
+
[self.user_name, self.session_id]
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
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
|
24
|
-
|
21
|
+
def initialize(state=State.new)
|
22
|
+
self.initialize_and_notify(state)
|
25
23
|
end
|
26
24
|
|
27
|
-
def
|
28
|
-
|
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
|
34
|
-
self.
|
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
|
-
|
62
|
-
self.proper_notify_observers(
|
63
|
-
|
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
|
-
|
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
|
data/lib/reactor/version.rb
CHANGED
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.
|
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-
|
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:
|
219
|
+
version: 1.3.1
|
219
220
|
requirements: []
|
220
221
|
rubyforge_project:
|
221
222
|
rubygems_version: 2.0.14.1
|