isomorfeus-transport 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '014479eeaec2d02e863f3e71fad9dd13baa99b99103cd46a922929aba1a7311c'
|
4
|
+
data.tar.gz: 4b88a670a325f1c834bc35259ace1f396cdc9611442f2f3f10cc3c00227616f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6187c2351668a657d6ddf6e14e881b1dd509b13d0d216174e0f483c611550f3c1f1b933b7b9881bf1ffec2d65a8247848062dd4d2769f220f234d6a97697196f
|
7
|
+
data.tar.gz: d7a94c2543aaf0e56fad460f8d52142b669b8d44530368da9cfbd11a63f40244c70b0ad1d281d3e444ff9ba9739668d1e5454ccecd70167298839b84e5608bde
|
@@ -33,9 +33,7 @@ module Isomorfeus
|
|
33
33
|
session_id = SecureRandom.uuid
|
34
34
|
session_cookie = "session=#{session_id}; SameSite=Strict; HttpOnly; Path=/; Max-Age=2592000#{'; Secure' if Isomorfeus.production?}"
|
35
35
|
session_cookie_accessor = SecureRandom.uuid
|
36
|
-
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_user, user)
|
37
36
|
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_authentication_tries, nil)
|
38
|
-
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_session_cookie, session_cookie)
|
39
37
|
Isomorfeus.session_store.add(session_id: session_id, cookie: session_cookie, user: user, accessor: session_cookie_accessor)
|
40
38
|
response_agent.agent_result = { success: 'ok', data: user.to_transport, session_cookie_accessor: session_cookie_accessor }
|
41
39
|
end
|
@@ -45,9 +43,7 @@ module Isomorfeus
|
|
45
43
|
session_id = response_agent.request['ssr_login']
|
46
44
|
user = Isomorfeus.session_store.get_user(session_id: session_id)
|
47
45
|
if user
|
48
|
-
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_user, user)
|
49
46
|
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_authentication_tries, nil)
|
50
|
-
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_session_cookie, nil)
|
51
47
|
response_agent.agent_result = { success: 'ok', data: user.to_transport }
|
52
48
|
end
|
53
49
|
end
|
@@ -9,10 +9,24 @@ module Isomorfeus
|
|
9
9
|
@app = app
|
10
10
|
end
|
11
11
|
|
12
|
+
def user_from_env(env)
|
13
|
+
cookies = env['HTTP_COOKIE']
|
14
|
+
if cookies
|
15
|
+
cookies = cookies.split('; ')
|
16
|
+
cookie = cookies.detect { |c| c.start_with?('session=') }
|
17
|
+
if cookie
|
18
|
+
session_id = cookie[8..-1]
|
19
|
+
user = Isomorfeus.session_store.get_user(session_id: session_id)
|
20
|
+
[user, session_id]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
12
25
|
def call(env)
|
13
26
|
if env['PATH_INFO'] == Isomorfeus.api_websocket_path
|
14
27
|
if env['rack.upgrade?'] == :websocket
|
15
|
-
|
28
|
+
user, _session_id = user_from_env(env)
|
29
|
+
env['rack.upgrade'] = Isomorfeus::Transport::ServerSocketProcessor.new(user)
|
16
30
|
end
|
17
31
|
WS_RESPONSE
|
18
32
|
elsif env['PATH_INFO'] == Isomorfeus.cookie_eater_path
|
@@ -28,39 +42,23 @@ module Isomorfeus
|
|
28
42
|
[404, {}, ["Must specify relative path!"]]
|
29
43
|
end
|
30
44
|
elsif env['PATH_INFO'] == Isomorfeus.api_logout_path
|
31
|
-
|
32
|
-
if
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
Isomorfeus.session_store.remove(session_id: session_id)
|
41
|
-
cookie = "session=#{session_id}; SameSite=Strict; HttpOnly; Path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC#{'; Secure' if Isomorfeus.production?}"
|
42
|
-
return [302, { 'Location' => '/', 'Set-Cookie' => cookie }, ["Logged out!"]]
|
43
|
-
ensure
|
44
|
-
Thread.current[:isomorfeus_user] = nil
|
45
|
-
Thread.current[:isomorfeus_session_id] = nil
|
46
|
-
end
|
47
|
-
end
|
45
|
+
user, session_id = user_from_env(env)
|
46
|
+
if user
|
47
|
+
begin
|
48
|
+
Isomorfeus.session_store.remove(session_id: session_id)
|
49
|
+
cookie = "session=#{session_id}; SameSite=Strict; HttpOnly; Path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC#{'; Secure' if Isomorfeus.production?}"
|
50
|
+
return [302, { 'Location' => '/', 'Set-Cookie' => cookie }, ["Logged out!"]]
|
51
|
+
ensure
|
52
|
+
Thread.current[:isomorfeus_user] = nil
|
53
|
+
Thread.current[:isomorfeus_session_id] = nil
|
48
54
|
end
|
49
55
|
end
|
50
56
|
return [302, { 'Location' => '/', 'Set-Cookie' => cookie }, ["Tried to log out!"]]
|
51
57
|
else
|
52
|
-
|
53
|
-
if
|
54
|
-
|
55
|
-
|
56
|
-
if cookie
|
57
|
-
session_id = cookie[8..-1]
|
58
|
-
user = Isomorfeus.session_store.get_user(session_id: session_id)
|
59
|
-
if user
|
60
|
-
Thread.current[:isomorfeus_user] = user
|
61
|
-
Thread.current[:isomorfeus_session_id] = session_id
|
62
|
-
end
|
63
|
-
end
|
58
|
+
user, session_id = user_from_env(env)
|
59
|
+
if user
|
60
|
+
Thread.current[:isomorfeus_user] = user
|
61
|
+
Thread.current[:isomorfeus_session_id] = session_id
|
64
62
|
end
|
65
63
|
begin
|
66
64
|
result = @app.call(env)
|
@@ -3,6 +3,10 @@ module Isomorfeus
|
|
3
3
|
class ServerSocketProcessor
|
4
4
|
include Isomorfeus::Transport::ServerProcessor
|
5
5
|
|
6
|
+
def initialize(user)
|
7
|
+
@user = user
|
8
|
+
end
|
9
|
+
|
6
10
|
def on_message(client, data)
|
7
11
|
if Isomorfeus.development?
|
8
12
|
write_lock = Isomorfeus.zeitwerk_lock.try_write_lock
|
@@ -45,9 +49,7 @@ module Isomorfeus
|
|
45
49
|
end
|
46
50
|
|
47
51
|
def user(client)
|
48
|
-
|
49
|
-
return current_user if current_user
|
50
|
-
Anonymous.new
|
52
|
+
@user ||= Anonymous.new
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 2.0.
|
131
|
+
version: 2.0.2
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 2.0.
|
138
|
+
version: 2.0.2
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: isomorfeus-redux
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - '='
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 2.0.
|
173
|
+
version: 2.0.2
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - '='
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 2.0.
|
180
|
+
version: 2.0.2
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: rake
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|