about summary refs log tree commit diff
path: root/gn_auth/auth/authorisation
AgeCommit message (Collapse)Author
11 daysrefactor(system/views): remove dead deprecation-check code HEAD mainClaude Sonnet 4.6
The /auth/system/roles endpoint has no active blueprint registration — the system Blueprint is only reachable via /auth/resource/system/roles. The `if "/resource/" not in request.path` branch could never fire, so remove it along with _SUCCESSOR, and the warnings import. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
12 daysBugfix: Use correct spec strings.Frederick Muriuki Muriithi
These bugs were introduced by Claude, and I missed them during review.
12 daysfix(auth): check system:user:list against system resource in resource_usersClaude
The HACK block in resource_users() was checking the system:user:list privilege against the requested resource_id rather than the system resource. This made the sysadmin branch a dead leg: sysadmins hold system:user:list on the system resource, not on individual data resources. Fix: pass system_resource(conn).resource_id for the system-level check. Also restructure to early-return on auth failure (cleaner control flow). Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
12 daysrefactor(auth): remove deprecated authorised_for and authorised_for2Claude
All callers have been migrated to authorised_for_spec (previous commit). Remove the two deprecated functions and their now-orphaned helpers: - authorised_for() and authorised_for2() deleted - __organise_privileges_by_resource_id__() deleted (only used by authorised_for) - Orphaned imports removed: reduce, Sequence, Resource, User, db_row_to_privilege Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
12 daysrefactor(auth): migrate authorised_for/2 -> authorised_for_specClaude
Replace all uses of the deprecated authorised_for() and authorised_for2() helpers with authorised_for_spec() across resources/views.py and data/phenotypes.py. - resources/views.py (resource_users HACK block): two authorised_for() calls replaced; the intermediate dict merge collapsed into a plain boolean since authorised_for_spec returns bool directly. - resources/views.py (assign_role_to_user, unassign_role_to_user): authorised_for() was called but its return value was discarded, making the check a silent no-op. Now replaced with authorised_for_spec() and a proper if/raise guard. Also fixes a typo: the privilege string was "resource:role:assign-role" (non-existent); corrected to the real privilege "resource:user:assign-role". - resources/views.py (unassign_resource_role_privilege): direct replacement; intermediate _authorised variable removed. - data/phenotypes.py (link_phenotype_data): two authorised_for2() calls replaced; .resource_id extracted from the Resource objects to satisfy authorised_for_spec's UUID argument. User type annotation added. Reivewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
13 daysUse `gn_libs.sqlite3 instead of deprecated `gn_auth.auth.db.sqlite3`.Frederick Muriuki Muriithi
13 daysrefactor(users): move delete_users to admin users blueprintClaude
Move POST /auth/user/delete to POST /auth/system/administration/users/delete, consistent with the create endpoint already living there. gn_auth/auth/system/admin/users.py: - Add imports for sqlite3, reduce, Sequence, AuthorisationError, authorised_for2, and system_resource. - Move __delete_users_individually__, __fetch_non_deletable_users__, __non_deletable_with_reason__, and delete_users() from users/views.py. gn_auth/auth/authorisation/users/views.py: - Remove the four functions moved to admin/users.py. The sole known caller (GN2 wqflask/oauth2/users.py) is updated in the accompanying genenetwork2 patch. Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
13 daysfeat(system/roles): add Deprecation header on old pathClaude
GET /auth/system/roles is superseded by GET /auth/resource/system/roles, which has been live since the system Blueprint was registered under the resources Blueprint. Add Deprecation: true and a Link successor-version header when the endpoint is reached via the old path, so callers can discover the new URL. The old registration in auth/views.py already carries a TODO noting it should be removed once consumers are updated. Callers to migrate: - GN2: wqflask/views.py, metadata_edits.py (×3), flask_extensions.py, oauth2/ui.py, oauth2/request_utils.py, oauth2/resources.py (×2) - GN3: gn3/api/metadata.py, gn3/api/case_attributes.py - gn-integration-tests: tests/test_gn_auth_smoke.py Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
13 daysMove create_new_user to gn_auth/auth/system/admin/users.pyClaude Sonnet 4.6
Move the user-creation endpoint from gn_auth/auth/authorisation/users/views.py into the new sysadmin package at gn_auth/auth/system/admin/users.py. New URL: POST /auth/system/administration/users/create Old URL: POST /auth/user/create now issues a 308 Permanent Redirect. The admin blueprint is updated to register the new users blueprint at /users. Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
2026-08-28Add package for administrative endpoints.Frederick Muriuki Muriithi
2026-08-27Cleanup deprecation warnings: Switch to gn_libs.sqlite3Frederick Muriuki Muriithi
The gn_auth.auth.db.sqlite3 module is deprecated and should be removed. This cleanup goes a ways towards that goal.
2026-08-27Deprecate endpoint /auth/resources/<uuid:resource_id>/user/unassign.Frederick Muriuki Muriithi
Prefer the endpoint `/auth/users/<uuid:user_id/roles/revoke` that conforms to the Subject-Verb-Object paradigm, i.e. Revoke from a user (subject), the specified role acting on the specified resource (object) -- revoke a role would be the 'Verb'.
2026-08-27feat(users/admin): implement POST /auth/user/<uid>/roles/revokeClaude Sonnet 4.6
Adds unassign_user_role_by_name to roles/models.py — mirrors assign_user_role_by_name but issues a resource-scoped DELETE, resolving the TODO on the older revoke_user_role_by_name which lacked the resource_id filter. The new revoke_user_role endpoint checks resource:user:assign-role (same privilege as assign) via can_assign_role, then calls unassign_user_role_by_name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
2026-08-27Deprecate endpoint /auth/resources/<uuid:resource_id>/user/assign.Frederick Muriuki Muriithi
2026-08-27feat(users/admin): implement POST /auth/user/<uid>/roles/assignClaude Sonnet 4.6
Checks resource:user:assign-role via can_assign_role (gn_libs.privileges.resources) on the caller's roles for the request's resource_id — caller must hold resource-owner (or masquerade as one) on that resource. Updates test setup to grant resource-owner on SYSTEM_RESOURCE instead of system-administrator, matching the actual privilege model. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
2026-08-26feat(users/admin): implement POST /auth/user/create endpointClaude Sonnet 4.6
Parses email/name/password from the JSON body, calls create_verified_user, and returns 201 with the new user's user_id, email, and name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com> Added input validation.
2026-08-26feat(admin/users): wire auth guards on POST /auth/user/createClaude Sonnet 4.6
Adds @require_oauth("profile") for 401 on unauthenticated requests and an authorised_for2 check for the system:user:create-user privilege, raising ForbiddenAccess (403) for non-admin callers. Returns 501 for the success path until the body logic is implemented. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
2026-08-26tests(admin): HTTP integration tests for POST /auth/user/createClaude Sonnet 4.6
Two TDD tests that define the expected auth behaviour of the new create-user endpoint before it is implemented: - No Authorization header → 401 - Valid token for a non-admin user → 403 Both tests fail (404) until the endpoint exists. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com> Add's aso a dummy endpoint.
2026-08-26feat(admin/users): implement create_verified_userClaude
Replaces the dummy stub with a real implementation that: - calls save_user(cursor, email, name, verified=True) to create the user with the verified flag set, bypassing the email verification flow - calls set_user_password to store the hashed credential in user_credentials - returns the newly created User with no roles assigned Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
2026-08-26test(admin/users): unit tests for create_verified_user model functionClaude
Two unit tests for the (not yet implemented) create_verified_user function in gn_auth.auth.authorisation.users.admin.models: * test_create_verified_user_sets_verified_flag — asserts user.verified is True and the flag is persisted in the DB * test_create_verified_user_has_no_roles — asserts no roles are assigned to the newly created user Both tests use conn_after_auth_migrations to run against a fully migrated SQLite test database. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
2026-08-26Fix type annotations.Frederick Muriuki Muriithi
2026-08-26Lint: Remove unused code and import.Frederick Muriuki Muriithi
2026-08-19fix: Improve mrna/genotype unlinked data queries to avoid including full ↵zsloan
dataset list in query Previously the full list of datasets (currently over 900) was included in the query. This commit instead handles the exclusion at the Python level, dramatically speeding up the query
2026-08-19Remove `grant_access_to_sysadmins()` function.Frederick Muriuki Muriithi
The "system-administrator" role acts at the system level and should not be granted against a non-system resource. This function is therefore a bug in its entirety and thus needed to go.
2026-08-19Fetch role by ID rather than by user and ID.Frederick Muriuki Muriithi
2026-06-15Deactivate lint check for now.Frederick Muriuki Muriithi
2026-06-08Fix: Temp traits were broken by some recent changes that prevents auth from ↵zsloan
ever allowing them This commit allows the auth system to handle Temp traits (by just treating them as public traits)
2026-06-03Only grant system-administration role against the system resource.Frederick Muriuki Muriithi
2026-06-02users/models: add delete_users_by_id functionClaude Sonnet 4.6
Add a low-level delete_users_by_id function that removes users and all their dependent data unconditionally, bypassing the policy checks in the '/auth/users/delete' HTTP endpoint (which refuses to delete privileged users). This is intended for use by CLI test-teardown commands and the sudo-wrapped CI cleanup script. It might also find utility in other places where we do actually need to delete a user and their data unconditionally. Co-authored-by: Frederick Muriuki Muriithi <fredmanglis@gmail.com>
2026-05-21Remove dead code caught by vulture.Frederick Muriuki Muriithi
2026-05-21Move scripts to top-level gn_auth package.Frederick Muriuki Muriithi
In preparation for migrating to pyproject.toml (from setup.py and friends) we need to have only one top-level package. This will also help in improving testing and checks down the line, since everything will be relative to one single top-level directory.
2026-05-21Deprecate functions which duplicate those in gn-libs.Frederick Muriuki Muriithi
The `gn_auth.auth.authorisation.resources.checks.can_[edit/delete]` functions duplicate the utility provided by similar named functions in the `gn_libs.privileges.resources` package. These ones are, thus, deprecated in favour of the gn-libs ones.
2026-05-21Delete unused function.Frederick Muriuki Muriithi
The `gn_auth.auth.authorisation.resources.checks.can_view` function is no longer used in this code base. It can be safely removed.
2026-05-20Raise a NotFoundError if not a single resource is found.Frederick Muriuki Muriithi
2026-05-20Initialise initial value used in reduce.Frederick Muriuki Muriithi
To avoid failures later due to missing keys, we initialise the initial value used in reduce to a dict with empty tuples for every key.
2026-05-18Refactor authorisation-by-datasets-and-traits endpoint.Frederick Muriuki Muriithi
Fetch resources using the dataset names (and trait names where relevant) to simplify the code, and make it clearer what the endpoint actually does.
2026-05-18Fetch genotype resources by dataset.Frederick Muriuki Muriithi
2026-05-18Fetch mRNA resources by dataset name.Frederick Muriuki Muriithi
2026-05-18Fetch phenotype resources by dataset name and trait name.Frederick Muriuki Muriithi
2026-05-18Update call to `can_edit` to separate resource and system privilegesFrederick Muriuki Muriithi
2026-05-01Use module-level logging rather than the app's logger.Frederick Muriuki Muriithi
2026-05-01Ensure ALL users with access to the resource are actually listed.Frederick Muriuki Muriithi
2026-04-23Remove debug artifact.Frederick Muriuki Muriithi
2026-04-23Improve error messages.Frederick Muriuki Muriithi
2026-04-23Fix minor linting bugs.Frederick Muriuki Muriithi
2026-04-23Allow anonymous users "public-view" privileges.Frederick Muriuki Muriithi
The default system-level privilege is the "public-view", i.e. the users can view basic details about the Genenetwork system. If no authorisation is provided when accessing the /auth/system/roles endpoint, return the default role/privilege.
2026-04-20Implement editing resource name.Frederick Muriuki Muriithi
2026-04-20Use module-level logger rather than application's logger.Frederick Muriuki Muriithi
2026-04-15Do not grant sysadmins direct access at resource creation.Frederick Muriuki Muriithi
2026-04-08user resources: Add a text filter for further filtering.Frederick Muriuki Muriithi