jwt-auth 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jwt/auth/token.rb +27 -15
- data/version.yml +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f8c312085d293598d22b4f524932f282f68e39ade3ba31e315665420c278f78
|
4
|
+
data.tar.gz: e2211deaea7d353ed280c0f94df7f0035ffd773a1db7365c185bd6e72828b71a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69a5de0fe797c6b77bbaad79cdfb4415efb1dd1d41920d292d4034f04b2ce243e212a7de181103f5098c38f5a174facf42e71e0bb8ab87773161cbfe940039b0
|
7
|
+
data.tar.gz: 664f79452ae146be44c8c4b8e47e753930c2b1408eece4426aa1e139c41cdc901bb52adb305b4fe39de3a6f4c8af1690622b63e3fea1768bb16dc827638be8fb
|
data/lib/jwt/auth/token.rb
CHANGED
@@ -50,29 +50,41 @@ module JWT
|
|
50
50
|
|
51
51
|
class << self
|
52
52
|
def from_jwt(token)
|
53
|
-
|
53
|
+
payload = JWT.decode(token, JWT::Auth.secret).first
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
token = token_for payload['typ']
|
56
|
+
|
57
|
+
token ? token.new(parse payload) : nil
|
58
|
+
rescue JWT::DecodeError
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
##
|
65
|
+
# Parse raw JWT payload into params object used to initialize a token class
|
66
|
+
#
|
67
|
+
def parse(payload)
|
68
|
+
{
|
69
|
+
:issued_at => payload['iat'],
|
70
|
+
:version => payload['ver'],
|
71
|
+
:subject => model.find_by_token(:id => payload['sub'],
|
72
|
+
:token_version => payload['ver'])
|
60
73
|
}
|
74
|
+
end
|
61
75
|
|
62
|
-
|
76
|
+
##
|
77
|
+
# Determine token class based on type identifier
|
78
|
+
#
|
79
|
+
def token_for(type)
|
80
|
+
case type
|
63
81
|
when 'access'
|
64
|
-
|
82
|
+
AccessToken
|
65
83
|
when 'refresh'
|
66
|
-
|
67
|
-
else
|
68
|
-
return nil
|
84
|
+
RefreshToken
|
69
85
|
end
|
70
|
-
rescue JWT::DecodeError
|
71
|
-
nil
|
72
86
|
end
|
73
87
|
|
74
|
-
private
|
75
|
-
|
76
88
|
def model
|
77
89
|
const_get JWT::Auth.model
|
78
90
|
end
|
data/version.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--- 5.0.
|
1
|
+
--- 5.0.1
|
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: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Dejonckheere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|