keycardai-oauth 0.7.1 → 0.8.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 +4 -4
- data/CHANGELOG.md +20 -0
- data/lib/keycardai/oauth/authenticate.rb +50 -1
- data/lib/keycardai/oauth/client_secret.rb +5 -1
- data/lib/keycardai/oauth/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dfd08b9f86490b46112e042f2685724041ae5ee0ee15a224d6be7066cfe792a0
|
|
4
|
+
data.tar.gz: 30270904aa434912c3c3b81ed1b3f0de92170da146bd0a12f509563f721958c4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5bc9f3ea131eaaadd12274401536b6ca7c7cf93fafe1c18e88d459339d22cbdc4602116d0b03c37628c8962218af6e25079d744be6f6b084eea872f97323a234
|
|
7
|
+
data.tar.gz: f2c8b190958fcba1e20c73736445432feec7a9bb92209d0be82e243e366a03768f45fb537d71b6aab43372e2f00f95da8cda5ece2da39a605fd80d0f088983fa
|
data/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,26 @@ the loopback flow (RFC 8252), JWT signing and verification with a caching JWKS
|
|
|
15
15
|
keyring, the three application credentials (ClientSecret with multi-zone,
|
|
16
16
|
WebIdentity, WorkloadIdentity with pluggable token sources), and AccessContext.
|
|
17
17
|
|
|
18
|
+
## 0.8.0-keycardai-oauth (2026-11-23)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
- fix(keycardai-oauth)!: require an issuer allow-list before sending client auth to a challenge-resolved issuer (#63)
|
|
22
|
+
- * fix(keycardai-oauth): require allowed_issuers before sending client auth to a challenge-resolved issuer
|
|
23
|
+
- authenticate_from_challenge takes the issuer from the protected resource's
|
|
24
|
+
metadata. With client_secret set it now requires allowed_issuers and
|
|
25
|
+
checks the resolved issuer against it before any request to that
|
|
26
|
+
issuer. SDK-120.
|
|
27
|
+
- * fix(keycardai-oauth): use a multi-zone ClientSecret's zone issuers as the challenge allow-list
|
|
28
|
+
- When allowed_issuers is unset and the credential is a multi-zone
|
|
29
|
+
ClientSecret, authenticate_from_challenge checks the resolved issuer
|
|
30
|
+
against the credential's zone issuers. An explicit allowed_issuers wins.
|
|
31
|
+
SDK-120.
|
|
32
|
+
- * fix(keycardai-oauth): validate challenge issuer allow-list entries
|
|
33
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
34
|
+
- ---------
|
|
35
|
+
- Co-authored-by: Larry Osakwe <larry@keycard.ai>
|
|
36
|
+
Co-authored-by: devin-ai-keycard <devin-ai@keycard.ai>
|
|
37
|
+
|
|
18
38
|
## 0.7.1-keycardai-oauth (2026-11-23)
|
|
19
39
|
|
|
20
40
|
|
|
@@ -102,19 +102,68 @@ module Keycardai
|
|
|
102
102
|
# Challenge-driven entry to the login flow: resolve the issuer from a
|
|
103
103
|
# WWW-Authenticate challenge, then run authenticate against it.
|
|
104
104
|
#
|
|
105
|
+
# The protected resource names the issuer, so client authentication
|
|
106
|
+
# (client_secret or credential) requires an allow-list. A multi-zone
|
|
107
|
+
# ClientSecret credential counts as the pin: with allowed_issuers unset
|
|
108
|
+
# or empty, its zone issuers are the allow-list.
|
|
109
|
+
# The resolved issuer must equal one of them, compared without a
|
|
110
|
+
# trailing slash. A public client may omit the list; when it sets one,
|
|
111
|
+
# it is enforced the same way.
|
|
112
|
+
#
|
|
105
113
|
# @param www_authenticate [String] the WWW-Authenticate header value
|
|
114
|
+
# @param allowed_issuers [Array<String>, nil] the issuers the caller
|
|
115
|
+
# trusts; overrides a multi-zone ClientSecret's zone issuers
|
|
106
116
|
# @param options [Hash] forwarded to authenticate
|
|
107
117
|
# @return [TokenResponse]
|
|
108
|
-
|
|
118
|
+
# @raise [ConfigurationError] invalid credential, an allowed_issuers entry
|
|
119
|
+
# that is not a non-empty String, or client authentication without an
|
|
120
|
+
# allow-list, before any request; or a resolved issuer outside the
|
|
121
|
+
# allow-list, after the resource metadata fetch and before any request
|
|
122
|
+
# to that issuer
|
|
123
|
+
def self.authenticate_from_challenge(www_authenticate, http_client: HTTP::NetHTTPClient.new,
|
|
124
|
+
allowed_issuers: nil, **options)
|
|
109
125
|
# Credential errors surface before the resource metadata fetch.
|
|
110
126
|
if options[:credential]
|
|
111
127
|
ClientAuth.validate(credential: options[:credential], client_id: nil, client_secret: options[:client_secret])
|
|
112
128
|
end
|
|
129
|
+
allowed, source = challenge_allow_list(allowed_issuers, options[:credential])
|
|
130
|
+
client_auth = !options[:client_secret].to_s.empty? || !options[:credential].nil?
|
|
131
|
+
if client_auth && allowed.empty?
|
|
132
|
+
raise ConfigurationError,
|
|
133
|
+
"pass allowed_issuers to send client_secret or credential to an issuer resolved from a challenge"
|
|
134
|
+
end
|
|
135
|
+
|
|
113
136
|
issuer = resolve_issuer_from_challenge(www_authenticate, http_client: http_client,
|
|
114
137
|
timeout: options[:timeout])
|
|
138
|
+
check_challenge_issuer(issuer, allowed, source)
|
|
115
139
|
authenticate(issuer: issuer, http_client: http_client, **options)
|
|
116
140
|
end
|
|
117
141
|
|
|
142
|
+
# Raises unless issuer is in a non-empty allowed, compared without a
|
|
143
|
+
# trailing slash. An empty list allows any issuer (a public client).
|
|
144
|
+
def self.check_challenge_issuer(issuer, allowed, source)
|
|
145
|
+
return if allowed.empty? || allowed.any? { |a| a.chomp("/") == issuer.chomp("/") }
|
|
146
|
+
|
|
147
|
+
raise ConfigurationError, "the challenge resolved issuer #{issuer}, which is not in #{source}"
|
|
148
|
+
end
|
|
149
|
+
private_class_method :check_challenge_issuer
|
|
150
|
+
|
|
151
|
+
# The allow-list for a challenge entry and how to name it in an error:
|
|
152
|
+
# allowed_issuers when set, else a multi-zone ClientSecret's zone issuers.
|
|
153
|
+
def self.challenge_allow_list(allowed_issuers, credential)
|
|
154
|
+
allowed = Array(allowed_issuers)
|
|
155
|
+
unless allowed.all? { |entry| entry.is_a?(String) && !entry.empty? }
|
|
156
|
+
raise ConfigurationError, "allowed_issuers entries must be non-empty strings"
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
return [allowed, "allowed_issuers"] unless allowed.empty?
|
|
160
|
+
return [credential.issuers, "the multi-zone ClientSecret's zone issuers"] if
|
|
161
|
+
credential.is_a?(ClientSecret) && credential.multi_zone?
|
|
162
|
+
|
|
163
|
+
[[], "allowed_issuers"]
|
|
164
|
+
end
|
|
165
|
+
private_class_method :challenge_allow_list
|
|
166
|
+
|
|
118
167
|
# Internals of the loopback flow. Not public API.
|
|
119
168
|
module Loopback
|
|
120
169
|
SUCCESS_PAGE = "<html><body><p>Authentication complete. You can close this window.</p></body></html>"
|
|
@@ -47,7 +47,11 @@ module Keycardai
|
|
|
47
47
|
!@pairs.nil?
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
#
|
|
50
|
+
# The issuer URLs this credential can serve, without a trailing slash.
|
|
51
|
+
# authenticate_from_challenge uses a multi-zone credential's issuers as
|
|
52
|
+
# its allow-list when allowed_issuers is unset.
|
|
53
|
+
#
|
|
54
|
+
# @return [Array<String>] the zone issuers; empty for a single zone
|
|
51
55
|
def issuers
|
|
52
56
|
multi_zone? ? @pairs.keys : []
|
|
53
57
|
end
|