Repository navigation
Auth: one auth key with RBAC, reach and ownership in storage - #75
Merged
Merged
Conversation
- Implemented the /v1/me endpoint in the me.py router to return the authenticated user's identity, roles, and permissions. - Added tests for the /v1/me endpoint to verify correct behavior with and without authentication. test: add CLI tests for auth rules validation - Created tests for the AuditCommand and BuildCommand to validate shared auth rules in the CLI. - Included assertions for expected outputs and exit codes based on different configurations. test: add integration tests for transport parity - Developed integration tests to ensure consistent permission decisions across different transport methods (HTTP and WebSocket). - Verified that revoked tokens and unauthorized access are handled correctly. test: add unit tests for auth configuration validation - Implemented unit tests for the AuthConfig validation logic to ensure proper handling of various auth configurations. - Included tests for RBAC rules, tenant claims, and custom authorization methods. test: add unit tests for auth dependencies - Created unit tests for RequirePermission and RequireIdentity dependencies to ensure correct behavior in HTTP and WebSocket contexts. - Verified that unauthorized access returns appropriate status codes. test: add unit tests for /v1/me route - Added unit tests for the /v1/me route to check identity retrieval and response structure. - Ensured that the endpoint behaves correctly when authentication is off.
- Renamed `verified_user_id` to `verified_caller_key` to better reflect its purpose of identifying callers with tenant values. - Updated the logic in `verified_caller_key` to handle tenant claims and return appropriate identity keys. - Modified `client_key_for` to utilize the new `verified_caller_key` for user identification. - Adjusted various routes and services to accommodate the new authorization structure, ensuring that tenant-specific access is enforced. - Enhanced error handling in the `CheckpointerService` to manage thread deletions and file cleanup more effectively. - Added tests to validate the new authorization logic, ensuring that users are correctly identified across different tenants. - Updated integration and unit tests to reflect changes in the rate limiting and authorization mechanisms.
…and code - Updated API/CLI SDK documentation to reflect changes in authentication and authorization handling, including the removal of the top-level `authorization` key. - Revised `api-configuration.md` to clarify the new structure of the `auth` object, incorporating roles and permissions. - Enhanced `auth-and-authorization.md` with detailed explanations of the new RBAC keys and their configurations. - Adjusted CLI command documentation to align with the new authentication setup. - Modified memory and store documentation to specify the new reach definitions and isolation scopes. - Updated tests to ensure compliance with the new authentication and authorization logic, including role-based access control. - Removed references to deprecated keys in request configuration validation.
- Updated the 10xgraph dependency to the commit hash 32d6bd45a02bef9ae0ab65e443e6a567716b9d7a. - Added hypothesis package version 6.170.15 with its dependencies. - Included sortedcontainers package version 2.4.0 as a dependency for hypothesis.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Part of the 1.0.0 auth revision. Replaces the
authorizationkey andAuthorizationBackendwithone
authkey that carries the role config, builds a coreIdentityper request, and lets storageenforce ownership by the caller's
reach. Depends on core10xgraphbranchfeat/auth-identity(
Identity,Reach,ThreadNotFoundError); merge core first.What changes
authkey.method(none|jwt|custom+path) plus RBAC keys next to it:roles(each withpermissions,inherits, requiredreach),roles_claim,permissions_claim,tenant_claims,default_role,system_identities."auth": "jwt"stillworks: default permission set, reach
own.check_auth_config, for boot,10xgraph config,auditandbuild. It refusesa leftover
authorizationorgraph_introspectionkey, unknown roles, permissions or reach,inheritance cycles, reach
tenantwithouttenant_claims, and bothroles_claimandpermissions_claim.tenant_claimsmust match the tenant columns on the checkpointer and store(refused in production, a warning otherwise).
core/auth/permissions_registry.py):graph(read, invoke, stream, stop,fix),
threads(read, write, delete),store,files(read, upload, delete),config:read,tasks(trigger, read, cancel),admin(read, write); wildcardsresource:*and*. Default set:everything except
admin:*. Tokenscope/scopesonly narrow.BaseAuth.authorize(identity, permission, resource=None), async, defaults to the RBAC check.It takes no request, so the jobs worker calls it too. Every transport passes the thread or file id
as
resource.authenticatenow takes anHTTPConnection(HTTP and WebSocket) and may getresponse/credentialas None.RequireIdentity(401, or close 1008 on WebSocket) andRequirePermission("resource", "action")(403), exported fromtenxgraph_apiwithIdentity.The route guard refuses to boot if a non-public route has neither.
core/threads.py::require_threadmakes one scoped read before the runlock and any response header on every thread route and run entry point (REST, stream, WS, AG-UI,
live, stop, observability). A foreign thread, message, memory, file or run answers 404. Reach
widens reads, lists, deletes and stop; runs and writes always stay own.
GET /v1/me:user_id,tenant,roles,permissions,reach;{"auth": "off"}withauth off.
config["user"]with the current role config before every run andchecks
tasks:trigger; refused or invalid identities fail the run without executing it. A tasklabel
identity="<name>"runs as a system identity fromauth.system_identitiesand neverreplaces a caller's identity.
/v1/tasksGET and cancel follow reach; trigger and PATCH stay own.user id plus tenant (
run_limits.identity_key).authorization.py,auth_backend.py,identity_cache.py,ownership_resolver.py,the ownership cache, tombstones,
POST /v1/threads/{id}/messages(history import) and theauthzreserved config key.request_config.pyandclient_filters.pymoved tocore/validation/.Breaking changes and migration
"authorization": "ownership"own)."authorization": {"backend": "rbac", "roles": {...}}auth.roles, each role withpermissionsandreach"authorization": "module:MyBackend""auth": {"method": "custom", "path": "module:MyAuth"}; overrideauthorizeon theBaseAuthclass (callsuper().authorizeto keep roles)authorize(user, resource, action, resource_id)authorize(identity, "resource:action", resource)graph_introspectiongraph:readcheckpointer:read/write/deletethreads:read/write/deletetasks:invoketasks:trigger(tasks:pauseremoved)checkpointer:import,graph:setupconfig["user"]as a dictIdentity(identity.get(key)/identity[key]still work)Testing
stream, WS, AG-UI, live, files pass the resource id), thread ownership and 404s, media lifecycle,
run guard recheck, rate-limit keying, jobs worker identity rebuild, system identities and task
reach (
tests/unit_tests/jobs/test_auth.py).pre-commit run --allpasses (ruff, mypy, bandit).<fill in: N passed, coverage>Notes for reviewers
core/auth/permissions.py(authorize_resource, identity reuse with the ratelimiter),
core/threads.py::require_thread,routers/graph/run_guard.py(recheck after thelock),
jobs/middleware.py::_run_identity(fails closed),checkpointer_service.py(file release on delete).
10xgraphfloor inpyproject.tomlmust point to the core release that shipsIdentity.10xgraph-docs,docs/auth-rbac), clientme()and the playground (feat/auth-mein each)follow in their own PRs.
authorization.isolation/isolation_scope/rbacbackend entriesare superseded and will be trimmed before release.