keycardai-oauth 0.9.1 → 0.9.2
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: 73096603402556204c3aa921c4821cbb250b662d957c6ead112dd28658dd303b
|
|
4
|
+
data.tar.gz: 53a912a76ea3194c4a78273ad494b6cde5e06591bbb429b0a310ea6bd401baa3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f61479a708c6423eed6139eccedea61332023e16edc1bbacf1424908492db43b5535c85550b700ffdbaf3648e0ad0859406652cfa4abbda3b03ba5925e75952f
|
|
7
|
+
data.tar.gz: 269c4b3ae7318f44b532beaab189352c00e57ebd942b6960ef6c5122f5c1cec0ea828706c0139a39498c3a15358b9764ae45169f1e56c5b4ab1ddbdf41bcae2a
|
data/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,28 @@ 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.9.2-keycardai-oauth (2026-11-25)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
- fix(keycardai-oauth): use prepared authentication in token exchange (#77)
|
|
22
|
+
- * fix(keycardai-oauth): use prepared authentication in token exchange
|
|
23
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
24
|
+
- * fix(keycardai-oauth): validate caller-supplied assertion type
|
|
25
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
26
|
+
- ---------
|
|
27
|
+
- Co-authored-by: devin-ai-keycard <devin-ai@keycard.ai>
|
|
28
|
+
Co-authored-by: Larry Osakwe <larry@keycard.ai>
|
|
29
|
+
- fix(keycardai-oauth): reject explicitly empty verifier audiences (#76)
|
|
30
|
+
- * fix(keycardai-oauth): reject explicitly empty verifier audiences
|
|
31
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
32
|
+
- * docs: refresh bearer conformance example counts
|
|
33
|
+
- Co-Authored-By: Larry Osakwe <larry@keycard.ai>
|
|
34
|
+
- * docs: count only row-numbered conformance examples
|
|
35
|
+
- ---------
|
|
36
|
+
- Co-authored-by: devin-ai-keycard <devin-ai@keycard.ai>
|
|
37
|
+
Co-authored-by: Larry Osakwe <larry@keycard.ai>
|
|
38
|
+
Co-authored-by: Larry Osakwe <23560354+Larry-Osakwe@users.noreply.github.com>
|
|
39
|
+
|
|
18
40
|
## 0.9.1-keycardai-oauth (2026-11-25)
|
|
19
41
|
|
|
20
42
|
|
|
@@ -46,10 +46,12 @@ 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.
|
|
@@ -63,7 +65,8 @@ module Keycardai
|
|
|
63
65
|
client_id: nil, issuer: nil)
|
|
64
66
|
raise ArgumentError, "actor_token_type is required when actor_token is set" if actor_token && !actor_token_type
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
validate_client_assertion(client_assertion, client_assertion_type)
|
|
69
|
+
|
|
67
70
|
overrides = {
|
|
68
71
|
"subject_token_type" => subject_token_type,
|
|
69
72
|
"resource" => resource,
|
|
@@ -76,7 +79,7 @@ module Keycardai
|
|
|
76
79
|
"client_assertion_type" => client_assertion_type,
|
|
77
80
|
"client_id" => client_id
|
|
78
81
|
}.compact
|
|
79
|
-
|
|
82
|
+
post_exchange(subject_token, overrides, issuer || @issuer)
|
|
80
83
|
end
|
|
81
84
|
|
|
82
85
|
# Impersonate a named user: a substitute-user token exchange for
|
|
@@ -105,20 +108,24 @@ module Keycardai
|
|
|
105
108
|
|
|
106
109
|
private
|
|
107
110
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
111
|
+
def validate_client_assertion(assertion, type)
|
|
112
|
+
raise ArgumentError, "client_assertion_type is required when client_assertion is set" if assertion && !type
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def post_exchange(subject_token, overrides, issuer)
|
|
116
|
+
params = { "grant_type" => GrantType::TOKEN_EXCHANGE, "subject_token" => subject_token,
|
|
117
|
+
"subject_token_type" => TokenType::ACCESS_TOKEN }.merge(overrides)
|
|
118
|
+
authorization = @credential&.authorization_header(issuer: issuer)
|
|
119
|
+
params = with_assertion(params, issuer) if @credential && !authorization && !overrides["client_assertion"]
|
|
120
|
+
post_token_request(params, issuer: issuer, authorization: authorization)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def with_assertion(params, issuer)
|
|
124
|
+
prepared = @credential.prepare_token_exchange_request(
|
|
125
|
+
subject_token: params.fetch("subject_token"), resource: params["resource"],
|
|
126
|
+
token_endpoint: token_endpoint(issuer), issuer: issuer
|
|
127
|
+
)
|
|
128
|
+
params.merge(prepared.slice("client_assertion", "client_assertion_type"), "client_id" => prepared["client_id"])
|
|
122
129
|
end
|
|
123
130
|
end
|
|
124
131
|
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 " \
|