standard_id-google 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f22ca920dcb306788b3588bf99ac704b9ce5e40cbb9c423a551e064ab6b236a9
4
- data.tar.gz: f8492f9d9af4dbf74af4062524e0c217e20e50ec3420605a76d363154cacc2f5
3
+ metadata.gz: 459021f16aaa8a5fa33bfcf4e1cbf310d9fe2873a8e899db7934325f605869d8
4
+ data.tar.gz: 929ccecf7bf0e0e1dac6488582d2996c065fb089a75d59fbaae3bb8e79a3a0e1
5
5
  SHA512:
6
- metadata.gz: 9b8d7e1bb7bdfa6302108521bf603a8727a61cd2a6893dcfd8ed230f9999697aa627f912b870528833f9b4781cbe1dbd868f761bdec013ae6cb7ff3a2f8af004
7
- data.tar.gz: 53b44b47d85d30da76de8dbdf1f55953c3b3f4a31fb3808c769b8a72175210d8ac0fdbbbbbe0d52eb7e45817666d17edd5ce2947b1dfc16462d3f12d92226544
6
+ metadata.gz: d8e1379e1de46a1cd29ae97a5e44640132cfa4d7d4756249ff6b3ac67df7a3a1562c59cb72227d201d9d443124579f95028bd1326c9a88de05a289ddb5519cd8
7
+ data.tar.gz: 8229c09170a9f4b8a76d02fc4b262d0d1d63516a9db56597beb1a3e724713ee496e54cedf60ae1ce5859c6683d047cfe67153ed0a7fcbf9d12f584fc213b56c4
data/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.6.0] - 2026-10-02
11
+
12
+ Pairs with **standard_id 0.44.0** (security fix L1-01), which matches returning
13
+ social logins on the provider's `sub` and links an existing account only when
14
+ the provider reports `email_verified`.
15
+
16
+ ### Fixed
17
+
18
+ - **The code-exchange and access-token paths now return `sub` and
19
+ `email_verified`.** They read Google's OAuth2 v2 userinfo endpoint, which
20
+ calls those claims `id` and `verified_email`, and returned its JSON as-is, so
21
+ standard_id never saw a subject for web (code) or native access-token
22
+ sign-ins. `fetch_user_info` now adds `sub` (from `id`) and `email_verified`
23
+ (from `verified_email`), keeping the original keys, and raises
24
+ `StandardId::InvalidRequestError` if the userinfo subject differs from the
25
+ `sub` tokeninfo reported for the access token. The ID-token path already
26
+ returned both claims (`email_verified` arrives there as the string `"true"`,
27
+ which standard_id 0.44 accepts).
28
+
29
+ ### Upgrade
30
+
31
+ - Bump together with standard_id 0.44.0. On standard_id < 0.44 the extra keys
32
+ are ignored, so this release is also safe on its own.
33
+
34
+ ### Changed
35
+
36
+ - **Requires Rails 8.1** (`activesupport >= 8.1`, was `>= 8.0`). Every
37
+ consumer app already runs 8.1; 8.0 was never exercised in CI.
38
+
10
39
  ## [0.5.0] - 2026-09-24
11
40
 
12
41
  Adopts the provider-plugin API of standard_id 0.42.
@@ -160,14 +160,14 @@ module StandardId
160
160
  rescue_to_oauth_error do
161
161
  raise StandardId::InvalidRequestError, "Google access token is missing" if access_token.blank?
162
162
 
163
- verify_token(access_token)
163
+ token_info = verify_token(access_token)
164
164
  user_response = HttpClient.get_with_bearer(USERINFO_ENDPOINT, access_token)
165
165
 
166
166
  unless user_response.is_a?(Net::HTTPSuccess)
167
167
  raise StandardId::InvalidRequestError, "Failed to fetch Google user info: HTTP #{user_response.code}"
168
168
  end
169
169
 
170
- JSON.parse(user_response.body)
170
+ with_oidc_claims(JSON.parse(user_response.body), token_info)
171
171
  end
172
172
  end
173
173
 
@@ -200,6 +200,28 @@ module StandardId
200
200
  token_info
201
201
  end
202
202
 
203
+ # The v2 userinfo endpoint names the subject `id` and the verified
204
+ # flag `verified_email`. standard_id (>= 0.44) matches returning
205
+ # logins on the OIDC `sub` and links existing accounts only on
206
+ # `email_verified`, so add both claims; the original keys are kept.
207
+ # The subject must agree with the one tokeninfo reported for the
208
+ # access token, when it reported one.
209
+ def with_oidc_claims(user_info, token_info)
210
+ return user_info unless user_info.is_a?(Hash)
211
+
212
+ claims = user_info.dup
213
+ claims["sub"] = claims["id"].to_s.presence if claims["sub"].blank?
214
+ claims["email_verified"] = claims["verified_email"] if !claims.key?("email_verified") && claims.key?("verified_email")
215
+ claims.compact!
216
+
217
+ token_sub = token_info.is_a?(Hash) ? token_info["sub"].to_s.presence : nil
218
+ if token_sub && claims["sub"] && token_sub != claims["sub"].to_s
219
+ raise StandardId::InvalidRequestError, "Google user info does not match the access token"
220
+ end
221
+
222
+ claims
223
+ end
224
+
203
225
  def error_reason(response)
204
226
  body = JSON.parse(response.body.to_s)
205
227
  reason = body["error"] if body.is_a?(Hash)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module StandardId
4
4
  module Google
5
- VERSION = "0.5.0"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard_id-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaryl Sim
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '8.0'
18
+ version: '8.1'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '8.0'
25
+ version: '8.1'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: standard_id
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 4.0.3
79
+ rubygems_version: 4.0.10
80
80
  specification_version: 4
81
81
  summary: Google Sign In provider plugin for the StandardId engine.
82
82
  test_files: []