Skip to content

Commit

Permalink
feat: moved scopes to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
lchen-2101 committed Mar 18, 2024
1 parent 968c6c4 commit 6100935
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ INST_DB_HOST=localhost:5432
INST_DB_SCHEMA=public
JWT_OPTS_VERIFY_AT_HASH="false"
JWT_OPTS_VERIFY_AUD="false"
JWT_OPTS_VERIFY_ISS="false"
JWT_OPTS_VERIFY_ISS="false"
ADMIN_SCOPES=["query-groups","manage-users"]
3 changes: 2 additions & 1 deletion src/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from urllib import parse
from typing import Any
from typing import Any, Set

from pydantic import field_validator, ValidationInfo
from pydantic.networks import PostgresDsn
Expand All @@ -24,6 +24,7 @@ class Settings(BaseSettings):
inst_db_host: str
inst_db_scheme: str = "postgresql+asyncpg"
inst_conn: PostgresDsn | None = None
admin_scopes: Set[str] = set(["query-groups", "manage-users"])

def __init__(self, **data):
super().__init__(**data)
Expand Down
6 changes: 2 additions & 4 deletions src/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sqlalchemy.ext.asyncio import AsyncSession
from typing import List, Optional
from itertools import chain
from config import settings

from entities.engine import get_session
from entities.repos import institutions_repo as repo
Expand Down Expand Up @@ -46,11 +47,8 @@ def get_email_domain(email: str) -> str:
return None


admin_scopes = set(["query-groups", "manage-users"])


def is_admin(auth: AuthCredentials):
return admin_scopes.issubset(auth.scopes)
return settings.admin_scopes.issubset(auth.scopes)


def lei_association_check(func: DecoratedCallable) -> DecoratedCallable:
Expand Down

0 comments on commit 6100935

Please sign in to comment.