ask-auth 0.3.1 → 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 +4 -4
- data/CHANGELOG.md +27 -0
- data/lib/ask/auth/providers/oauth.rb +11 -3
- data/lib/ask/auth/version.rb +1 -1
- data/lib/ask/auth.rb +15 -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: 62fd78e86d9cb1014d3c1edc874b037073fc8fda38247c10441401b88c96cb43
|
|
4
|
+
data.tar.gz: c836b2db286075e95d081aa483762bf17f4332d4c306bb4a58cfd5d1323272ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9ade8a91063788a2e247c72b189f850debaad6144c5f2270cbf900354aa2d366a127ac1f6d862b3197d944cc201dc582ca7d86fb2f8a6ba7c9e6acc8ccac1775
|
|
7
|
+
data.tar.gz: c924696e695d30d1d35367ae00e96293add344374e316d7deccca93ad2b5afad85103537c64cac90783f18866ef41c43d5deb5db9ddaf1adf62a1a460d2fd25b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
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
|
+
|
|
17
|
+
## [0.3.2] — 2026-08-13
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **`Ask::Auth.lookup` — non-raising credential resolution.** Same chain and
|
|
22
|
+
fallback semantics as `resolve`, but returns `nil` when nothing matches
|
|
23
|
+
instead of raising `MissingCredential`. For config-time resolution (e.g.
|
|
24
|
+
ERB in `database.yml`) where a missing credential should degrade to
|
|
25
|
+
nil/defaults rather than crash the boot. `resolve` is now implemented on
|
|
26
|
+
top of `lookup` and keeps its raising behavior.
|
|
27
|
+
|
|
1
28
|
## [0.3.1] — 2026-08-07
|
|
2
29
|
|
|
3
30
|
### 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,
|
|
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)
|
|
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
|
data/lib/ask/auth/version.rb
CHANGED
data/lib/ask/auth.rb
CHANGED
|
@@ -74,7 +74,21 @@ module Ask
|
|
|
74
74
|
#
|
|
75
75
|
# +names+:: One or more Symbols, Strings, or Arrays identifying the credential
|
|
76
76
|
# +user+:: Optional user record for per-user providers (Database, OAuth)
|
|
77
|
+
#
|
|
78
|
+
# Raises MissingCredential when nothing matches. Use +lookup+ for a
|
|
79
|
+
# non-raising variant.
|
|
77
80
|
def resolve(*names, user: nil)
|
|
81
|
+
value = lookup(*names, user: user)
|
|
82
|
+
return value unless value.nil?
|
|
83
|
+
|
|
84
|
+
raise MissingCredential, names
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Non-raising variant of +resolve+: returns nil when no provider
|
|
88
|
+
# matches, instead of raising MissingCredential. For config-time
|
|
89
|
+
# resolution (e.g. ERB in database.yml) where a missing credential
|
|
90
|
+
# should degrade to nil/defaults rather than crash the boot.
|
|
91
|
+
def lookup(*names, user: nil)
|
|
78
92
|
return nil if names.empty?
|
|
79
93
|
|
|
80
94
|
names.each do |name|
|
|
@@ -92,7 +106,7 @@ module Ask
|
|
|
92
106
|
end
|
|
93
107
|
end
|
|
94
108
|
|
|
95
|
-
|
|
109
|
+
nil
|
|
96
110
|
end
|
|
97
111
|
|
|
98
112
|
private
|
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.
|
|
4
|
+
version: 0.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kaka Ruto
|
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
110
110
|
- !ruby/object:Gem::Version
|
|
111
111
|
version: '0'
|
|
112
112
|
requirements: []
|
|
113
|
-
rubygems_version: 4.0.
|
|
113
|
+
rubygems_version: 4.0.18
|
|
114
114
|
specification_version: 4
|
|
115
115
|
summary: Credential resolution for the ask-rb ecosystem
|
|
116
116
|
test_files: []
|