AuthZen PDP client#4177
Draft
stevenvegt wants to merge 4 commits into4144-1-scope-parsing-and-configfrom
Draft
Conversation
|
Coverage Impact ⬇️ Merging this pull request will decrease total coverage on Modified Files with Diff Coverage (1)
🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 Help
|
10 tasks
Implements the HTTP client for the AuthZen Access Evaluations API (POST /access/v1/evaluations). Request uses AuthZen batch format: shared subject/action/context with per-scope evaluations array. Returns scope→decision map. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests cover: partial denial, HTTP 500, PDP unreachable, context cancellation/timeout, evaluation count mismatch, malformed response. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Truncate PDP error body in error messages (prevent log injection) - Validate duplicate resource IDs before sending request - Add Accept: application/json header - Add package doc comment - Fix require.NoError inside httptest handler (capture request, assert outside) - Rename context cancellation test for accuracy - Add duplicate resource ID test - Response body limiting delegated to StrictHTTPClient (caller responsibility) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7c44b2a to
4f08bcf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Parent PRD
#4144
Implementation Spec
Overview
New HTTP client for the AuthZen batch Access Evaluations API (
POST /access/v1/evaluations). This client is used by the server-side token flow (PR #4179) whenscope_policy: "dynamic"to evaluate requested scopes against an external PDP.Key files to create/modify
policy/authzen/client.go— New HTTP clientpolicy/authzen/types.go— Request/response typespolicy/authzen/client_test.go— Unit testsDesign decisions
evaluationsarray contains per-scope resource overrides. This avoids repeating the same subject/action/context for every scope.ExtractSubjectPropertieshelper depends on how the credential map from PEX evaluation maps to the organization bucket. This becomes clear in the server-side flow where the actual credential data is available. The AuthZen client takes a pre-builtEvaluationsRequest— it doesn't need to know about credentials.map[string]boolreturn type: Denial reasons from the AuthZen response are logged for debugging but not exposed in the return value. Rego-produced reasons are typically terse and few. A richer return type can be added later if operators need it.AuthZen request/response examples
Request (
POST /access/v1/evaluations):{ "subject": { "type": "token_request", "id": "did:web:hospital.example.com", "properties": { "organization": { "id": "did:web:hospital.example.com", "name": "Hospital B.V.", "ura": "12345678" } } }, "action": { "name": "request_scope" }, "context": { "policy": "urn:nuts:medication-overview" }, "evaluations": [ { "resource": { "type": "scope", "id": "urn:nuts:medication-overview" } }, { "resource": { "type": "scope", "id": "patient/Observation.read" } }, { "resource": { "type": "scope", "id": "launch/patient" } } ] }Response:
{ "evaluations": [ { "decision": true }, { "decision": true }, { "decision": false, "context": { "reason": "scope not permitted by policy" } } ] }Go types
Client implementation
The
Evaluatemethod:{endpoint}/access/v1/evaluations.map[string]boolfor easy lookup.Error handling
Testing
httptest.NewServerfor HTTP mockingAcceptance Criteria