keycardai-oauth 0.9.1 → 0.10.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbe4dc737a7a8ab30d17ac738620e62878c16f2f4fa25ad2821cef9d82e635cf
|
|
4
|
+
data.tar.gz: 41f9295086fd2fca1d23c7513d40fb5f689a86ffc3ad2c5c312ec035a38ca2e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7166b568c0176d7d9e73b8985c44640d71158f6abf4c3fb5e5d16767b0d4c616c19bd18420a4500de201b20d7ea0a371fc37b23ac9dda50efb3ab2541b0968e2
|
|
7
|
+
data.tar.gz: dbeba673528ec8fbca7e82d82910c3170f133b6e498ca11b87192a384719c5b28ecc04adc4809c7ed24076498f4e3c26e076039707c14e4b3ec03ea03b99565c
|
data/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,42 @@ 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.10.0-keycardai-oauth (2026-11-25)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
- fix(keycardai-oauth)!: reject request client IDs with Basic token exchange (#78)
|
|
22
|
+
- * fix(keycardai-oauth)!: reject request client IDs with Basic token exchange
|
|
23
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
24
|
+
- * test(keycardai-oauth): cover request assertion precedence with workload identity
|
|
25
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
26
|
+
- * fix(keycardai-oauth): keep the Basic client_id guard on the prepared exchange path
|
|
27
|
+
- ---------
|
|
28
|
+
- Co-authored-by: devin-ai-keycard <devin-ai@keycard.ai>
|
|
29
|
+
Co-authored-by: Larry Osakwe <larry@keycard.ai>
|
|
30
|
+
Co-authored-by: Larry Osakwe <23560354+Larry-Osakwe@users.noreply.github.com>
|
|
31
|
+
|
|
32
|
+
## 0.9.2-keycardai-oauth (2026-11-25)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
- fix(keycardai-oauth): use prepared authentication in token exchange (#77)
|
|
36
|
+
- * fix(keycardai-oauth): use prepared authentication in token exchange
|
|
37
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
38
|
+
- * fix(keycardai-oauth): validate caller-supplied assertion type
|
|
39
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
40
|
+
- ---------
|
|
41
|
+
- Co-authored-by: devin-ai-keycard <devin-ai@keycard.ai>
|
|
42
|
+
Co-authored-by: Larry Osakwe <larry@keycard.ai>
|
|
43
|
+
- fix(keycardai-oauth): reject explicitly empty verifier audiences (#76)
|
|
44
|
+
- * fix(keycardai-oauth): reject explicitly empty verifier audiences
|
|
45
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
46
|
+
- * docs: refresh bearer conformance example counts
|
|
47
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
48
|
+
- * docs: count only row-numbered conformance examples
|
|
49
|
+
- ---------
|
|
50
|
+
- Co-authored-by: devin-ai-keycard <devin-ai@keycard.ai>
|
|
51
|
+
Co-authored-by: Larry Osakwe <larry@keycard.ai>
|
|
52
|
+
Co-authored-by: Larry Osakwe <23560354+Larry-Osakwe@users.noreply.github.com>
|
|
53
|
+
|
|
18
54
|
## 0.9.1-keycardai-oauth (2026-11-25)
|
|
19
55
|
|
|
20
56
|
|
|
@@ -46,14 +46,17 @@ module Keycardai
|
|
|
46
46
|
# delegation; requires actor_token_type
|
|
47
47
|
# @param actor_token_type [String, nil]
|
|
48
48
|
# @param client_assertion [String, nil] client-authentication assertion,
|
|
49
|
-
# form-encoded in the body
|
|
49
|
+
# form-encoded in the body; requires client_assertion_type
|
|
50
50
|
# @param client_assertion_type [String, nil]
|
|
51
51
|
# @param client_id [String, nil] the application credential the
|
|
52
|
-
# assertion authenticates as, form-encoded beside client_assertion
|
|
52
|
+
# assertion authenticates as, form-encoded beside client_assertion.
|
|
53
|
+
# When the credential prepares the assertion, its ID replaces this
|
|
54
|
+
# value, or the field is omitted if the credential supplies no ID.
|
|
53
55
|
# @param issuer [String, nil] per-call zone selection: resolves the zone's
|
|
54
56
|
# token endpoint and, for a multi-zone credential, that zone's client
|
|
55
57
|
# authentication. Defaults to the client's issuer.
|
|
56
58
|
# @return [TokenResponse]
|
|
59
|
+
# @raise [ConfigurationError] when the request sets client_id with HTTP Basic
|
|
57
60
|
# @raise [OAuthError] an RFC 6749 §5.2 error response (invalid_grant,
|
|
58
61
|
# invalid_target, invalid_scope, unauthorized_client, ...)
|
|
59
62
|
# @raise [HTTPError, ProtocolError, NetworkError]
|
|
@@ -63,7 +66,8 @@ module Keycardai
|
|
|
63
66
|
client_id: nil, issuer: nil)
|
|
64
67
|
raise ArgumentError, "actor_token_type is required when actor_token is set" if actor_token && !actor_token_type
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
validate_client_assertion(client_assertion, client_assertion_type)
|
|
70
|
+
|
|
67
71
|
overrides = {
|
|
68
72
|
"subject_token_type" => subject_token_type,
|
|
69
73
|
"resource" => resource,
|
|
@@ -76,7 +80,7 @@ module Keycardai
|
|
|
76
80
|
"client_assertion_type" => client_assertion_type,
|
|
77
81
|
"client_id" => client_id
|
|
78
82
|
}.compact
|
|
79
|
-
|
|
83
|
+
post_exchange(subject_token, overrides, issuer || @issuer)
|
|
80
84
|
end
|
|
81
85
|
|
|
82
86
|
# Impersonate a named user: a substitute-user token exchange for
|
|
@@ -105,20 +109,37 @@ module Keycardai
|
|
|
105
109
|
|
|
106
110
|
private
|
|
107
111
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
def validate_client_assertion(assertion, type)
|
|
113
|
+
raise ArgumentError, "client_assertion_type is required when client_assertion is set" if assertion && !type
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# An explicit client_assertion authenticates the client on its own, so
|
|
117
|
+
# the credential adds no Basic header and prepares no assertion.
|
|
118
|
+
def post_exchange(subject_token, overrides, issuer)
|
|
119
|
+
params = { "grant_type" => GrantType::TOKEN_EXCHANGE, "subject_token" => subject_token,
|
|
120
|
+
"subject_token_type" => TokenType::ACCESS_TOKEN }.merge(overrides)
|
|
121
|
+
return post_token_request(params, issuer: issuer, authorization: nil) if overrides["client_assertion"]
|
|
122
|
+
|
|
123
|
+
authorization = @credential&.authorization_header(issuer: issuer)
|
|
124
|
+
reject_client_id_with_basic(overrides, authorization)
|
|
125
|
+
params = with_assertion(params, issuer) if @credential && !authorization
|
|
126
|
+
post_token_request(params, issuer: issuer, authorization: authorization)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# A request client_id never travels beside HTTP Basic: fail before any
|
|
130
|
+
# HTTP request, including discovery.
|
|
131
|
+
def reject_client_id_with_basic(overrides, authorization)
|
|
132
|
+
return unless overrides.key?("client_id") && authorization&.match?(/\ABasic\s/i)
|
|
133
|
+
|
|
134
|
+
raise ConfigurationError, "token exchange client_id cannot be sent with HTTP Basic"
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def with_assertion(params, issuer)
|
|
138
|
+
prepared = @credential.prepare_token_exchange_request(
|
|
139
|
+
subject_token: params.fetch("subject_token"), resource: params["resource"],
|
|
140
|
+
token_endpoint: token_endpoint(issuer), issuer: issuer
|
|
141
|
+
)
|
|
142
|
+
params.merge(prepared.slice("client_assertion", "client_assertion_type"), "client_id" => prepared["client_id"])
|
|
122
143
|
end
|
|
123
144
|
end
|
|
124
145
|
end
|
|
@@ -113,9 +113,8 @@ module Keycardai
|
|
|
113
113
|
endpoint
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
-
def post_token_request(params, issuer: @issuer)
|
|
116
|
+
def post_token_request(params, issuer: @issuer, authorization: @credential&.authorization_header(issuer: issuer))
|
|
117
117
|
headers = { "Accept" => "application/json" }
|
|
118
|
-
authorization = @credential&.authorization_header(issuer: issuer)
|
|
119
118
|
headers["Authorization"] = authorization if authorization
|
|
120
119
|
|
|
121
120
|
response = @http_client.post_form(token_endpoint(issuer), params.compact, headers: headers,
|
|
@@ -84,12 +84,13 @@ module Keycardai
|
|
|
84
84
|
# @param discovery_ttl [Numeric] jwks_uri cache lifetime in seconds
|
|
85
85
|
# @param fetch_timeout [Numeric] discovery and JWKS fetch timeout
|
|
86
86
|
# @param clock [#call] returns the current Time; override in tests
|
|
87
|
-
# @raise [ConfigurationError] no trusted issuer
|
|
87
|
+
# @raise [ConfigurationError] no trusted issuer or explicitly empty audiences
|
|
88
88
|
def initialize(issuers:, audiences: nil, http_client: HTTP::NetHTTPClient.new,
|
|
89
89
|
key_ttl: JWKSKeyring::DEFAULT_KEY_TTL, discovery_ttl: JWKSKeyring::DEFAULT_DISCOVERY_TTL,
|
|
90
90
|
fetch_timeout: JWKSKeyring::DEFAULT_FETCH_TIMEOUT, clock: -> { Time.now })
|
|
91
91
|
@issuers = Array(issuers).reject { |issuer| issuer.nil? || issuer.empty? }
|
|
92
92
|
raise ConfigurationError, "TokenVerifier requires at least one trusted issuer" if @issuers.empty?
|
|
93
|
+
raise ConfigurationError, "audiences must not be empty" if audiences.is_a?(Array) && audiences.empty?
|
|
93
94
|
|
|
94
95
|
if audiences.nil?
|
|
95
96
|
warn "Keycardai::OAuth::TokenVerifier has no audiences configured, so it accepts a token minted " \
|