anycable-rails-jwt 0.1.0 → 0.2.0
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/CHANGELOG.md +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +25 -1
- data/lib/anycable/rails/jwt/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05712c4f8339d089c73fb8a23c4cb1a185f7c00c18561145c454c119c54a8651
|
4
|
+
data.tar.gz: 64b6c9ffd9dc13a7750bf4e5728653f0e08740314952b39573e4bacbac71afbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a7da5fc88d87a21ea118037436f7ee4612a6afcdf0acbbe1fd8a3713b479baf7692d684f8dfd0a23cf53fd6ed18f6af82794fe49349ef4f014b872709c53fcf
|
7
|
+
data.tar.gz: 79035b6aa1581ceaf3295d809f493a7ff967448b178ff46e21e98986ae25c75f60a7b30fac3c2f6516171b5e63bf85d612841ccd1314f745c52f201e5a1c2459
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
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[:
|
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).
|
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.
|
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:
|
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.
|
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.
|
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
|