|
20 | 20 | from starlette.routing import Route |
21 | 21 |
|
22 | 22 | from agentnet.authorization.evidence import IssuanceAuthority, SignedAuthorityCommand |
| 23 | +from agentnet.authorization.grant_http import create_task_grant_routes |
23 | 24 | from agentnet.authorization.grants import GrantUse |
24 | 25 | from agentnet.approval import IndependentApprovalReceipt |
25 | 26 | from agentnet.automation_http import create_automation_routes |
|
47 | 48 | RelationshipPolicyException, |
48 | 49 | TaskConflictAdjudication, |
49 | 50 | ) |
50 | | -from agentnet.protocol.models import Classification, Relationship, TaskGrant |
| 51 | +from agentnet.protocol.models import Classification, Relationship |
51 | 52 | from agentnet.provenance_http import create_provenance_routes |
52 | 53 | from agentnet.rooms.http import create_room_routes |
53 | 54 | from agentnet.security.signatures import canonical_digest, canonical_json |
@@ -95,12 +96,6 @@ class RelationshipPolicyExceptionActivationBody(BaseModel): |
95 | 96 | expected_lifecycle_revision: int = Field(ge=1) |
96 | 97 |
|
97 | 98 |
|
98 | | -class TaskGrantIssueBody(BaseModel): |
99 | | - model_config = ConfigDict(extra="forbid") |
100 | | - |
101 | | - grant: TaskGrant |
102 | | - |
103 | | - |
104 | 99 | class AuthorityCommandBody(BaseModel): |
105 | 100 | model_config = ConfigDict(extra="forbid") |
106 | 101 |
|
@@ -468,56 +463,6 @@ async def adjudicate_task_conflict(request: Request) -> Response: |
468 | 463 | headers=RELATIONSHIP_RESPONSE_HEADERS, |
469 | 464 | ) |
470 | 465 |
|
471 | | - async def issue_task_grant(request: Request) -> Response: |
472 | | - body, actor = await body_and_actor(request, core) |
473 | | - parsed = TaskGrantIssueBody.model_validate_json(body) |
474 | | - issued = core.issue_task_grant(actor=actor, grant=parsed.grant) |
475 | | - return JSONResponse({"grant": issued.model_dump(mode="json")}, status_code=201) |
476 | | - |
477 | | - async def get_task_grant(request: Request) -> Response: |
478 | | - _body, actor = await body_and_actor(request, core) |
479 | | - grant_id = request.path_params["grant_id"] |
480 | | - administrative = request.query_params.get("administrative", "false") |
481 | | - if administrative not in {"true", "false"}: |
482 | | - raise ValidationError("administrative must be true or false") |
483 | | - action = ( |
484 | | - "authorization.task_grant.admin_read" |
485 | | - if administrative == "true" |
486 | | - else "authorization.task_grant.read" |
487 | | - ) |
488 | | - resource, exact_request = core.grants.read_binding(grant_id) |
489 | | - authority = _authority( |
490 | | - core, |
491 | | - actor=actor, |
492 | | - action=action, |
493 | | - resource=resource, |
494 | | - request=exact_request, |
495 | | - ) |
496 | | - grant = core.grants.get( |
497 | | - grant_id, |
498 | | - authority=authority, |
499 | | - administrative=administrative == "true", |
500 | | - ) |
501 | | - if grant is None: |
502 | | - raise AuthorizationError("task grant is not visible") |
503 | | - return JSONResponse({"grant": grant.model_dump(mode="json")}) |
504 | | - |
505 | | - async def revoke_task_grant(request: Request) -> Response: |
506 | | - body, actor = await body_and_actor(request, core) |
507 | | - parsed = AuthorityCommandBody.model_validate_json(body) |
508 | | - grant_id = request.path_params["grant_id"] |
509 | | - if parsed.command.resource != f"task-grant:{grant_id}": |
510 | | - raise AuthorizationError("task grant authority binding mismatch") |
511 | | - authority = _authority( |
512 | | - core, |
513 | | - actor=actor, |
514 | | - action=parsed.command.action, |
515 | | - resource=parsed.command.resource, |
516 | | - request={"request_digest": parsed.command.request_digest}, |
517 | | - ) |
518 | | - core.grants.revoke(grant_id, command=parsed.command, authority=authority) |
519 | | - return JSONResponse({"grant_id": grant_id, "revoked": True}) |
520 | | - |
521 | 466 | async def reserve_artifact(request: Request) -> Response: |
522 | 467 | core.artifacts.require_enabled() |
523 | 468 | body, actor = await body_and_actor(request, core) |
@@ -1041,11 +986,7 @@ async def replay_version_events(request: Request) -> Response: |
1041 | 986 | RELATIONSHIP_RESPONSE_HEADERS, |
1042 | 987 | ) |
1043 | 988 | ) |
1044 | | - routes += [ |
1045 | | - Route("/v1/task-grants", issue_task_grant, methods=["POST"]), |
1046 | | - Route("/v1/task-grants/{grant_id}", get_task_grant, methods=["GET"]), |
1047 | | - Route("/v1/task-grants/{grant_id}/revoke", revoke_task_grant, methods=["POST"]), |
1048 | | - ] |
| 989 | + routes.extend(create_task_grant_routes(core, body_and_actor, _authority)) |
1049 | 990 | routes.extend(create_room_routes(core, body_and_actor, _decode_b64)) |
1050 | 991 | routes += [ |
1051 | 992 | Route("/v1/artifacts/reservations", reserve_artifact, methods=["POST"]), |
|
0 commit comments