ask-auth 0.3.2 → 0.3.3

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: 62fd78e86d9cb1014d3c1edc874b037073fc8fda38247c10441401b88c96cb43
4
+ data.tar.gz: c836b2db286075e95d081aa483762bf17f4332d4c306bb4a58cfd5d1323272ac
5
5
  SHA512:
6
- metadata.gz: 90118e173e9fa7e9a675dacb331d14fe179f006b72679c2201a3395b121f0637dd91058f99efa098a1aefcf33224f730c40ce5bcbe9a80b37932edcfef73f791
7
- data.tar.gz: 73b8d4681b7a3a74a7f92600e26c819e9123b796975d4100e6784fcb948f9412fecef3c7791dd095f41f114a00dadf59ed05c0e4f04eb9dddaee22fd74e5bba9
6
+ metadata.gz: 9ade8a91063788a2e247c72b189f850debaad6144c5f2270cbf900354aa2d366a127ac1f6d862b3197d944cc201dc582ca7d86fb2f8a6ba7c9e6acc8ccac1775
7
+ data.tar.gz: c924696e695d30d1d35367ae00e96293add344374e316d7deccca93ad2b5afad85103537c64cac90783f18866ef41c43d5deb5db9ddaf1adf62a1a460d2fd25b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [0.3.3] — 2026-08-18
2
+
3
+ ### Fixed
4
+
5
+ - **`OAuth#fetch_oauth_state` tolerates string keys.** Cookie session stores
6
+ serialize to JSON, converting symbol keys to strings. The verifier lookup
7
+ now falls back to `value[key.to_s]` when the symbol lookup returns nil.
8
+
9
+ ### Added
10
+
11
+ - **`OAuth` accepts `client_secret:` for token exchange.** Providers that
12
+ require a client secret (e.g. GitHub OAuth) can now pass it at
13
+ construction. The secret is included in `token_exchange` and `refresh`
14
+ requests when present, and omitted when nil — preserving backwards
15
+ compatibility with PKCE-only flows.
16
+
1
17
  ## [0.3.2] — 2026-08-13
2
18
 
3
19
  ### 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,6 +123,7 @@ module Ask
121
123
  def token_exchange(**params)
122
124
  raise OAuthError, "token_url not configured" if @token_url.to_s.empty?
123
125
 
126
+ params[:client_secret] = client_secret if client_secret
124
127
  status, body = @http.post_form(@token_url, params)
125
128
  raise OAuthError, "token exchange failed (#{status}): #{body.to_s[0, 200]}" unless status == 200
126
129
 
@@ -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.3"
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto