Add Delegated User Access and Private Connectivity
Add optional on-behalf-of authority and a private network path without confusing reachability with permission.
Run it in the public monorepo
This course is built around the public Zheta Kubernetes Lab monorepo. The excerpt below is runnable source, not pseudocode.
Source: services/shared/auth.py
if claims.get("iss") != issuer or claims.get("aud") != audience or int(claims.get("exp", 0)) <= int(time.time()):
raise PermissionError("expired or wrong-scope bearer token")
if not claims.get("sub") or not claims.get("org"):
raise PermissionError("bearer token lacks tenant identity")
return Identity(str(claims["sub"]), str(claims["org"]))
Code to reality
- Declared intent
- Derive actor and tenant authority only from a signed, scoped, unexpired identity token.
- Interpreter
- The shared authentication adapter verifies cryptographic and semantic claims before MVC dispatch.
- Software effect
- Accepted requests carry an immutable actor and organization identity; invalid requests stop at the boundary.
- Hardware effect
- Signature verification consumes service CPU but denied calls allocate no downstream runtime or data resources.
- Observable evidence
- Positive tenant access and wrong-signature, wrong-audience, and cross-tenant denials identify the boundary.
Start with the people and the result they need
The source tables below remain the detailed contract. Begin with these customer paths:
- D09-UC-01
- Person: Enterprise end user
- Job: Ask an app to read one source item on the user's behalf
- Observable result: Broker uses workload identity plus user delegation and source allows their intersected scope
- D09-UC-02
- Person: Network administrator
- Job: Expose a source privately without making it public
- Observable result: Broker resolves private DNS and connects over the approved private route
Turn each customer job into a testable story
Now turn each customer job into a story with a result that an engineer can check:
- D09-US-01
- Story: As an enterprise end user, I want explicit delegated consent, so that the app cannot reuse my authority after revocation
- Observable acceptance: Consent, subject, scopes, expiry, revocation, and source decision are recorded without storing a reusable token in app data
- D09-US-02
- Story: As a network administrator, I want source traffic constrained to a private path, so that public reachability is unnecessary
- Observable acceptance: Private DNS/route succeeds; public probe fails; wrong-scope private request still receives authorization denial
Add real state and observable proof
Finally trace each story through the system that owns its state and the evidence that proves the outcome:
- D09-FLOW-01
- Trigger: User approves delegated read of one source collection
- Responsible systems: Enterprise identity provider, Connector Broker, source authorization
- Authoritative state: Delegated Grant store plus source authorization records
- Owned record: DelegatedConnectorGrant
- Observable evidence: Actor, subject, workload, both grant IDs, effective scope, private endpoint, source request, environment, timestamp, trace ID
- Failure signal: Invalid consent, revoked token, empty scope intersection, or source denial
- D09-FLOW-02
- Trigger: Revoked user asks for a workload-allowed resource
- Responsible systems: Private DNS, routing/firewall, Connector Broker, source endpoint
- Authoritative state: Network configuration and flow evidence
- Owned record: PrivateConnectionEvidence
- Observable evidence: Revocation, denial rule, zero delegated source call, private-path proof, allowed machine control, immutable evidence ID
- Failure signal: Public resolution, route/firewall failure, unexpected public flow, or authorization bypass
The enterprise problem and today’s slice
Enterprise problem: A private connection is often treated as authorization, while delegated tokens are treated as replacements for workload grants, allowing reachable workloads to exceed either machine or human scope.
Whole-course context: Provider state can record an intended machine connector name but no broker enforces source authority yet; today designs the separate delegated grant and private route without pretending either exists.
Today’s slice: Design the required intersection of workload and delegated-user scopes, then inspect the authenticated provider identity seam that exists today; delegated grants and private source connectivity are not implemented in the monorepo.
End-of-day evidence: Provider-token success plus missing, tampered, expired, and wrong-audience denials are reproducible; delegated consent, scope intersection, private DNS/route, and source decision remain named acceptance evidence for later implementation.
Still unsolved: Generated-app human identity, collaboration roles, publication, and AWS account implementation remain deferred.
Customer use cases
Some source actions need a named human while scheduled refreshes need machine authority. These use cases keep both grants independent and make the private path observable.
| Use case ID | Actor | Customer job | Success outcome | Denial or recovery evidence |
|---|---|---|---|---|
| D09-UC-01 | Enterprise end user | Ask an app to read one source item on the user's behalf | Broker uses workload identity plus user delegation and source allows their intersected scope | User-only or workload-only excess scope is denied |
| D09-UC-02 | Network administrator | Expose a source privately without making it public | Broker resolves private DNS and connects over the approved private route | Public-route probe and unauthorized private request are denied while authorized private request succeeds |
Actor-centred user stories
Reachability and authority answer different questions. These stories require separate network and policy evidence.
| Story ID | Use case IDs | User story | Observable acceptance conditions |
|---|---|---|---|
| D09-US-01 | D09-UC-01 | As an enterprise end user, I want explicit delegated consent, so that the app cannot reuse my authority after revocation | Consent, subject, scopes, expiry, revocation, and source decision are recorded without storing a reusable token in app data |
| D09-US-02 | D09-UC-02 | As a network administrator, I want source traffic constrained to a private path, so that public reachability is unnecessary | Private DNS/route succeeds; public probe fails; wrong-scope private request still receives authorization denial |
End-to-end product flows
The user chooses Connect as me for one source operation. Connector Broker computes the intersection of the machine and human grants before it uses the private route.
| Flow ID | Use case IDs | Path | Trigger | Numbered steps | Terminal evidence |
|---|---|---|---|---|---|
| D09-FLOW-01 | D09-UC-01, D09-UC-02 | Happy | User approves delegated read of one source collection | 1. Identity provider records consent.; 2. Broker validates user and workload grants.; 3. Compute scope intersection.; 4. Resolve private DNS.; 5. Call source privately.; 6. Record source decision. | Actor, subject, workload, both grant IDs, effective scope, private endpoint, source request, environment, timestamp, trace ID |
| D09-FLOW-02 | D09-UC-01, D09-UC-02 | Denied | Revoked user asks for a workload-allowed resource | 1. Private route remains reachable.; 2. Broker finds revoked delegation.; 3. Deny before source call.; 4. Workload-only scheduled read repeats as positive control. | Revocation, denial rule, zero delegated source call, private-path proof, allowed machine control, immutable evidence ID |
The user grants optional on-behalf-of authority. This action neither creates the workload grant nor grants membership inside the generated application.
System design derived from the flows
A private endpoint controls the network path but cannot decide whether a user may read a record. Connector Broker combines plane-local grants; the source system remains the final authority.
| Use case ID | Entry point | Responsible services | Authoritative store | Failure evidence |
|---|---|---|---|---|
| D09-UC-01 | Connector consent and broker request | Enterprise identity provider, Connector Broker, source authorization | Delegated Grant store plus source authorization records | Invalid consent, revoked token, empty scope intersection, or source denial |
| D09-UC-02 | Broker DNS and connection | Private DNS, routing/firewall, Connector Broker, source endpoint | Network configuration and flow evidence | Public resolution, route/firewall failure, unexpected public flow, or authorization bypass |
Broker access is constrained by both grants, then transported privately. A green network connection is not a green authorization decision.
Data model and ownership
Delegated credentials in app tables would survive user revocation and cross a plane boundary. Connector Broker owns encrypted grant material and exposes only opaque status to the app.
Generated-application database: Not created in this runnable slice — no delegated credential or connection status is persisted; both the generated-app store and connector grant store remain explicit production work.
| Record or entity | Store and owner | Primary key | Foreign key or opaque reference | Tenant key | Material constraint | Lifecycle and deletion | Use case IDs |
|---|---|---|---|---|---|---|---|
| DelegatedConnectorGrant | Connector grant store and secret manager, owned by Connector Broker | delegated_grant_id | Opaque user, workload grant, consent, and secret-version references | organization_id | Effective scope is intersection; encrypted material never enters generated-app storage | Consented, active, refreshed, expired/revoked; secret deleted and evidence retained | D09-UC-01, D09-UC-02 |
| PrivateConnectionEvidence | Evidence store, owned by Network Platform and Audit Evidence | evidence_run_id | Endpoint, DNS answer, flow, both grants, source request IDs | environment and organization_id | Must include authorized private, denied public, and denied wrong-scope paths | Immutable retention; expires by network evidence policy | D09-UC-01, D09-UC-02 |
The grant record proves current delegated authority; the evidence distinguishes network reachability, broker policy, and source policy.
Prove the intersection
Testing only an authorized request cannot expose accidental union of scopes. The current monorepo verifies a provider bearer token's signature, issuer, audience, expiry, actor, and organization; it has no delegated grant, OAuth exchange, private DNS, firewall, or enterprise source adapter. Read the exact boundary in services/shared/auth.py.
if claims.get("iss") != issuer or claims.get("aud") != audience or int(claims.get("exp", 0)) <= int(time.time()):
raise PermissionError("expired or wrong-scope bearer token")
if not claims.get("sub") or not claims.get("org"):
raise PermissionError("bearer token lacks tenant identity")
return Identity(str(claims["sub"]), str(claims["org"]))
| Declared intent | Interpreter | Software effect | Hardware effect | Evidence |
|---|---|---|---|---|
| Accept only a correctly scoped provider token and derive actor plus organization from signed claims | Python verifies HMAC and semantic JWT claims before MVC controller dispatch | Produces an immutable Identity or stops the request; it does not create delegated consent or network reachability | Verification consumes control-plane CPU; a denied request allocates no connector or source resources | AuthenticationTest proves valid identity plus missing/tampered-token denial; delegated-scope and private-path evidence remain absent |
Decision rules
Use workload authority for unattended app operations and delegated authority only when the source action must carry a human subject. Private connectivity reduces exposure; it never expands permission, and revoking either grant must independently stop the combined path.