aboutsummaryrefslogtreecommitdiff
path: root/gn3
AgeCommit message (Collapse)Author
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-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-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-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-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-06mypy and pylint fixesAlexander_Kabui
2022-12-02correlations: return `None` rather than zero for missing lit corrsFrederick Muriuki Muriithi
* gn3/computations/correlations.py: Return `None` for missing literature correlations rather than zero. Update the sorting key to avoid issues with comparing floats to NoneType objects
2022-11-29remove trailing whitespaceAlexanderKabui
2022-11-29remove unused function parameterAlexanderKabui
2022-11-28Catch a URLError when virtuoso isn't running at allMunyoki Kilyungi
* gn3/api/metadata.py: Import URLError. (jsonify_dataset_metadata): Add URLError in except block.
2022-11-28Fix pylint errorsMunyoki Kilyungi
* gn3/api/general.py: Delete rdf import. Delete trailing white spaces. * gn3/api/metadata.py: Delete trailing white spaces.
2022-11-28Fail gracefully when virtuoso is not accessibleMunyoki Kilyungi
* gn3/api/metadata.py: import RemoteDisconnected. (jsonify_dataset_metadata): Wrap get_dataset_metadata in try block.
2022-11-24auth: Check for authentication and fix errorsFrederick Muriuki Muriithi
* gn3/auth/authorisation/groups.py: base `MembershipError` on new `AuthorisationError` base exception. Use new authentication checking decorator. * gn3/auth/authorisation/privileges.py: Change argument to User object rather than UUID object * gn3/auth/authorisation/roles.py: Use new authentication checking decorator. * tests/unit/auth/test_groups.py: use `conftest.TEST_USER` * tests/unit/auth/test_privileges.py: use `conftest.TEST_USER` * tests/unit/auth/test_roles.py: use `conftest.TEST_USER`
2022-11-24auth: Implement `create_resource` functionFrederick Muriuki Muriithi
* gn3/auth/authentication/checks.py: new `authenticated_p` decorator to apply on any function that requires the user to be authenticated before it runs. * gn3/auth/authorisation/checks.py: use a `auth.authentication.users.User` object rather than a UUID object in the global `g`. * gn3/auth/authorisation/groups.py: Implement the `authenticated_user_group` function to get the group(s) in which the currently authenticated user belongs. * gn3/auth/authorisation/resources.py: Implement the `create_resource` function correctly. * tests/unit/auth/conftest.py: extract the User objects into a global variable for reusability with the tests. * tests/unit/auth/test_resources.py: Use global user objects from conftest in the tests. Set a User object (rather than UUID) in the global `g` variable.
2022-11-24auth: Define base exceptionsFrederick Muriuki Muriithi
* gn3/auth/authentication/exceptions.py: define `AuthenticationError` * gn3/auth/authorisation/exceptions.py: define `AuthorisationError`
2022-11-24tests: Add test for `create_resource`Frederick Muriuki Muriithi
* gn3/auth/authorisation/resources.py: Define Resource and ResourceCategory classes. Create the `create_resource` stub. * tests/unit/auth/test_resources.py: test for `create_resource` function
2022-11-23Create a new REST endpoint for fetching a phenotype's metadataMunyoki Kilyungi
* gn3/api/general.py: (dataset_metadata) Delete. * gn3/api/metadata.py: Import Blueprint, jsonify, current_app, SPARQLWrapper and get_dataset_metadata. (metadata): New Blueprint (jsonify_dataset_metadata): New function/end-point. * gn3/app.py: Import metadata (create_app): Register metadata blueprint.
2022-11-21auth: Prevent group leader from being a member of multiple groupsFrederick Muriuki Muriithi
* gn3/auth/authorisation/groups.py: Assign the group leader at group creation time. * tests/unit/auth/test_groups.py: Ensure the group leader is only ever a member of a single group.
2022-11-17auth: Finish implementation of `create_group_role`Frederick Muriuki Muriithi
* gn3/auth/authorisation/groups.py: Add `GroupRole` type. Fix typing annotations. Fix bugs. * tests/unit/auth/conftest.py: Fix bugs. * tests/unit/auth/test_groups.py: Fix test to run.
2022-11-17auth: Define the `User` typeFrederick Muriuki Muriithi
* gn3/auth/authentication.py -> gn3/auth/authentication/__init__.py: Convert module to package * gn3/auth/authentication/users.py: Define the `User` type
2022-11-16auth: fix bugs in the codeFrederick Muriuki Muriithi
* gn3/auth/authorisation/privileges.py: Set id to UUID type * gn3/auth/authorisation/roles.py: fix parameters to types that sqlite3 supports * gn3/auth/db.py: add logging for errors and re-raise the exception * tests/unit/auth/test_roles.py: fix test
2022-11-16Inject SPARQLWrapper as a parameterMunyoki Kilyungi
* gn3/db/rdf.py: Delete gn3.setting.SPARQL_ENDPOINT import. (sparql_query): Inject SPARQLWrapper. (get_dataset_metadata): Ditto.
2022-11-15auth: Add `create_group_role` function.Frederick Muriuki Muriithi
2022-11-15auth: Return results of calling function directlyFrederick Muriuki Muriithi
* gn3/auth/authorisation/checks.py: Return results of calling the function rather than a dict of values that include the results. * gn3/auth/authorisation/groups.py: Use the newer form of `authorised_p` decorator. * tests/unit/auth/test_groups.py: Update tests
2022-11-15auth: Specify types for privileges, roles, groupsFrederick Muriuki Muriithi
Use specified types for privileges, roles and types rather than using strings to help with limiting bugs. * gn3/auth/authorisation/groups.py: Specify and use the `Group` type * gn3/auth/authorisation/privileges.py: Specify and use the `Privilege` type * gn3/auth/authorisation/roles.py: Specify the `Role` type. Add the `create_role` function.
2022-11-15auth: Add some typing information to the functionsFrederick Muriuki Muriithi
2022-11-15auth: Reorganise package - move function to `checks` moduleFrederick Muriuki Muriithi
* gn3/auth/authorisation/__init__.py: delete function * gn3/auth/authorisation/checks.py: move function to `checks` module
2022-11-15pylint: Fix linting errors.Frederick Muriuki Muriithi
2022-11-14auth: Implement `create_group`Frederick Muriuki Muriithi
2022-11-14auth: Add test for `create_group`Frederick Muriuki Muriithi
* gn3/auth/authorisation/__init__.py: Add `authorised_p` decorator to be used for all function requiring authorisation. * gn3/auth/authorisation/groups.py: Add `create_group` function stub * tests/unit/auth/conftest.py: Add fixture for test users * tests/unit/auth/test_groups.py: Add tests for `create_group`
2022-11-10Migrations: Add migration for 'resources' tableFrederick Muriuki Muriithi
* gn3/migrations.py: Minor change * migrations/auth/20221110_01_WtZ1I-create-resources-table.py: new migration * tests/unit/auth/test_create_table_migrations.py: test new migration
2022-11-08Fix issue where only primary samples were used when all samples arezsloan
selected This is because base_samples was set to all_samples_ordered, which only includes primary samples + parents/f1s. Setting this to an empty list fixed the issue and caused it to use all samples again.
2022-11-08Tests: Generalise testing 'CREATE TABLE' migrationsFrederick Muriuki Muriithi
* gn3/settings.py: Omit trailing slash * tests/unit/auth/test_create_table_migrations.py: Generalise testing migrations that create tables. * tests/unit/auth/test_create_user_credentials_table.py: delete * tests/unit/auth/test_migration_create_users_table.py: delete
2022-11-08Settings: Provide default `AUTH_DB` setting.Frederick Muriuki Muriithi
2022-11-08Tests: Tests the credentials check systemFrederick Muriuki Muriithi
* gn3/auth/authentication.py: Fix issues caught by tests * tests/unit/auth/test_credentials.py: Add fixtures and tests for credentials checking
2022-11-03Add credentials checkingFrederick Muriuki Muriithi
* gn3/auth/authentication.py: new function `credentials_in_database` * gn3/auth/authentication/__init__.py: replace package with module * gn3/settings.py: new `AUTH_MIGRATIONS` configuration variable * migrations/auth/20221103_02_sGrIs-create-user-credentials-table.py: new migration * tests/unit/auth/test_credentials.py: test the `credentials_in_database` function * tests/unit/conftest.py: more test fixtures
2022-11-03Initialise the Auth(entic|oris)ation packagesFrederick Muriuki Muriithi
Initialise the authentication/authorisation system packages and set up the initial database migrations to set up the system. * README.md: Add documentation on migrations * gn3/auth/__init__.py: init package * gn3/auth/authentication/__init__.py: init package * gn3/auth/authorisation/__init__.py: init package * gn3/migrations.py: provide migration utilities * migrations/auth/20221103_01_js9ub-initialise-the-auth-entic-oris-ation-database.py: new migration * tests/unit/auth/test_init_database.py: test new migration applies and rolls back as expected * tests/unit/conftest.py: fixtures for unit tests * yoyo.auth.ini: basic configuration for yoyo-migration for auth system migrations
2022-11-02Re-implement RDF related code to use monads in its own moduleMunyoki Kilyungi
* gn3/api/general.py: Replace gn3.db.datasets import with gn3.db.rdf. (dataset_metadata) <jsonify>: Replace datasets.dataset_metadata with rdf.get_dataset_metadata. * gn3/db/datasets.py: Remove unused imports. (sparql_query, dataset_metadata): Delete. * gn3/db/rdf.py: (sparql_query, get_dataset_metadata): New functions.
2022-11-02Fix pylint and mypy errorsMunyoki Kilyungi
* gn3/db/sample_data.py (get_trait_csv_sample_data): Pass __query directly to cursor.execute. Rename value to _value in for loop to make mypy pass. * gn3/db_utils.py (Connection): Add class docstring. (Connection.cursor): Add docstring. * mypy.ini: Add an entry for xapian.
2022-10-28Use Xapian index path from app settings.Arun Isaac
App settings should be accessed from current_app. It should not be hard-coded to a variable in a module. * gn3/db_utils.py: Do not import XAPIAN_DB_PATH from gn3.settings. (xapian_database): Accept path argument. * gn3/api/search.py: Import current_app from flask. (search_results): Pass Xapian index path to xapian_database.