stytch 3.1.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stytch/sessions.rb +11 -3
- data/lib/stytch/version.rb +1 -1
- data/stytch.gemspec +3 -1
- metadata +25 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ae3fdbca4b9b650bd1efe53244d9752888ec610edfb92393b3c593d638ac219
|
4
|
+
data.tar.gz: 49d50b9bf2b9544bfc93b3e586fdf89efeefe3837bd1df07ce9eabdf9df1397c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e8a04d1eed6cced36ad8568b52794d3ca33ba181637739ec47553ba44957c72f5e1a1820c2a083005a69b5a204cb7946d73c58c342321bd87bd74a951ceb4f
|
7
|
+
data.tar.gz: 145f04af5a49a3a7d40f96fd35c9947e642e192e2d8fc7b572f12ed8d5dc3a22a7e5594bb94b68799fa380d9d233c90266e497ab86463c6ada6cf8144b64df73
|
data/lib/stytch/sessions.rb
CHANGED
@@ -88,6 +88,12 @@ module Stytch
|
|
88
88
|
session_duration_minutes: session_duration_minutes,
|
89
89
|
)
|
90
90
|
end
|
91
|
+
rescue StandardError
|
92
|
+
# JWT could not be verified locally. Check with the Stytch API.
|
93
|
+
return authenticate(
|
94
|
+
session_jwt: session_jwt,
|
95
|
+
session_duration_minutes: session_duration_minutes,
|
96
|
+
)
|
91
97
|
end
|
92
98
|
|
93
99
|
# Parse a JWT and verify the signature locally (without calling /authenticate in the API)
|
@@ -97,7 +103,7 @@ module Stytch
|
|
97
103
|
def authenticate_jwt_local(session_jwt)
|
98
104
|
issuer = "stytch.com/" + @project_id
|
99
105
|
begin
|
100
|
-
decoded_token = JWT.decode session_jwt, nil, true,
|
106
|
+
decoded_token = JWT.decode session_jwt, nil, true,
|
101
107
|
{ jwks: @jwks_loader, iss: issuer, verify_iss: true, aud: @project_id, verify_aud: true, algorithms: ["RS256"]}
|
102
108
|
return decoded_token[0]
|
103
109
|
rescue JWT::InvalidIssuerError
|
@@ -113,12 +119,14 @@ module Stytch
|
|
113
119
|
|
114
120
|
def marshal_jwt_into_session(jwt)
|
115
121
|
stytch_claim = "https://stytch.com/session"
|
122
|
+
expires_at = jwt[stytch_claim]["expires_at"] || Time.at(jwt["exp"]).to_datetime.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
|
116
123
|
return {
|
117
|
-
"session_id" => jwt["
|
124
|
+
"session_id" => jwt[stytch_claim]["id"],
|
118
125
|
"user_id" => jwt["sub"],
|
119
126
|
"started_at" => jwt[stytch_claim]["started_at"],
|
120
127
|
"last_accessed_at" => jwt[stytch_claim]["last_accessed_at"],
|
121
|
-
|
128
|
+
# For JWTs that include it, prefer the inner expires_at claim.
|
129
|
+
"expires_at" => expires_at,
|
122
130
|
"attributes" => jwt[stytch_claim]["attributes"],
|
123
131
|
"authentication_factors" => jwt[stytch_claim]["authentication_factors"],
|
124
132
|
}
|
data/lib/stytch/version.rb
CHANGED
data/stytch.gemspec
CHANGED
@@ -27,6 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_dependency 'faraday', '>= 0.17.0', '< 2.0'
|
29
29
|
spec.add_dependency 'faraday_middleware', '>= 0.14.0', '< 2.0'
|
30
|
-
spec.add_dependency 'jwt', '>= 2.3.0'
|
31
30
|
spec.add_dependency 'json-jwt', '>=1.13.0'
|
31
|
+
spec.add_dependency 'jwt', '>= 2.3.0'
|
32
|
+
|
33
|
+
spec.add_development_dependency 'test-unit', '>=3.5.3'
|
32
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stytch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- stytch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -50,6 +50,20 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '2.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: json-jwt
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.13.0
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.13.0
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
name: jwt
|
55
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,20 +79,20 @@ dependencies:
|
|
65
79
|
- !ruby/object:Gem::Version
|
66
80
|
version: 2.3.0
|
67
81
|
- !ruby/object:Gem::Dependency
|
68
|
-
name:
|
82
|
+
name: test-unit
|
69
83
|
requirement: !ruby/object:Gem::Requirement
|
70
84
|
requirements:
|
71
85
|
- - ">="
|
72
86
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
74
|
-
type: :
|
87
|
+
version: 3.5.3
|
88
|
+
type: :development
|
75
89
|
prerelease: false
|
76
90
|
version_requirements: !ruby/object:Gem::Requirement
|
77
91
|
requirements:
|
78
92
|
- - ">="
|
79
93
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
81
|
-
description:
|
94
|
+
version: 3.5.3
|
95
|
+
description:
|
82
96
|
email:
|
83
97
|
- support@stytch.com
|
84
98
|
executables: []
|
@@ -118,7 +132,7 @@ licenses:
|
|
118
132
|
metadata:
|
119
133
|
homepage_uri: https://stytch.com
|
120
134
|
source_code_uri: https://github.com/stytchauth/stytch-ruby
|
121
|
-
post_install_message:
|
135
|
+
post_install_message:
|
122
136
|
rdoc_options: []
|
123
137
|
require_paths:
|
124
138
|
- lib
|
@@ -133,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
147
|
- !ruby/object:Gem::Version
|
134
148
|
version: '0'
|
135
149
|
requirements: []
|
136
|
-
rubygems_version: 3.
|
137
|
-
signing_key:
|
150
|
+
rubygems_version: 3.1.6
|
151
|
+
signing_key:
|
138
152
|
specification_version: 4
|
139
153
|
summary: Stytch Ruby Gem
|
140
154
|
test_files: []
|