ask-auth 0.3.2 → 0.3.4

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: d41ca49d1114503dc3a3830efb730823fd598c1dca1249b2c06bc808be7c4743
4
- data.tar.gz: 17b4718e99c515ba26424ce90b104ad4dfc416871e2ee2598ff5f62b67524bd7
3
+ metadata.gz: 8b6984f31cfde1336e6309204570981998b06055ab1be0a8112f9e30a947eac9
4
+ data.tar.gz: 4eb5d482ff745689d26b53378358c6cab098a30583ade8549b93298977bf2980
5
5
  SHA512:
6
- metadata.gz: 90118e173e9fa7e9a675dacb331d14fe179f006b72679c2201a3395b121f0637dd91058f99efa098a1aefcf33224f730c40ce5bcbe9a80b37932edcfef73f791
7
- data.tar.gz: 73b8d4681b7a3a74a7f92600e26c819e9123b796975d4100e6784fcb948f9412fecef3c7791dd095f41f114a00dadf59ed05c0e4f04eb9dddaee22fd74e5bba9
6
+ metadata.gz: 4281565d7ff34c10b2f1c2d8cbbdd669748fb1f4037fc1ef7ecb132f22cb4b821658ca7c5e39d228ec7a1ebe5148e6adf2892cd34191a121900297b81891b861
7
+ data.tar.gz: 4f5227bd2484737269442f9af081df85f5f72670d50206c0e01d431338193a58e36aa074aeb9e8d9244dd0687975c6c2d1b280e7edb20116454fcdddea830d65
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## [0.3.4] — 2026-08-18
2
+
3
+ ### Fixed
4
+
5
+ - **Token exchange requests JSON by default.** Added `Accept: application/json`
6
+ header to `token_exchange` so providers that default to form-encoded
7
+ responses (e.g. GitHub) return parseable JSON.
8
+
9
+ ## [0.3.3] — 2026-08-18
10
+
11
+ ### Fixed
12
+
13
+ - **`OAuth#fetch_oauth_state` tolerates string keys.** Cookie session stores
14
+ serialize to JSON, converting symbol keys to strings. The verifier lookup
15
+ now falls back to `value[key.to_s]` when the symbol lookup returns nil.
16
+
17
+ ### Added
18
+
19
+ - **`OAuth` accepts `client_secret:` for token exchange.** Providers that
20
+ require a client secret (e.g. GitHub OAuth) can now pass it at
21
+ construction. The secret is included in `token_exchange` and `refresh`
22
+ requests when present, and omitted when nil — preserving backwards
23
+ compatibility with PKCE-only flows.
24
+
1
25
  ## [0.3.2] — 2026-08-13
2
26
 
3
27
  ### Added
@@ -29,12 +29,14 @@ module Ask
29
29
  # Subclasses override #parse_token_response to add provider-specific
30
30
  # fields (e.g. an account id from the id_token).
31
31
  class OAuth
32
- attr_reader :client_id, :redirect_uri
32
+ attr_reader :client_id, :client_secret, :redirect_uri
33
33
 
34
- def initialize(storage: nil, client_id: nil, authorize_url: nil, token_url: nil,
34
+ def initialize(storage: nil, client_id: nil, client_secret: nil,
35
+ authorize_url: nil, token_url: nil,
35
36
  redirect_uri: nil, scope: nil, http: Ask::Auth::OAuth::HTTP)
36
37
  @storage = storage
37
38
  @client_id = client_id
39
+ @client_secret = client_secret
38
40
  @authorize_url = authorize_url
39
41
  @token_url = token_url
40
42
  @redirect_uri = redirect_uri
@@ -121,7 +123,8 @@ module Ask
121
123
  def token_exchange(**params)
122
124
  raise OAuthError, "token_url not configured" if @token_url.to_s.empty?
123
125
 
124
- status, body = @http.post_form(@token_url, params)
126
+ params[:client_secret] = client_secret if client_secret
127
+ status, body = @http.post_form(@token_url, params, headers: { "Accept" => "application/json" })
125
128
  raise OAuthError, "token exchange failed (#{status}): #{body.to_s[0, 200]}" unless status == 200
126
129
 
127
130
  body
@@ -153,7 +156,12 @@ module Ask
153
156
  return nil unless @storage.respond_to?(:fetch) && user
154
157
 
155
158
  value = @storage.fetch(:oauth_state, user: user)
156
- value.is_a?(Hash) ? value[key] : nil
159
+ return nil unless value.is_a?(Hash)
160
+
161
+ # Symbol keys survive Ruby→JSON→Ruby round-trips, but cookie
162
+ # session stores serialize to JSON (converting symbols to strings).
163
+ # Support both by falling back to the string representation.
164
+ value[key] || value[key.to_s]
157
165
  end
158
166
  end
159
167
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module Auth
5
- VERSION = "0.3.2"
5
+ VERSION = "0.3.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto