isomorfeus-transport 2.0.0 → 2.0.1
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 +4 -4
- data/README.md +3 -3
- data/lib/isomorfeus/transport/config.rb +6 -4
- data/lib/isomorfeus/transport/handler/authentication_handler.rb +3 -14
- data/lib/isomorfeus/transport/rack_middleware.rb +21 -0
- data/lib/isomorfeus/transport/version.rb +1 -1
- data/lib/lucid_authentication/mixin.rb +7 -6
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa0acbcbd591284295e444b772feb04cfd666a9ffc760f9883d6ca4e1ab92cf8
|
4
|
+
data.tar.gz: a71a263b02d3652bc2a934c2369c8e432baa8b11f4bca1c3b44202a819f4d650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1069e0e06fd752d82ef00f059c9afddb095e13b0891d14e4d3e5d2f4d27498ea2971142f8c6535566864d41aad49a804af538f6fc53cb9a65230a6555305c193
|
7
|
+
data.tar.gz: 57f34ceceea085bb19891bd4c30420aa506f8c69d6305f04eb1a8662fb9dff8089785b043bd9703caa0be3e5fd42c9d33cb02ef6b9abc7c62673393dabb13157
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Transport and PubSub for Isomorfeus.
|
4
4
|
|
5
5
|
### Community and Support
|
6
|
-
At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
6
|
+
At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
isomorfeus-transport is usually installed with the installer.
|
@@ -23,5 +23,5 @@ Server only:
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
-
- [Authentication and Current User](https://github.com/isomorfeus/isomorfeus-project/blob/master/
|
27
|
-
- [Channels (PubSub)](https://github.com/isomorfeus/isomorfeus-project/blob/master/
|
26
|
+
- [Authentication and Current User](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-transport/docs/authentication.md)
|
27
|
+
- [Channels (PubSub)](https://github.com/isomorfeus/isomorfeus-project/blob/master/isomorfeus-transport/docs/channels.md)
|
@@ -30,6 +30,7 @@ module Isomorfeus
|
|
30
30
|
add_client_option(:api_websocket_host)
|
31
31
|
add_client_option(:api_websocket_port)
|
32
32
|
add_client_option(:api_websocket_path)
|
33
|
+
add_client_option(:api_logout_path)
|
33
34
|
add_client_option(:cookie_eater_path)
|
34
35
|
add_client_option(:transport_init_class_names, [])
|
35
36
|
|
@@ -69,6 +70,7 @@ module Isomorfeus
|
|
69
70
|
attr_accessor :api_websocket_host
|
70
71
|
attr_accessor :api_websocket_port
|
71
72
|
attr_accessor :api_websocket_path
|
73
|
+
attr_accessor :api_logout_path
|
72
74
|
attr_accessor :cookie_eater_path
|
73
75
|
attr_reader :session_store
|
74
76
|
|
@@ -168,8 +170,8 @@ module Isomorfeus
|
|
168
170
|
end
|
169
171
|
|
170
172
|
self.session_store_init do
|
171
|
-
store_path = File.expand_path(File.join(Isomorfeus.root, 'data', Isomorfeus.env
|
172
|
-
Isomorfeus::Transport::HamsterSessionStore.new(store_path)
|
173
|
+
store_path = File.expand_path(File.join(Isomorfeus.root, 'data', Isomorfeus.env, 'session_store'))
|
174
|
+
Isomorfeus::Transport::HamsterSessionStore.new(store_path)
|
173
175
|
end
|
174
176
|
end
|
175
177
|
|
@@ -177,6 +179,6 @@ module Isomorfeus
|
|
177
179
|
self.api_websocket_host = 'localhost'
|
178
180
|
self.api_websocket_port = '3000'
|
179
181
|
self.api_websocket_path = '/isomorfeus/api/websocket'
|
180
|
-
|
181
|
-
self.cookie_eater_path
|
182
|
+
self.api_logout_path = '/isomorfeus/api/logout'
|
183
|
+
self.cookie_eater_path = '/isomorfeus/cookie/eat'
|
182
184
|
end
|
@@ -6,8 +6,8 @@ module Isomorfeus
|
|
6
6
|
|
7
7
|
on_request do |response_agent|
|
8
8
|
# promise_send_path('Isomorfeus::Transport::Handler::AuthenticationHandler', 'login', user_class_name, user_identifier, user_password)
|
9
|
-
response_agent.request.each_key do |
|
10
|
-
if
|
9
|
+
response_agent.request.each_key do |login_or_ssr_login|
|
10
|
+
if login_or_ssr_login == 'login'
|
11
11
|
response_agent.agent_result = { error: 'Authentication failed' }
|
12
12
|
tries = pub_sub_client.instance_variable_get(:@isomorfeus_authentication_tries)
|
13
13
|
tries = 0 unless tries
|
@@ -40,7 +40,7 @@ module Isomorfeus
|
|
40
40
|
response_agent.agent_result = { success: 'ok', data: user.to_transport, session_cookie_accessor: session_cookie_accessor }
|
41
41
|
end
|
42
42
|
end
|
43
|
-
elsif
|
43
|
+
elsif login_or_ssr_login == 'ssr_login'
|
44
44
|
response_agent.agent_result = { error: 'Authentication failed' }
|
45
45
|
session_id = response_agent.request['ssr_login']
|
46
46
|
user = Isomorfeus.session_store.get_user(session_id: session_id)
|
@@ -50,17 +50,6 @@ module Isomorfeus
|
|
50
50
|
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_session_cookie, nil)
|
51
51
|
response_agent.agent_result = { success: 'ok', data: user.to_transport }
|
52
52
|
end
|
53
|
-
elsif login_or_logout == 'logout'
|
54
|
-
begin
|
55
|
-
# bogus
|
56
|
-
session_cookie = nil
|
57
|
-
ensure
|
58
|
-
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_user, nil)
|
59
|
-
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_authentication_tries, nil)
|
60
|
-
Isomorfeus.pub_sub_client.instance_variable_set(:@isomorfeus_session_cookie, nil)
|
61
|
-
Isomorfeus.session_store.remove(cookie: session_cookie)
|
62
|
-
response_agent.agent_result = { success: 'ok' }
|
63
|
-
end
|
64
53
|
end
|
65
54
|
end
|
66
55
|
end
|
@@ -27,6 +27,27 @@ module Isomorfeus
|
|
27
27
|
else
|
28
28
|
[404, {}, ["Must specify relative path!"]]
|
29
29
|
end
|
30
|
+
elsif env['PATH_INFO'] == Isomorfeus.api_logout_path
|
31
|
+
cookies = env['HTTP_COOKIE']
|
32
|
+
if cookies
|
33
|
+
cookies = cookies.split('; ')
|
34
|
+
cookie = cookies.detect { |c| c.start_with?('session=') }
|
35
|
+
if cookie
|
36
|
+
session_id = cookie[8..-1]
|
37
|
+
user = Isomorfeus.session_store.get_user(session_id: session_id)
|
38
|
+
if user
|
39
|
+
begin
|
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
|
48
|
+
end
|
49
|
+
end
|
50
|
+
return [302, { 'Location' => '/', 'Set-Cookie' => cookie }, ["Tried to log out!"]]
|
30
51
|
else
|
31
52
|
cookies = env['HTTP_COOKIE']
|
32
53
|
if cookies
|
@@ -60,12 +60,13 @@ module LucidAuthentication
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def promise_deauthentication_with_isomorfeus
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
Isomorfeus.
|
67
|
-
|
68
|
-
|
63
|
+
cookie = `document.cookie`
|
64
|
+
p = Promise.new
|
65
|
+
begin
|
66
|
+
logout_query = Isomorfeus.api_logout_path
|
67
|
+
`window.location = logout_query`
|
68
|
+
rescue
|
69
|
+
p.reject
|
69
70
|
end
|
70
71
|
end
|
71
72
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.14.
|
89
|
+
version: 0.14.5
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.14.
|
96
|
+
version: 0.14.5
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: isomorfeus-hamster
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,28 +114,28 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 10.6.
|
117
|
+
version: 10.6.11
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 10.6.
|
124
|
+
version: 10.6.11
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: isomorfeus-policy
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 2.0.
|
131
|
+
version: 2.0.1
|
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.1
|
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.1
|
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.1
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: rake
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|