agentadmit 1.5.0 → 1.5.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 +4 -4
- data/README.md +12 -3
- data/lib/agentadmit/caller_consent.rb +31 -7
- data/lib/agentadmit/introspection_client.rb +18 -16
- data/lib/agentadmit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 810b958cd0fd3558a19bfc79910e194e45e02d95331b98747ff4edf29e337d8a
|
|
4
|
+
data.tar.gz: 4c18ad2b306eea918107543eeee24c3f2eb7f30010bfb3c1bb6502bcfa94718b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a0a65b2ce47a30683c14de7c397bea637adbe18ed76db7b8b579c5835d5dcdb90881ef93e20c687710cc37184ec3fc796a9fd153e1f6bf19edcb8f1c2875463
|
|
7
|
+
data.tar.gz: b81a5431a0a2b37728e675963ab79e188e5d0e288f4bb2a4e8497fe5df81ba7a962fc15d99b36fd21d72fa6472de266bb2dacef92aab79f46c04b615bcd31e58
|
data/README.md
CHANGED
|
@@ -76,15 +76,24 @@ The token goes to the human, not the agent. No automated delivery = no prompt in
|
|
|
76
76
|
|
|
77
77
|
AgentAdmit can host per-user consent switches for three independent caller classes: `human_session`, `in_app_ai`, and `external_agent`. No class's setting implies another's.
|
|
78
78
|
|
|
79
|
-
**External agents:** the verify result already carries the verdict:
|
|
79
|
+
**External agents:** the verify result already carries the verdict. The hosted service deliberately omits the verdict when its consent store is unreadable (degraded mode), so an absent verdict is *unresolved*, never a grant — `consent_granted?` fails closed on it. Resolve an absent or malformed verdict through the ledger:
|
|
80
80
|
|
|
81
81
|
```ruby
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
client = AgentAdmit::IntrospectionClient.new
|
|
83
|
+
result = client.verify(token)
|
|
84
|
+
consent = result.consent
|
|
85
|
+
unless consent.is_a?(Hash) && [true, false].include?(consent["granted"])
|
|
86
|
+
# absent/malformed verdict: the ledger holds the authoritative answer
|
|
87
|
+
consent = client.check_consent(app_user_id: result.user_id,
|
|
88
|
+
caller_class: "external_agent") # fail closed on error
|
|
89
|
+
end
|
|
90
|
+
unless consent["granted"] == true
|
|
84
91
|
# the data owner has switched external agents off: return your own 403
|
|
85
92
|
end
|
|
86
93
|
```
|
|
87
94
|
|
|
95
|
+
The `AgentAdmit::CallerConsent` middleware does all of this for you: it evaluates the consent verdict **before** the scope check (a caller whose class the owner denied learns nothing about scope state) and resolves an absent verdict through the Consent Ledger, fail-closed.
|
|
96
|
+
|
|
88
97
|
**Human sessions and in-app AI** never hold AgentAdmit tokens, so ask directly:
|
|
89
98
|
|
|
90
99
|
```ruby
|
|
@@ -18,7 +18,9 @@ module AgentAdmit
|
|
|
18
18
|
#
|
|
19
19
|
# - external_agent: an ag_at_ access token -> hosted introspection, which
|
|
20
20
|
# returns the external-agent consent verdict inline plus the granted
|
|
21
|
-
# scopes.
|
|
21
|
+
# scopes. Consent is evaluated BEFORE scope (a denied class must not
|
|
22
|
+
# learn scope state). A missing or malformed verdict is resolved through
|
|
23
|
+
# the Consent Ledger, fail-closed -- absence is never a grant.
|
|
22
24
|
# - in_app_ai: your application's own server-side AI code path -> the
|
|
23
25
|
# Consent Ledger /consent/check for the in-app-AI class.
|
|
24
26
|
# - human_session: your application's own permission model (sharing,
|
|
@@ -121,8 +123,12 @@ module AgentAdmit
|
|
|
121
123
|
|
|
122
124
|
##
|
|
123
125
|
# External-agent path: hosted introspection carries the verdict and the
|
|
124
|
-
# scopes.
|
|
125
|
-
#
|
|
126
|
+
# scopes. Consent is evaluated first (Patent FIG. 3: the class consent
|
|
127
|
+
# decision precedes scope evaluation) -- checking scope first would leak
|
|
128
|
+
# granted-scope state to callers whose class the owner has denied. The
|
|
129
|
+
# hosted service omits the verdict when its consent-store read fails
|
|
130
|
+
# (designed degraded mode), so an absent or malformed verdict is resolved
|
|
131
|
+
# through the Consent Ledger, fail-closed -- never treated as a grant.
|
|
126
132
|
#
|
|
127
133
|
def call_external_agent(env)
|
|
128
134
|
token = (env["HTTP_AUTHORIZATION"] || "").sub(/\Abearer /i, "")
|
|
@@ -135,6 +141,27 @@ module AgentAdmit
|
|
|
135
141
|
return json_error(502, "introspection_failed", e.message)
|
|
136
142
|
end
|
|
137
143
|
|
|
144
|
+
consent = result.consent
|
|
145
|
+
unless consent.is_a?(Hash) && [true, false].include?(consent["granted"])
|
|
146
|
+
owner = result.user_id
|
|
147
|
+
if !owner.is_a?(String) || owner.empty?
|
|
148
|
+
return json_error(503, "consent_unavailable",
|
|
149
|
+
"Introspection carried no consent verdict and no resolvable data owner")
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
begin
|
|
153
|
+
consent = @client.check_consent(app_user_id: owner, caller_class: EXTERNAL_AGENT,
|
|
154
|
+
scope_group: @scope_group)
|
|
155
|
+
rescue StandardError
|
|
156
|
+
return json_error(503, "consent_unavailable", "Consent check failed")
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
unless consent.is_a?(Hash) && consent["granted"] == true
|
|
161
|
+
return json_error(403, "consent_not_granted",
|
|
162
|
+
"The data owner has not enabled external agent access.")
|
|
163
|
+
end
|
|
164
|
+
|
|
138
165
|
if @required_scope && !(result.scopes || []).include?(@required_scope)
|
|
139
166
|
return [403, { "Content-Type" => "application/json" },
|
|
140
167
|
[{ error: "insufficient_scope",
|
|
@@ -143,16 +170,13 @@ module AgentAdmit
|
|
|
143
170
|
message: "This action requires '#{@required_scope}' scope." }.to_json]]
|
|
144
171
|
end
|
|
145
172
|
|
|
146
|
-
return json_error(403, "consent_not_granted",
|
|
147
|
-
"The data owner has not enabled external agent access.") unless result.consent_granted?
|
|
148
|
-
|
|
149
173
|
env["agentadmit.auth_type"] = "agent"
|
|
150
174
|
env["agentadmit.user_id"] = result.user_id
|
|
151
175
|
env["agentadmit.scopes"] = result.scopes
|
|
152
176
|
env["agentadmit.connection_id"] = result.connection_id
|
|
153
177
|
env["agentadmit.agent_label"] = result.agent_label
|
|
154
178
|
env["agentadmit.presence"] = result.presence
|
|
155
|
-
env["agentadmit.consent"] =
|
|
179
|
+
env["agentadmit.consent"] = consent
|
|
156
180
|
|
|
157
181
|
@app.call(env)
|
|
158
182
|
end
|
|
@@ -26,22 +26,24 @@ module AgentAdmit
|
|
|
26
26
|
# nil). A denied verdict means the app returns its own 403 -- the token
|
|
27
27
|
# itself stays valid (consent is orthogonal to revocation).
|
|
28
28
|
#
|
|
29
|
-
# Contract
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
29
|
+
# Contract: grants ONLY on an explicit boolean true. An ABSENT block is
|
|
30
|
+
# NEVER a grant -- the hosted service deliberately omits it when its
|
|
31
|
+
# consent-store read fails (designed degraded mode), so absence here
|
|
32
|
+
# fails closed. A missing or non-boolean granted value is likewise
|
|
33
|
+
# denied (malformed = deny). Callers that want the authoritative answer
|
|
34
|
+
# for an absent/malformed verdict should resolve it through
|
|
35
|
+
# #check_consent for the external_agent class (CallerConsent does this
|
|
36
|
+
# automatically).
|
|
34
37
|
def consent_granted?
|
|
35
|
-
|
|
36
|
-
consent["granted"] == true
|
|
38
|
+
consent.is_a?(Hash) && consent["granted"] == true
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
# Human-presence fact from the WebAuthn step-up (additive; may be nil).
|
|
40
42
|
# True ONLY when the connection was authorized by a human who completed
|
|
41
43
|
# a presence ceremony on the consent page: verified must be the boolean
|
|
42
|
-
# true.
|
|
43
|
-
#
|
|
44
|
-
#
|
|
44
|
+
# true. Absence fails closed -- older servers never send the block, and
|
|
45
|
+
# connections minted without a ceremony carry verified: false, so
|
|
46
|
+
# nil/false/malformed all read as not verified.
|
|
45
47
|
def presence_verified?
|
|
46
48
|
presence.is_a?(Hash) && presence["verified"] == true
|
|
47
49
|
end
|
|
@@ -161,17 +163,17 @@ module AgentAdmit
|
|
|
161
163
|
# Validate that consumed fields have the expected types when present.
|
|
162
164
|
validate_introspection_types!(data)
|
|
163
165
|
|
|
164
|
-
# Keep
|
|
165
|
-
#
|
|
166
|
-
# consent_granted
|
|
167
|
-
#
|
|
166
|
+
# Keep the consent block only when it is a Hash; anything else reads
|
|
167
|
+
# as nil. Absent and malformed are both safe: neither is ever a grant
|
|
168
|
+
# (consent_granted? fails closed, and CallerConsent resolves the
|
|
169
|
+
# authoritative verdict through the Consent Ledger).
|
|
168
170
|
consent = data["consent"]
|
|
169
171
|
consent = nil unless consent.is_a?(Hash)
|
|
170
172
|
|
|
171
173
|
# Presence rides along when the platform returns it. Same strictness
|
|
172
174
|
# as active: verified must be the boolean true or false, never coerced.
|
|
173
|
-
#
|
|
174
|
-
#
|
|
175
|
+
# A malformed block is dropped -- presence_verified? fails closed on
|
|
176
|
+
# nil, so dropping cannot fail open.
|
|
175
177
|
presence = data["presence"]
|
|
176
178
|
presence = nil unless presence.is_a?(Hash) && [true, false].include?(presence["verified"])
|
|
177
179
|
|
data/lib/agentadmit/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: agentadmit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.
|
|
4
|
+
version: 1.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christopher Emerson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-07-
|
|
11
|
+
date: 2026-07-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|