Repository navigation
feat(generate): scaffold authorization decision hook in generated Go agents - #357
Conversation
|
@infer /model deepseek/deepseek-v4-pro Can you review this? use /go /go-concurrency /go-spec-reviewer /ponytail:ponytail /ponytail:ponytail-review Shouldn't we have the authz in the spec? allowing better flexibility to define the authorizations needed? for every agent it might be different. |
|
Model: Todos
Pull Request✅ Infer Result: SuccessReview of PR #357: Scaffold authorization decision hookGo code reviewStatus: Approved. The generated
No issues. Go concurrency reviewStatus: Clean. No goroutines, no channels, no shared state in Ponytail-review (over-engineering)Status: Lean already. Ship.
Go-spec-reviewer (design completeness)Status: Issues found - but PR is correct as a first step. The central question you raised - "Shouldn't we have the authz in the spec?" - is the right design tension. What this PR gets right:
The gap:
Recommendation: Add a minimal spec:
server:
auth:
enabled: true
authorization:
mode: allow-all # enum: allow-all, deny-all, custom
This keeps Do NOT add per-tool ACL rules to the ADL schema at this stage. Authorization models vary too widely (OPA, OIDC claims, RBAC, ABAC, multi-tenant) - trying to capture that in a schema without real user demand would produce a bloated, incomplete abstraction. Wait for concrete use cases. Verdict: Ship this PR as-is. File a follow-up issue for Model: Tokens: 674,268 in · 8,523 out · 682,791 total (13 requests) Cost: $0.0523 in · $0.0074 out · $0.0597 total Tool calls: 25 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
|
@infer I think we should make the authz opt-in, if it's not needed (i.e not enabled in the spec the code shouldn't be generated. Can you create the feature request mentioned above in the review comment as a follow-up? in the adl repo first. And I don't think it should be under auth rather it should be: |
|
Model: Todos
Pull Request✅ Infer Result: SuccessAll changes are committed and pushed to Changes madeSchema layer:
Generation gating (authz is now opt-in under
Mode-aware authz callback:
Docs and examples:
Follow-up tracking:
Model: Tokens: 4,462,808 in · 15,684 out · 4,478,492 total (35 requests) Tool calls: 48 total · 96% success rate TracesStats
|
Make the authorization decision hook opt-in under its own spec.server.authz block instead of piggybacking on spec.server.auth.enabled. - Add AuthzConfig to schema.json with enabled bool + mode enum (allow-all, deny-all, custom) and regenerate types.go - Gate authz file generation, .adl-ignore protection, and main.go wiring on spec.server.authz.enabled - Update authz.go.tmpl to accept a mode parameter and act accordingly (allow-all, deny-all, or custom) - Update README.md.tmpl feature badge to reference authz - Update go-agent-authz.yaml example to use the authz block - Track upstream schema in inference-gateway/adl#159
|
@infer Can you use enums instead of magic strings? use /ponytail:ponytail |
|
Model: Todos
Pull Request✅ Infer Result: SuccessDone. Here's what changed:
Skipped: the README.md.tmpl line that displays the mode value ( Model: Tokens: 1,884,918 in · 8,978 out · 1,893,896 total (16 requests) Tool calls: 25 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
…in generated authz.go Replace magic string comparisons with an AuthzMode type and exported constants (ModeAllowAll, ModeDenyAll, ModeCustom) in the generated authz.go template. The BeforeTool function now accepts AuthzMode instead of string. Update main.go.tmpl to pass the typed constants based on the ADL spec value, removing the raw string interpolation.
|
@infer What about passing the identity of the user if auth is enabled? maybe I want to assert the user who invoked this agent is allowed to invoke the tool? use /ponytail:ponytail /go |
|
Model: Todos
Pull Request✅ Infer Result: SuccessAll done. Here's what changed: Committed The change gives users a typed, forward-looking API for caller-aware authorization:
Why it returns empty today: The ADK's auth middleware stores the verified OIDC ID token in the Gin context during HTTP handling. The background task handler creates a fresh context for tool execution, dropping all request-scoped values. Skipped: no changes to the ADK itself (that's inference-gateway/adk#276), no new template in Model: Tokens: 1,976,308 in · 12,919 out · 1,989,227 total (31 requests) Tool calls: 35 total · 91% success rate TracesStats
|
…-aware authz Add authz.Identity struct (Subject, Email, Issuer) mapping OIDC ID token claims and IdentityFrom(*ToolContext) helper that reads from toolCtx.State when the ADK surfaces claims (tracked in inference-gateway/adk#276). Returns empty Identity until then - the authz hook MUST allow calls through on empty identity. Update the BeforeTool doc comment to show identity-aware authz in the example. Add asString helper for safe map-value extraction.
|
@infer both the adl PR and the fix in the ADK are released, can you prepare this PR for review? use /go /ponytail:ponytail |
|
Model: Todos
Pull Request✅ Infer Result: SuccessPR #357 is ready for review. Here's what was done: New commit pushed: Changes made:
Working tree clean, branch up to date with origin. Model: Tokens: 4,985,141 in · 12,519 out · 4,997,660 total (32 requests) Tool calls: 47 total · 98% success rate TracesStats
|
Updates stale ADK #276 references in authz.go.tmpl - the fix has been released so comments now use present/past tense.
## [0.60.0](v0.59.1...v0.60.0) (2026-08-07) ### ✨ Features * **generate:** scaffold authorization decision hook in generated Go agents ([#357](#357)) ([f2c3c68](f2c3c68)), references [inference-gateway/adl#159](inference-gateway/adl#159) [inference-gateway/adk#276](inference-gateway/adk#276) ### 🔧 Miscellaneous * **deps:** bump infer CLI v0.155.0 -> v0.164.0 ([#356](#356)) ([c5b31fc](c5b31fc))
|
🎉 This PR is included in version 0.60.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Resolves #346
Summary
Scaffold an authorization decision hook (
internal/authz/authz.go, packageauthz) in generated Go agents whenspec.server.auth.enabledis true. The hook is a user-owned file (added to.adl-ignore) that returns an ADKBeforeToolCallback. The default implementation allows all calls (preserving pre-audit behavior) and logs a warning so the gap is visible.Authorization is a separate package from authentication: auth (token verification) is ADK-owned wiring in
main.go; authz (policy) is user-owned code. This matches the generator's one-package-per-responsibility layout.Changes
languages/go/authz.go.tmpl: user-ownedinternal/authz/authz.gowithpackage authz, aBeforeToolfunction returningserver.BeforeToolCallback, default-allow body with warning log, and doc comments explaining the caveat that the ADK does not yet surface OIDC claims to the callback (tracked in [BUG] Verified OIDC claims not propagated to BeforeTool callbacks (background task processor drops request context) adk#276)main.go.tmpl: addsauthzimport and.WithCallbacks(&server.CallbackConfig{BeforeTool: ...})to the agent builder chain, gated onspec.server.auth.enabledregistry.go: mapsinternal/authz/authz.goto theauthz.gotemplate key when auth is enabled for Go targets.adl-ignore: addsinternal/authz/authz.goto the ignore list for Go with auth enabled, so user edits survive regenerationgo-agent-authz.yaml: regression example wired intoTaskfile.yml(examples:testandexamples:generate)