Skip to content

Commit daf0687

Browse files
marius-matheronesandzeroesuwwintCopilot
authored
fix: fix circular import caused by type annotations (#111)
* refactor: rename user_is_admin -> user_is_general_admin to make purpose clearer * refactor: rename SessionUser.is_admin SessionUser.is_biocommons_admin * feat: add group/platform admin checks for the user * refactor: rename get_current_user -> get_session_user for clarity * refactor: add DB checks to user_is_general_admin check * test: update tests to allow for updated admin check * test: add tests of user_is_general_admin check * test: add tests of DB admin checks * refactor: update is-admin endpoint to is-general-admin * refactor: update tests of is-admin check * refactor: move user permissions to a new module * feat: add check for is_biocommons_admin and a new router for biocommons admin routes * chore: add biocommons_admin router to main app * refactor: start moving routes to /biocommons-admin * refactor: simplify creating groups in the API * refactor: lookup methods for roles and platforms * refactor: rework group/role/platform creation endpoints * test: move biocommons-admin tests to a dedicated module * test: fix mocks in user tests * feat: add is_admin check for platform model * refactor: rework UserQueryParams to add group/platform admin checks, use it in all endpoints * test: update tests of get_users to include platform-specific users * test: test group or platform admin access * feat: more permissions checks that can be applied to endpoints * refactor: move 'get_or_404' checks into models * refactor: add permission checks to admin endpoints * refactor: renamed get_for_admin_roles -> get_from_admin_roles * refactor: move shared param types to schemas to avoid circular import * fix: should use _or_404 for getting the group * fix: need to return platform * fix: fix checking admin roles for platform * fix: allow for / in group IDs in URLs * test: update tests of admin API to reflect permissions * refactor: exclude biocommons-admin endpoints from docs/API schema * test: include short_name when creating group * feat: add simple endpoint for checking if current user has admin rights to a specific platform * fix: sync platform roles to db, response typing test: increase test coverate to 100% * fix: undefiend role name in error message * docs: docstring fixes * docs: update DB diagram * feat: add schemas for user profile data * feat: add an endpoint for fetching profile data for current user * fix: need to get user's name from Auth0 data * test: test getting profile data from DB and Auth0 data * test: test profile endpoint * refactor: cache the Auth0 management token - fetching it is slow * feat: add a dependency that allows looking up Auth0 userinfo endpoint directly * refactor: update profile endpoint to use userinfo lookup * test: update tests of profile data * fix: exclude revoked memberships from user profile data * test: check that revoked groups/platforms are excluded from profile data * refactor: set up new cache before replacing the existing one Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: use AsyncClient to get userinfo Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * test: fix override for get_auth0_user_info * test: different method to override userinfo lookup * fix: fix circular import by only importing db models for type checking --------- Co-authored-by: Marius <marius.mather@gmail.com> Co-authored-by: Uwe Winter <uwwint@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5cc64af commit daf0687

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

schemas/biocommons.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
These are the core schemas we use for storing/representing users
55
and their metadata
66
"""
7+
from __future__ import annotations
78

89
import re
910
from datetime import datetime
10-
from typing import Annotated, List, Literal, Optional, Self
11+
from typing import TYPE_CHECKING, Annotated, List, Literal, Optional, Self
1112

1213
from fastapi import Path
1314
from pydantic import (
@@ -22,9 +23,11 @@
2223
import db
2324
import schemas
2425
from auth0.user_info import UserInfo
25-
from db import models
2626
from db.types import ApprovalStatusEnum, GroupMembershipData, PlatformMembershipData
2727

28+
if TYPE_CHECKING:
29+
from db import models
30+
2831
# From Auth0 password settings
2932
ALLOWED_SPECIAL_CHARS = "!@#$%^&*"
3033
VALID_PASSWORD_REGEX = re.compile(

0 commit comments

Comments
 (0)