keycardai-oauth 0.8.0 → 0.9.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 +14 -0
- data/lib/keycardai/oauth/authorization_code.rb +10 -3
- data/lib/keycardai/oauth/errors.rb +12 -2
- data/lib/keycardai/oauth/token_requests.rb +2 -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: ef60657e21dbad4e33c52dcee7762e64a0e82528e9584fd8fa408e6196ff65ab
|
|
4
|
+
data.tar.gz: 9742a4a6082f37ea03ac1eccaa2b60f1d1f9086477980dcb3946e17ce0024bc7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9683da1bb0fbf3e8cadaeef98f4c7b7b29425c011f8b1ef47803f9516544a6bb59f56215c1d8dd4b9aec553ec1ac14c5013076e07a48820ac1288688c0a0bce3
|
|
7
|
+
data.tar.gz: '08bb338f8fbd4d2190aaca0a48e9d3669da7928b24642371fc75e540a46325a84561ce01fcd19e80d5bf66e368c6b9e2bc8b848c72d11a0890793322192e28b3'
|
data/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,20 @@ 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.0-keycardai-oauth (2026-11-25)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
- feat(keycardai-oauth): preserve authorization server error reasons (#74)
|
|
22
|
+
- Co-authored-by: devin-ai-keycard <devin-ai@keycard.ai>
|
|
23
|
+
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
|
24
|
+
|
|
25
|
+
## 0.8.1-keycardai-oauth (2026-11-25)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
- fix(keycardai-oauth): merge and deduplicate authorize URL queries (#72)
|
|
29
|
+
- Co-authored-by: devin-ai-keycard <devin-ai@keycard.ai>
|
|
30
|
+
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
|
31
|
+
|
|
18
32
|
## 0.8.0-keycardai-oauth (2026-11-23)
|
|
19
33
|
|
|
20
34
|
|
|
@@ -15,7 +15,7 @@ module Keycardai
|
|
|
15
15
|
# @param code_challenge_method [String] the method the challenge was derived with
|
|
16
16
|
# @param scope [String, nil] space-separated scopes
|
|
17
17
|
# @param state [String, nil] CSRF state value
|
|
18
|
-
# @param resources [Array<String>] RFC 8707 resource indicators; each
|
|
18
|
+
# @param resources [Array<String>] RFC 8707 resource indicators; each distinct value
|
|
19
19
|
# becomes its own resource parameter, and the authorization server binds
|
|
20
20
|
# them into the authorization code at authorize time
|
|
21
21
|
# @return [String] the authorize URL
|
|
@@ -32,11 +32,18 @@ module Keycardai
|
|
|
32
32
|
}.compact
|
|
33
33
|
|
|
34
34
|
uri = URI(authorization_endpoint)
|
|
35
|
-
|
|
36
|
-
uri.query = uri.query
|
|
35
|
+
sdk_params = params.to_a + Array(resources).uniq.map { |resource| ["resource", resource] }
|
|
36
|
+
uri.query = merge_authorize_query(uri.query, sdk_params)
|
|
37
37
|
uri.to_s
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
def self.merge_authorize_query(query, sdk_params)
|
|
41
|
+
sdk_keys = sdk_params.map(&:first)
|
|
42
|
+
inherited = URI.decode_www_form(query.to_s).reject { |pair| sdk_keys.include?(pair.first) }
|
|
43
|
+
URI.encode_www_form(inherited + sdk_params)
|
|
44
|
+
end
|
|
45
|
+
private_class_method :merge_authorize_query
|
|
46
|
+
|
|
40
47
|
# Exchange an authorization code for a token (RFC 6749 §4.1.3). A public
|
|
41
48
|
# client sends its client_id in the body. A confidential client
|
|
42
49
|
# authenticates with HTTP Basic and omits client_id from the body. A
|
|
@@ -29,20 +29,30 @@ module Keycardai
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# An OAuth error response from the authorization server (RFC 6749 §5.2).
|
|
32
|
-
# Has the wire error code plus the optional description and
|
|
32
|
+
# Has the wire error code plus the optional description, URI, and reason.
|
|
33
33
|
class OAuthError < HTTPError
|
|
34
|
+
PERMANENT_ERROR_CODES = %w[access_denied expired_token insufficient_authorization invalid_client].freeze
|
|
35
|
+
|
|
34
36
|
# @return [String] the OAuth error code (e.g. invalid_grant)
|
|
35
37
|
attr_reader :error
|
|
36
38
|
# @return [String, nil]
|
|
37
39
|
attr_reader :error_description
|
|
38
40
|
# @return [String, nil]
|
|
39
41
|
attr_reader :error_uri
|
|
42
|
+
# @return [String, nil]
|
|
43
|
+
attr_reader :reason
|
|
40
44
|
|
|
41
|
-
def initialize(message, error:, status:, body: "", error_description: nil, error_uri: nil)
|
|
45
|
+
def initialize(message, error:, status:, body: "", error_description: nil, error_uri: nil, reason: nil)
|
|
42
46
|
super(message, status: status, body: body)
|
|
43
47
|
@error = error
|
|
44
48
|
@error_description = error_description
|
|
45
49
|
@error_uri = error_uri
|
|
50
|
+
@reason = reason
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @return [Boolean] whether repeating the request unchanged could succeed
|
|
54
|
+
def retryable?
|
|
55
|
+
status == 429 || status.to_i >= 500 || !PERMANENT_ERROR_CODES.include?(error)
|
|
46
56
|
end
|
|
47
57
|
end
|
|
48
58
|
|
|
@@ -57,7 +57,8 @@ module Keycardai
|
|
|
57
57
|
|
|
58
58
|
OAuthError.new("#{endpoint_name} returned #{payload["error"]}",
|
|
59
59
|
error: payload["error"], error_description: payload["error_description"],
|
|
60
|
-
error_uri: payload["error_uri"],
|
|
60
|
+
error_uri: payload["error_uri"], reason: payload["reason"],
|
|
61
|
+
status: response.status, body: response.body)
|
|
61
62
|
end
|
|
62
63
|
|
|
63
64
|
private
|