anycable-rails-jwt 0.1.0 → 0.2.0

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: 7e38b60305bc5b61376f47a37f89c09e1abb328e9c8df059cce318db9442f8e2
4
- data.tar.gz: 077eadd6f914cfa06076dbf8b58ae7884ca24d760a4184b8433301ba7e453cc4
3
+ metadata.gz: 05712c4f8339d089c73fb8a23c4cb1a185f7c00c18561145c454c119c54a8651
4
+ data.tar.gz: 64b6c9ffd9dc13a7750bf4e5728653f0e08740314952b39573e4bacbac71afbc
5
5
  SHA512:
6
- metadata.gz: b12e6a72e8fa9564922875b30df8842a4d46d5609c19ebbe74d85ce95dac9d05f127c29ebdea32fd818c20b26b31b80de32b5c18384f4265dcd50a87ee6d893f
7
- data.tar.gz: 2f2475a62ffd70990edd0e9936c39a883285a77582804f7a15a02fcb38add534320e4245ed894b62994b272f5db0fd77a3706ec1dcc502f31532632a96b25fe2
6
+ metadata.gz: 6a7da5fc88d87a21ea118037436f7ee4612a6afcdf0acbbe1fd8a3713b479baf7692d684f8dfd0a23cf53fd6ed18f6af82794fe49349ef4f014b872709c53fcf
7
+ data.tar.gz: 79035b6aa1581ceaf3295d809f493a7ff967448b178ff46e21e98986ae25c75f60a7b30fac3c2f6516171b5e63bf85d612841ccd1314f745c52f201e5a1c2459
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.2.0 (2023-07-25)
6
+
7
+ - Changed **anycable-rails** dependency to **anycable-rails-core**.
8
+ - **Ruby 2.7+** is required.
9
+
5
10
  ## 0.1.0 (2020-09-23)
6
11
 
7
12
  - Initial version.
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2021 Vladimir Dementyev
1
+ Copyright (c) 2021-2023 Vladimir Dementyev
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -58,7 +58,7 @@ module ApplicationCable
58
58
  identified_by :current_user
59
59
 
60
60
  def connect
61
- token = request.params[:token]
61
+ token = request.params[:jid]
62
62
 
63
63
  identifiers = AnyCable::Rails::JWT.decode(token)
64
64
  identifiers.each do |k, v|
@@ -71,6 +71,30 @@ module ApplicationCable
71
71
  end
72
72
  ```
73
73
 
74
+ In AnyCable a token's TTL is checked by the `anycable-go` server. In case the token is expired, the server [would disconnect with a specific reason](https://anycable.io/blog/jwt-identification-and-hot-streams/) `token_expired`.
75
+
76
+ To mimic this behavior without AnyCable, you can add a simple patch to your application connection:
77
+
78
+ ```ruby
79
+ module ApplicationCable
80
+ class Connection < ActionCable::Connection::Base
81
+ # ...
82
+
83
+ private
84
+
85
+ # Overload the +ActionCable::Connection::Base+ to handle JWT expiration
86
+ # as rejected connection with a specific reason.
87
+ # (in AnyCable this check is <also> done by the `anycable-go` server).
88
+ def handle_open
89
+ super
90
+ rescue JWT::ExpiredSignature
91
+ logger.error "An expired JWT token was rejected"
92
+ close(reason: "token_expired", reconnect: false) if websocket.alive?
93
+ end
94
+ end
95
+ end
96
+ ```
97
+
74
98
  ## Contributing
75
99
 
76
100
  Bug reports and pull requests are welcome on GitHub at [https://github.com/anycable/anycable-rails-jwt](https://github.com/anycable/anycable-rails-jwt).
@@ -3,7 +3,7 @@
3
3
  module AnyCable
4
4
  module Rails
5
5
  module JWT # :nodoc:
6
- VERSION = "0.1.0"
6
+ VERSION = "0.2.0"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable-rails-jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-23 00:00:00.000000000 Z
11
+ date: 2023-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: anycable-rails
14
+ name: anycable-rails-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
@@ -126,14 +126,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - ">="
128
128
  - !ruby/object:Gem::Version
129
- version: '2.6'
129
+ version: '2.7'
130
130
  required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  requirements:
132
132
  - - ">="
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
- rubygems_version: 3.2.15
136
+ rubygems_version: 3.4.8
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: AnyCable Rails helpers for JWT-based authentication