isomorfeus-transport 2.0.0 → 2.0.1

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: f2a7d2c1a8f19bd039510a71ad4e145d49244bcd3806457af5bdad78bc4f6ecd
4
- data.tar.gz: 2c07e48156e16722515868b552878be2b8189cddebd1ca7500be7aee95a445cc
3
+ metadata.gz: fa0acbcbd591284295e444b772feb04cfd666a9ffc760f9883d6ca4e1ab92cf8
4
+ data.tar.gz: a71a263b02d3652bc2a934c2369c8e432baa8b11f4bca1c3b44202a819f4d650
5
5
  SHA512:
6
- metadata.gz: d2e6929114aa91f8a4a7e0144a33015d296febe5ac8743695e191194ae23653f49eebb430365f637f69463d8d8ef65b0a42454564ec6b80af1450a5036c22206
7
- data.tar.gz: 9cd43f123afcac86b6e1bccb305201a9e1bbced142e66650974472dadb949e678fbe8f5dcce30f9f541e8e8b85fe87265dd93a18bd593c624f9999311ed939b5
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/ruby/isomorfeus-transport/docs/authentication.md)
27
- - [Channels (PubSub)](https://github.com/isomorfeus/isomorfeus-project/blob/master/ruby/isomorfeus-transport/docs/channels.md)
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), 'session_store')
172
- Isomorfeus::Transport::HamsterSessionStore.new(store_path) # dont use this one, but we keep it here to have at least something
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 = '/isomorfeus/cookie/eat'
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 |login_or_logout|
10
- if login_or_logout == 'login'
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 login_or_logout == 'ssr_login'
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
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Transport
3
- VERSION = '2.0.0'
3
+ VERSION = '2.0.1'
4
4
  end
5
5
  end
@@ -60,12 +60,13 @@ module LucidAuthentication
60
60
  end
61
61
 
62
62
  def promise_deauthentication_with_isomorfeus
63
- Isomorfeus::Transport.promise_send_path('Isomorfeus::Transport::Handler::AuthenticationHandler', 'logout', 'logout').then do |agent|
64
- `document.cookie = "session="`
65
- Isomorfeus.set_current_user(nil)
66
- Isomorfeus.force_init_store!
67
- agent.processed = true
68
- agent.response.key?(:success) ? true : raise('Logout failed!')
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.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-15 00:00:00.000000000 Z
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.4
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.4
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.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.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.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.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.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.0
180
+ version: 2.0.1
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rake
183
183
  requirement: !ruby/object:Gem::Requirement