jwt-auth 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/jwt/auth/authenticatable.rb +1 -1
- data/lib/jwt/auth/token.rb +21 -13
- data/lib/jwt/auth/version.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4ee309e4680b104875e55bdf95fa0f54e104be4596d5a2f8249cc37e8257c95
|
4
|
+
data.tar.gz: a8816bfbfe5b1211e4ad6d81a1f902387043c3b4ea38c856811e79012e44454c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02da9f0ef071a5844531310379c1a5778ddda6f0ea7f450052449e2b6cdf46b05c2bdc667c6e14f5cc6eff97dbcd97e5038f03719e9e0f87f1736fd3210825eb
|
7
|
+
data.tar.gz: '09978d0bb5d5430f73adafc7dc2f2e6c0c0d934b952e8fc93c5a8a9f6e8116677c120d8e91820af83aa25c5ddd380d08de8f63ab8adfa0a17941b3ecb8127184'
|
data/README.md
CHANGED
@@ -34,6 +34,8 @@ JWT::Auth.configure do |config|
|
|
34
34
|
end
|
35
35
|
```
|
36
36
|
|
37
|
+
Do not try to set the `model` configuration property in the initializer, as this property is already set by including the `Authenticatable` concern in your model.
|
38
|
+
|
37
39
|
Include model methods in your user model:
|
38
40
|
|
39
41
|
```ruby
|
data/lib/jwt/auth/token.rb
CHANGED
@@ -54,23 +54,31 @@ module JWT
|
|
54
54
|
JWT::Auth.token_lifetime
|
55
55
|
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
class << self
|
58
|
+
def from_token(token)
|
59
|
+
begin
|
60
|
+
@decoded_payload = JWT.decode(token, JWT::Auth.secret).first
|
61
|
+
rescue JWT::DecodeError
|
62
|
+
@decoded_payload = {}
|
63
|
+
end
|
64
|
+
|
65
|
+
token = self.new
|
66
|
+
token.issued_at = @decoded_payload['iat']
|
67
|
+
token.token_version = @decoded_payload['ver']
|
68
|
+
|
69
|
+
if @decoded_payload['sub']
|
70
|
+
find_method = model.respond_to?(:find_by_token) ? :find_by_token : :find_by
|
71
|
+
token.subject = model.send find_method, :id => @decoded_payload['sub'], :token_version => @decoded_payload['ver']
|
72
|
+
end
|
73
|
+
|
74
|
+
token
|
62
75
|
end
|
63
76
|
|
64
|
-
|
65
|
-
token.issued_at = @decoded_payload['iat']
|
66
|
-
token.token_version = @decoded_payload['ver']
|
77
|
+
private
|
67
78
|
|
68
|
-
|
69
|
-
|
70
|
-
token.subject = JWT::Auth.model.send find_method, :id => @decoded_payload['sub'], :token_version => @decoded_payload['ver']
|
79
|
+
def model
|
80
|
+
const_get JWT::Auth.model
|
71
81
|
end
|
72
|
-
|
73
|
-
token
|
74
82
|
end
|
75
83
|
end
|
76
84
|
end
|
data/lib/jwt/auth/version.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jwt-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Dejonckheere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -278,8 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
278
|
- !ruby/object:Gem::Version
|
279
279
|
version: '0'
|
280
280
|
requirements: []
|
281
|
-
|
282
|
-
rubygems_version: 2.7.3
|
281
|
+
rubygems_version: 3.0.1
|
283
282
|
signing_key:
|
284
283
|
specification_version: 4
|
285
284
|
summary: JWT-based authentication for Rails API
|