aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-01-19auth: Fix user registrationFrederick Muriuki Muriithi
The code checking for errors was buggy and would let empty values through. The sqlite3.IntegrityError exception was not being handled correctly, and would cause a failure in the application. This commit fixes the issues noted above. * gn3/auth/authorisation/roles.py: fix bug in generating query params * gn3/auth/authorisation/views.py: fix error checking code. Raise exception if email is already registered.
2023-01-18search: Ensure limits of chromosomal interval is non-negative.Arun Isaac
* gn3/api/search.py (parse_location_field): Ensure limits of chromosomal interval is non-negative.
2023-01-18search: Convert point locations to a +/- 50 kbase range.Arun Isaac
* gn3/api/search.py (parse_location_field): Convert point locations to a +/- 50 kbase range.
2023-01-18Pass species and species prefix as a single query argument.Arun Isaac
* gn3/api/search.py (parse_location_field): Accept a single species query argument instead of separate species and species prefix arguments. (parse_query): Pass parse_location_field a single species query argument.
2023-01-18auth: Fix tests after enforcing FOREIGN KEY constraintFrederick Muriuki Muriithi
Fix a number of tests and fixtures that were not conforming to the FOREIGN KEY constraints: * Each test that creates a new "object" needs to clean up after itself * Each fixture that sets up test data needs to clean up after itself
2023-01-18auth: Allow non-member users to access group resourcesFrederick Muriuki Muriithi
Allow users that are not members of a particular group to be granted access to that group's resources via an explicit role assignment. This is accomplished by removing the `FOREIGN KEY(group_id, user_id)` constraint.
2023-01-18auth: Enable FOREIGN KEY constraint for the connectionsFrederick Muriuki Muriithi
Enable the FOREIGN KEY constraints for the connections to the database to help with queries that would otherwise lead to data corruption.
2023-01-18pylintrc: Disable no-else-return check.Arun Isaac
else-return statements are closer to the cond ladders in lisp. They feel better composed, more symmetric and less like non-local exits. They should not be discouraged. * .pylintrc (disable): Add no-else-return.
2023-01-18Tolerate WEIGHT operator in parsed search queries.Arun Isaac
* gn3/api/search.py (remove_synteny_field): Tolerate WEIGHT operator in parsed search queries.
2023-01-18Implement synteny search.Arun Isaac
* gn3/api/search.py: Import gzip, Path from pathlib and curry from pymonad.tools. (IntervalLiftoverFunction): New variable. (query_subqueries, query_terms, field_processor_or, liftover, liftover_interval, parse_synteny_field, is_synteny_on, remove_synteny_field): New functions. (parse_location_field): Generalize to support synteny searches. (parse_query): Support synteny search queries. (search_results): Pass synteny files directory to parse_query.
2023-01-18Support location shorthands in search queries.Arun Isaac
* gn3/api/search.py: Import partial and reduce from functools. Import Callable from typing. (ChromosomalPosition, ChromosomalInterval, FieldProcessor): New classes. (apply_si_suffix, combine_queries, parse_location_field, interval_start, interval_end): New functions. (parse_query): Add field processors for location shorthands.
2023-01-18Split off search query parsing into separate function.Arun Isaac
* gn3/api/search.py (parse_query): New function. (search_results): Use parse_query.
2023-01-16auth: update privileges formatFrederick Muriuki Muriithi
Save privileges with ids of the form <top-level>:<sub-level>:<privilege-name> rather than using a UUID, to reduce indirection levels. * migrations/auth/20230116_01_KwuJ3-rework-privileges-schema.py: new migration to change the schema and IDs for the privileges. * Update code to use new privileges format * gn3/auth/authorisation/checks.py * gn3/auth/authorisation/groups.py * gn3/auth/authorisation/privileges.py * gn3/auth/authorisation/resources.py * gn3/auth/authorisation/roles.py * migrations/auth/20230116_01_KwuJ3-rework-privileges-schema.py * tests/unit/auth/fixtures/role_fixtures.py * tests/unit/auth/test_groups.py * tests/unit/auth/test_privileges.py * tests/unit/auth/test_roles.py
2023-01-11auth: assign default role. separate group creation from group adminFrederick Muriuki Muriithi
A newly registered user will have the ability to create a group. Once a user is a member of a group, either by creating a new group, or being added to a group, they should not be able to create any more groups, i.e. they lose the 'create-group' (and/or equivalent) privileges. This means that the group-administration privileges should be separated from the group-creation privilege. * gn3/auth/authorisation/roles.py: assign default roles to user on registration * gn3/auth/authorisation/views.py: assign default roles to user on registration * migrations/auth/20230111_01_Wd6IZ-remove-create-group-privilege-from-group-leader.py: separate group-creation role from group-administration role. * tests/unit/auth/fixtures/user_fixtures.py: Add group-creation role to test user * tests/unit/auth/test_roles.py: Add the group-creation role explicitly in the expected results for the test
2023-01-11auth: Add missing importFrederick Muriuki Muriithi
2023-01-05auth: Persist the user's registration detailsFrederick Muriuki Muriithi
If the registration details pass the validations steps, then persist the details in the database and respond with details about the newly created user. * gn3/auth/authentication/users.py: new functions * `save_user`: create and persist a new user * `set_user_password`: hash and persist the new password for the given user * gn3/auth/authorisation/views.py: Persist the user details and respond with the newly persisted user details.
2023-01-04auth: Add `/register-user` endpointFrederick Muriuki Muriithi
* gn3/app.py: register top-level error handlers. reorganise oauth2 blueprint. * gn3/auth/__init__.py: reorganise oaut2 blueprint. * gn3/auth/authentication/oauth2/views.py: reorganise oauth2 blueprint. * gn3/auth/authorisation/exceptions.py -> gn3/auth/authorisation/errors.py * gn3/auth/authorisation/groups.py: rename file/module * gn3/auth/authorisation/resources.py: rename file/module * gn3/auth/authorisation/views.py: Add `/register-user` endpoint * gn3/auth/blueprint.py: reorganise oauth2 blueprint. * gn3/errors.py: register top-level error handlers.
2023-01-04auth: return group info as part of user detailsFrederick Muriuki Muriithi
* gn3/app.py: import blueprint from authorisation views inorder to get all endpoints * gn3/auth/authentication/oauth2/views.py: remove the `/user` endpoint * gn3/auth/authorisation/views.py: add the `/user` endpoint and add the group information to the user details.
2023-01-04auth: Return only non-resource roles on `/user-roles` endpointFrederick Muriuki Muriithi
Resource roles will be returned as part of the resources request. * gn3/auth/authorisation/roles.py: Simplify query - only get non-resource roles * gn3/auth/authorisation/views.py: update docstring
2023-01-03auth: Fetch all of a user's roles.Frederick Muriuki Muriithi
* gn3/auth/authorisation/roles.py: Fetch roles from DB * gn3/auth/authorisation/views.py: Provide API endpoint for user roles * tests/unit/auth/test_roles.py: Tests to check fetching roles works correctly Fix linting and typing issues in the following files: * gn3/auth/authentication/oauth2/resource_server.py * gn3/auth/authentication/oauth2/views.py * tests/unit/auth/fixtures/oauth2_client_fixtures.py
2023-01-03auth: rename fixtures: test_* -> fxtr_*Frederick Muriuki Muriithi
Since test functions are defined starting with "test_", rename the fixture to more clearly indicate it is a fixture (fxtr_*), an not a test in itself.
2022-12-31auth: Document new ideas for privilegesFrederick Muriuki Muriithi
2022-12-28auth: Add resource server and /user endpointFrederick Muriuki Muriithi
Add a resource server with the validator for the bearer token to protect the resources endpoints. Add a protected `/user` endpoint that returns the user details for valid tokens. * gn3/auth/authentication/oauth2/resource_server.py: new file * gn3/auth/authentication/oauth2/views.py: add /user endpoint
2022-12-23Update how to set configurations in READMEzsloan
2022-12-23Add a couple necessary environment variableszsloan
2022-12-22tests: Setup environment variables and configsFrederick Muriuki Muriithi
* gn3/settings.py: leave `OAUTH2_ACCESS_TOKEN_GENERATOR` in its default setting * tests/unit/auth/fixtures/oauth2_client_fixtures.py: setup `AUTHLIB_INSECURE_TRANSPORT` before running the OAuth2 tests * tests/unit/conftest.py: setup the test application's configuration correctly for the tests.
2022-12-22auth: implement OAuth2 flow.oauth2_auth_flowFrederick Muriuki Muriithi
Add code to implement the OAuth2 flow. * Add test fixtures for setting up users and OAuth2 clients * Add tests for token generation with the "Password Grant" flow * Fix some issues with test due to changes in the database connection's row_factory
2022-12-21auth: oauth2: users: Add expected propertyFrederick Muriuki Muriithi
* gn3/auth/authentication/users.py: authlib expects the user object to have a `get_user_id` method.
2022-12-21migrations: create the authorisation_code tableFrederick Muriuki Muriithi
* migrations/auth/20221219_03_PcTrb-create-authorisation-code-table.py: new migration * tests/unit/auth/test_migrations_create_tables.py: test new migration
2022-12-21migrations: create oauth2_tokens tableFrederick Muriuki Muriithi
* migrations/auth/20221219_02_buSEU-create-oauth2-tokens-table.py * tests/unit/auth/test_migrations_create_tables.py
2022-12-21migrations: New migrationFrederick Muriuki Muriithi
* migrations/auth/20221219_01_CI3tN-create-oauth2-clients-table.py: New migration * tests/unit/auth/test_migrations_create_tables.py: tests for new migration
2022-12-21auth: Add default row_factory to sqlite3Frederick Muriuki Muriithi
* gn3/auth/db.py: For easier setting up of objects after querying, set the default row_factory object that allows indexing by database field name.
2022-12-21Enable authenticationFrederick Muriuki Muriithi
* gn3/auth/authentication/routes.py: Add `/login` endpoint and a function to validate the login credentials. * gn3/auth/authentication/users.py: add function to fetch user details by email
2022-12-21gn3: (gn3.random -> gn3.chancy): Rename module to avoid conflicts.Frederick Muriuki Muriithi
Rename the `gn3.random` module to gn3.chancy to avoid conflicts with Python's `random` module. * gn3/random.py -> gn3/chancy.py: rename module * gn3/commands.py: update import * gn3/computations/partial_correlations.py: update import * gn3/computations/qtlreaper.py: update import * gn3/computations/rust_correlation.py: update import * gn3/db/correlations.py: update import * gn3/db/traits.py: update import * gn3/heatmaps.py: update import * tests/integration/conftest.py: update import
2022-12-12auth: functions to get user resourcesFrederick Muriuki Muriithi
* gn3/auth/authorisation/resources.py: add function to get the resources that the user has access to.
2022-12-12tests: Update fixtures to use for testing resources functionsFrederick Muriuki Muriithi
2022-12-12auth: Add a way to check whether a user is a group leaderFrederick Muriuki Muriithi
* gn3/auth/authorisation/groups.py: Add `is_group_leader` function
2022-12-12auth: pass cursor object to `user_group` functionFrederick Muriuki Muriithi
2022-12-12auth: Attach group to GroupRole, rather than group_idFrederick Muriuki Muriithi
2022-12-12tests: Reorganise fixturesFrederick Muriuki Muriithi
Split the fixtures into separate modules for easier management * tests/unit/auth/conftest.py: Import all from the `fixtures` package. Delete all fixtures from the file * tests/unit/auth/fixtures/__init__.py: new `fixtures` package * tests/unit/auth/fixtures/group_fixtures.py: new groups fixtures module * tests/unit/auth/fixtures/migration_fixtures.py: new migrations fixtures module * tests/unit/auth/fixtures/resource_fixtures.py: new resources fixtures module * tests/unit/auth/fixtures/role_fixtures.py: new roles fixtures module * tests/unit/auth/fixtures/user_fixtures.py: new users fixtures module
2022-12-08Remove unused importFrederick Muriuki Muriithi
2022-12-08auth: test for `user_resources` function (incomplete)Frederick Muriuki Muriithi
* gn3/auth/authorisation/resources.py: dummy `user_resources` function * tests/unit/auth/conftest.py: (incomplete): Add some fixtures for testing the `user_resources` function * tests/unit/auth/test_resources.py: test the `user_resources` function
2022-12-08tests: Fix issues caught by testsFrederick Muriuki Muriithi
The addition of the `public` field in the `resources` table, led to some previously passing tests to fail. This commit fixes the failures, and cleans up some pylint issues. * gn3/auth/authorisation/resources.py: add `public` to db queries * tests/unit/auth/test_groups.py: fix pylint issues
2022-12-08auth: add test to retrieve public resourcesFrederick Muriuki Muriithi
* gn3/auth/authorisation/resources.py: new functions * resource_categories: retrieves all resource categories * public_resources: retrieves all public resources * tests/unit/auth/test_resources.py: test `public_resources` function
2022-12-08auth: add function to retrieve a user's groupFrederick Muriuki Muriithi
* gn3/auth/authorisation/groups.py: new `user_group` function * tests/unit/auth/test_groups.py: test `user_group` function
2022-12-08migrations: Add column `public` to `resources` tableFrederick Muriuki Muriithi
* migrations/auth/20221208_01_sSdHz-add-public-column-to-resources-table.py: new migration script. * tests/unit/auth/test_migrations_add_remove_columns.py: test new migration script
2022-12-06Use a dataset's name to fetch it's metadata from RDFMunyoki Kilyungi
* gn3/api/metadata.py (jsonify_dataset_metadata): Rewrite metadata end-point to use a dataset's name instead of it's accession_id. * gn3/db/rdf.py (get_dataset_metadata): Replace accession_id with name. Use one single RDF query instead of multiple queries.
2022-12-06migrations: Add `group_user_roles_on_resources` tableFrederick Muriuki Muriithi
* migrations/auth/20221206_01_BbeF9-create-group-user-roles-on-resources-table.py: new migration * tests/unit/auth/test_migrations_create_tables.py: Test creation of table * tests/unit/auth/test_migrations_indexes.py: Test creation of index
2022-12-06mypy and pylint fixesAlexander_Kabui
2022-12-06remove noisy tests for constant array correlationAlexander_Kabui