about summary refs log tree commit diff
path: root/gn_auth
AgeCommit message (Collapse)Author
5 hoursImplement assign-owner / revoke-owner in system admin resources HEAD mainClaude Sonnet 4.6
The system-administrator role carries system:resource:assign-owner (migration 20250729_02), but no endpoint used it. Sysadmins had no API path to bootstrap ownership on a resource that has no owner yet. Implement two endpoints in gn_auth/auth/system/admin/resources.py (the blueprint skeleton was already wired in a preceding commit): POST /auth/system/administration/resources/<resource_id>/assign-owner Body: {"user_id": "<uuid>"} Assigns the resource-owner role to the named user on the resource. POST /auth/system/administration/resources/<resource_id>/revoke-owner Body: {"user_id": "<uuid>"} Revokes the resource-owner role from the named user on the resource. Both check system:resource:assign-owner on the *system* resource, so a sysadmin can grant/revoke ownership without being resource-owner themselves. Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
5 hoursAdd package for administrative endpoints.Frederick Muriuki Muriithi
7 hoursfix(jwt-bearer-token): use AUTH_DB instead of SQL_URI for user/client lookupFrederick Muriuki Muriithi
JWTBearerToken.__init__ was calling with_db_connection with app.config["SQL_URI"] (the GeneNetwork MariaDB URI) to look up the authenticated user and OAuth2 client. gn_libs.sqlite3.with_db_connection expects a SQLite file path, so passing a MySQL URI causes an OperationalError: unable to open database file every time a JWT is validated through require_oauth.acquire(). Use app.config["AUTH_DB"] (the gn-auth SQLite database) for both lookups. Also normalise the whitespace in the user lookup lambda while here. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
31 hoursCleanup 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.
32 hoursDeprecate 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'.
32 hoursfeat(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>
33 hoursDeprecate endpoint /auth/resources/<uuid:resource_id>/user/assign.Frederick Muriuki Muriithi
33 hoursfeat(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>
2 daysFix error codes for various input validation errors.Frederick Muriuki Muriithi
2 daysfeat(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.
2 daysAssign 'system:user:create-user' privilege to 'system-administrator' role.Frederick Muriuki Muriithi
2 daysfeat(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>
2 daystests(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.
2 daysfeat(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>
2 daystest(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>
2 daysFix type annotations.Frederick Muriuki Muriithi
2 daysLint: Remove unused code and import.Frederick Muriuki Muriithi
3 daysMigration:Assign `system:user:list` privilege to `resource-owner` role.Frederick Muriuki Muriithi
9 daysfix: 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
9 daysRemove `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.
9 daysFetch role by ID rather than by user and ID.Frederick Muriuki Muriithi
2026-06-25Clear any related JWT tokens when deleting a client.Frederick Muriuki Muriithi
2026-06-25Generate JWTs for password auth flow too.Frederick Muriuki Muriithi
While we do not actually use the password-flow for authentication on the system, it is useful for getting tokens when running (integration) tests against the system. This commit allows the test harness to make use of the simpler password-flow authentication to get tokens.
2026-06-22Bugfix: Provide missing `redirect_uris` required argument.Frederick Muriuki Muriithi
2026-06-22Delete the credentials files since they are no longer needed.Frederick Muriuki Muriithi
2026-06-22Specify scopes when creating a client.Frederick Muriuki Muriithi
2026-06-15Allow generated files to be readable by other users.Frederick Muriuki Muriithi
On CI/CD, the tests are run under a different user that the one that runs the gn-auth service, therefore we need the generated files to be readable by more than just the user running the gn-auth service.
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-08Fix some minor linting errors.Frederick Muriuki Muriithi
2026-06-03wsgi: add delete-test-users commandClaude Sonnet 4.6
Add delete-test-users which reads the credentials file produced by create-test-users and deletes all listed users unconditionally via delete_users_by_id, bypassing policy checks. Intended for CI teardown.
2026-06-03wsgi: add delete-oauth2-client commandClaude Sonnet 4.6
Add delete-oauth2-client which reads a credentials file produced by create-oauth2-client or create-test-oauth2-client and removes the client and its associated tokens from the database.
2026-06-03wsgi: add create-test-oauth2-client commandClaude Sonnet 4.6
Add create-test-oauth2-client which reads the users-file produced by create-test-users to find the client owner, auto-generates the client name with the session timestamp, and delegates to __create_one_client__.
2026-06-03wsgi: add __create_one_client__ helper and create-oauth2-clientClaude Sonnet 4.6
Add a __create_one_client__ helper that constructs an OAuth2Client, hashes the secret, persists it via save_client, and returns a credential record dict. Add create-oauth2-client CLI command that exposes all client parameters explicitly. Preparation for reuse by create-test-oauth2-client.
2026-06-03wsgi: add create-test-users commandClaude Sonnet 4.6
Add create_test_users which auto-generates timestamped emails and random passwords for ephemeral test accounts, delegating DB creation to the __create_one_user__ helper introduced in the previous commit.
2026-06-03wsgi: extract __create_one_user__ helper from create_usersClaude Sonnet 4.6
Refactor create_users to delegate per-user DB creation to a shared __create_one_user__ helper. No behaviour change — preparation for reuse by the forthcoming create_test_users command.
2026-06-03wsgi: add delete-users CLI commandClaude Sonnet 4.6
Add a delete-users command that removes one or more users by UUID, unconditionally bypassing the policy checks in the HTTP endpoint. Delegates to delete_users_by_id from the authorisation users models.
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-06-02wsgi: add create-users CLI commandClaude Sonnet 4.6
Add a general-purpose `create-users` command that creates one or more users with explicitly specified name, email, password and role. Supported roles: system-admin (assigns default roles plus grant_sysadmin_role), none (assigns default roles only). Output is written as JSON to a file (with 0600 permissions) or stdout. Helper functions __parse_user_spec__ and __write_output__ are factored out for reuse by the forthcoming create-test-users command.
2026-05-21Override all settings with the startup settings before doing checks.Frederick Muriuki Muriithi
The startup checks should be used sparingly, if at all, and they override every other setting.
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-21Move migrations 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-21Remove unused argument/parameter from function.Frederick Muriuki Muriithi
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.