keycardai-oauth 0.14.0 → 0.15.1

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: fc9efe8a3b93bb81137cfb6829e5461ac369ccb9334dd7aca57e058263802b2f
4
- data.tar.gz: 4e11001bf77f8c69a2ab4fa8066c204adeeb74edcc986f8d260717dd6d5d6fd4
3
+ metadata.gz: a7400d25827d149ad7a740292601c57eb0b65c2774129f3e1611641ae137dbba
4
+ data.tar.gz: 529c41f9789e2def9c3891d107c76cb22a97614d2a1e3dc9ff86e1464606a345
5
5
  SHA512:
6
- metadata.gz: e8b6eea8644d3f8d38c1520aca1152b5a4a7ffadf7c1c0df631e846954ee19d03a599cd315644c0792d64cf43d853c5770ba2eed7ce1c1e6f1147d13e6ff8150
7
- data.tar.gz: 29e30c8a5deefa76102b3fd2f9a6a75877fe4ffa8de18e772f29b59b2a30c568aed103f928db6504c9512de140918257b337104518bf9c8170d58db26f3ea18a
6
+ metadata.gz: 4797054e9a97e1a39772e3b6fcc2afc9c211b21e11226073bab08d070576a67b5e36a2fe41e79b01bf13252d39e8dd95cf119ba4f0d875f4e6e8a1526e144def
7
+ data.tar.gz: 170c9f2e56942af0de2bd02827e36f396396b1bfbff8e62e3d1359327a23fcebe792c349244c4071e7dfafe0cf2ec988c0389df8333e68e5ae08e71c4d78824a
data/CHANGELOG.md CHANGED
@@ -15,6 +15,31 @@ 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.15.1-keycardai-oauth (2026-11-26)
19
+
20
+
21
+ - fix(keycardai-oauth): classify workload identity file failures (#122)
22
+ - * fix(keycardai-oauth): classify workload identity file failures
23
+ - Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
24
+ - * fix(keycardai-oauth): classify token file encoding failures at construction
25
+ - Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
26
+ - ---------
27
+ - Co-authored-by: devin-ai-keycard <devin-ai@keycard.ai>
28
+ Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
29
+
30
+ ## 0.15.0-keycardai-oauth (2026-11-26)
31
+
32
+
33
+ - feat(keycardai-oauth): bind credentials to the client credentials grant (#103)
34
+ - * feat(keycardai-oauth): bind credentials to the client credentials grant
35
+ - Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
36
+ - * test(keycardai-oauth): cover row 4d without a request client_id
37
+ - * fix(keycardai-oauth): reject request client fields beside a configured assertion credential and resolve ClientSecret before discovery
38
+ - ---------
39
+ - Co-authored-by: devin-ai-keycard <devin-ai@keycard.ai>
40
+ Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
41
+ Co-authored-by: Larry Osakwe <23560354+Larry-Osakwe@users.noreply.github.com>
42
+
18
43
  ## 0.14.0-keycardai-oauth (2026-11-26)
19
44
 
20
45
 
data/README.md CHANGED
@@ -14,7 +14,7 @@ bundle add keycardai-oauth
14
14
  Capabilities:
15
15
 
16
16
  - Token exchange and impersonation (RFC 8693)
17
- - Client credentials grant (RFC 6749 §4.4)
17
+ - Client credentials grant (RFC 6749 §4.4), with an application credential bound on `ClientCredentialsClient`
18
18
  - Authorization code + PKCE, including the challenge-driven loopback flow (RFC 8252)
19
19
  - Device authorization grant (RFC 8628)
20
20
  - Token revocation (RFC 7009)
@@ -14,9 +14,8 @@ module Keycardai
14
14
  include TokenRequests
15
15
 
16
16
  # @param issuer [String] the zone's issuer URL
17
- # @param credential [Object, nil] a Basic-auth credential (ClientSecret);
18
- # exclusive with client_id/client_secret. Assertion-based credentials
19
- # supply their assertion through the request fields instead.
17
+ # @param credential [Object, nil] provides client authentication;
18
+ # exclusive with client_id/client_secret
20
19
  # @param client_id [String, nil] shared-secret client id (HTTP Basic)
21
20
  # @param client_secret [String, nil] shared-secret client secret;
22
21
  # provide both or neither
@@ -39,7 +38,7 @@ module Keycardai
39
38
  # @param scope [String, nil] space-separated scopes for the token
40
39
  # @param resource [String, nil] RFC 8707 resource indicator
41
40
  # @param client_assertion [String, nil] client-authentication assertion,
42
- # form-encoded in the body
41
+ # form-encoded in the body in place of configured client authentication
43
42
  # @param client_assertion_type [String, nil]
44
43
  # @param client_id [String, nil] the application credential the
45
44
  # assertion authenticates as, form-encoded beside client_assertion;
@@ -50,12 +49,7 @@ module Keycardai
50
49
  # @raise [HTTPError, ProtocolError, NetworkError]
51
50
  def request_token(scope: nil, resource: nil, client_assertion: nil, client_assertion_type: nil,
52
51
  client_id: nil, issuer: nil)
53
- target = issuer || @issuer
54
- if client_id && @credential&.authorization_header(issuer: target)
55
- raise ConfigurationError, "client_id is sent beside client_assertion, not with HTTP Basic"
56
- end
57
-
58
- post_token_request(
52
+ post_credentials(
59
53
  {
60
54
  "grant_type" => GrantType::CLIENT_CREDENTIALS,
61
55
  "scope" => scope,
@@ -64,9 +58,52 @@ module Keycardai
64
58
  "client_assertion_type" => client_assertion_type,
65
59
  "client_id" => client_id
66
60
  },
67
- issuer: target
61
+ issuer || @issuer
68
62
  )
69
63
  end
64
+
65
+ private
66
+
67
+ def post_credentials(params, issuer)
68
+ if params["client_assertion"] || !@credential
69
+ return post_token_request(params, issuer: issuer, authorization: nil)
70
+ end
71
+ # A ClientSecret resolves its Basic header without the token endpoint,
72
+ # so an unconfigured zone fails before any discovery request.
73
+ if @credential.is_a?(ClientSecret) || !@credential.respond_to?(:client_authentication)
74
+ return post_with_header(params, issuer)
75
+ end
76
+
77
+ post_authenticated_credentials(params, issuer)
78
+ end
79
+
80
+ def post_authenticated_credentials(params, issuer)
81
+ reject_request_client_fields(params)
82
+ endpoint = token_endpoint(issuer)
83
+ auth = @credential.client_authentication(issuer: issuer, endpoint: endpoint)
84
+ form = params.merge(auth.params)
85
+ post_token_form(endpoint, form, { "Accept" => "application/json" }.merge(auth.headers))
86
+ end
87
+
88
+ def post_with_header(params, issuer)
89
+ authorization = @credential.authorization_header(issuer: issuer)
90
+ reject_body_client_id(params) if authorization
91
+ post_token_request(params, issuer: issuer, authorization: authorization)
92
+ end
93
+
94
+ def reject_body_client_id(params)
95
+ return unless params["client_id"]
96
+
97
+ raise ConfigurationError, "client_id is sent beside client_assertion, not with HTTP Basic"
98
+ end
99
+
100
+ # The configured credential supplies client_id and client_assertion_type,
101
+ # so a request value would be dropped or overridden: fail instead.
102
+ def reject_request_client_fields(params)
103
+ return unless params["client_id"] || params["client_assertion_type"]
104
+
105
+ raise ConfigurationError, "client_id and client_assertion_type are sent only beside a request client_assertion"
106
+ end
70
107
  end
71
108
  end
72
109
  end
@@ -125,9 +125,11 @@ module Keycardai
125
125
  def post_token_request(params, issuer: @issuer, authorization: @credential&.authorization_header(issuer: issuer))
126
126
  headers = { "Accept" => "application/json" }
127
127
  headers["Authorization"] = authorization if authorization
128
+ post_token_form(token_endpoint(issuer), params, headers)
129
+ end
128
130
 
129
- response = @http_client.post_form(token_endpoint(issuer), params.compact, headers: headers,
130
- timeout: @timeout)
131
+ def post_token_form(endpoint, params, headers)
132
+ response = @http_client.post_form(endpoint, params.compact, headers: headers, timeout: @timeout)
131
133
  TokenRequests.parse_response(response)
132
134
  end
133
135
  end
@@ -36,11 +36,14 @@ module Keycardai
36
36
  # @raise [WorkloadIdentityRuntimeError] unreadable or empty file
37
37
  def identity_token
38
38
  token = File.read(@path).strip
39
- raise WorkloadIdentityRuntimeError.new("token file #{@path} is empty", source: "file") if token.empty?
39
+ if token.empty?
40
+ raise WorkloadIdentityRuntimeError.new("token file #{@path} is empty", source: "file", retryable: true)
41
+ end
40
42
 
41
43
  token
42
44
  rescue SystemCallError => e
43
- raise WorkloadIdentityRuntimeError.new("token file #{@path} is unreadable: #{e.message}", source: "file")
45
+ raise WorkloadIdentityRuntimeError.new("token file #{@path} is unreadable: #{e.message}",
46
+ source: "file", retryable: true)
44
47
  end
45
48
 
46
49
  def source_identifier
@@ -61,9 +64,11 @@ module Keycardai
61
64
  end
62
65
 
63
66
  def validate_file
64
- return if File.file?(@path) && !File.empty?(@path)
67
+ return if File.file?(@path) && !File.read(@path).strip.empty?
65
68
 
66
69
  raise WorkloadIdentityConfigurationError.new("token file #{@path} is missing or empty", source: "file")
70
+ rescue SystemCallError, ArgumentError, EncodingError => e
71
+ raise WorkloadIdentityConfigurationError.new("token file #{@path} is unreadable: #{e.message}", source: "file")
67
72
  end
68
73
  end
69
74
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Keycardai
4
4
  module OAuth
5
- VERSION = "0.14.0"
5
+ VERSION = "0.15.1"
6
6
  end
7
7
  end
@@ -62,7 +62,7 @@ module Keycardai
62
62
  raise
63
63
  rescue StandardError => e
64
64
  raise WorkloadIdentityRuntimeError.new("identity token source failed: #{e.message}",
65
- source: source_identifier_for(source))
65
+ source: "custom")
66
66
  end
67
67
 
68
68
  def self.source_identifier_for(source)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keycardai-oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keycard