From 2b23710b8eed19994d89953e22d985203be333f1 Mon Sep 17 00:00:00 2001 From: Semyon Grigoriev Date: Tue, 23 Jul 2024 16:31:53 +0300 Subject: [PATCH 1/3] cli fix --- Makefile | 82 +++++++++++++++++----------------- auth_backend/cli/process.py | 9 ++-- auth_backend/cli/scope.py | 5 ++- auth_backend/cli/user_group.py | 6 ++- 4 files changed, 52 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index a35a88a5..4e21100d 100644 --- a/Makefile +++ b/Makefile @@ -1,64 +1,64 @@ SHELL := /bin/bash run: - source ./venv/bin/activate && uvicorn --reload --log-config logging_dev.conf auth_backend.routes.base:app + source ./.venv/bin/activate && uvicorn --reload --log-config logging_dev.conf auth_backend.routes.base:app -configure: venv - source ./venv/bin/activate && pip install -r requirements.dev.txt -r requirements.txt +configure: .venv + source ./.venv/bin/activate && pip install -r requirements.dev.txt -r requirements.txt -venv: - python3.11 -m venv venv +.venv: + python3.11 -m .venv .venv format: - source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./auth_backend - source ./venv/bin/activate && isort ./auth_backend - source ./venv/bin/activate && black ./auth_backend - source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./tests - source ./venv/bin/activate && isort ./tests - source ./venv/bin/activate && black ./tests - source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./migrations - source ./venv/bin/activate && isort ./migrations - source ./venv/bin/activate && black ./migrations + source ./.venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./auth_backend + source ./.venv/bin/activate && isort ./auth_backend + source ./.venv/bin/activate && black ./auth_backend + source ./.venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./tests + source ./.venv/bin/activate && isort ./tests + source ./.venv/bin/activate && black ./tests + source ./.venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./migrations + source ./.venv/bin/activate && isort ./migrations + source ./.venv/bin/activate && black ./migrations db: docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-auth_api postgres:15 migrate: - source ./venv/bin/activate && alembic upgrade head + source ./.venv/bin/activate && alembic upgrade head test: - source ./venv/bin/activate && python3 -m pytest --verbosity=2 --showlocals --log-level=DEBUG + source ./.venv/bin/activate && python3 -m pytest --verbosity=2 --showlocals --log-level=DEBUG create-user: python -m auth_backend user create --email test-user@profcomff.com --password string create-admin: - source ./venv/bin/activate && python -m auth_backend user create --email test-admin@profcomff.com --password string - source ./venv/bin/activate && python -m auth_backend scope create --name auth.group.create --comment auth.group.create --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.group.delete --comment auth.group.delete --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.group.read --comment auth.group.read --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.group.update --comment auth.group.update --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.scope.create --comment auth.scope.create --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.scope.delete --comment auth.scope.delete --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.scope.read --comment auth.scope.read --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.scope.update --comment auth.scope.update --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.user.delete --comment auth.user.delete --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.user.read --comment auth.user.read --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.user.update --comment auth.user.update --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.read --comment auth.airflow_outer_auth.link.read --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.create --comment auth.airflow_outer_auth.link.create --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.delete --comment auth.airflow_outer_auth.link.delete --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.read --comment auth.coder_outer_auth.link.read --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.create --comment auth.coder_outer_auth.link.create --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.delete --comment auth.coder_outer_auth.link.delete --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.read --comment auth.mailu_outer_auth.link.read --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.create --comment auth.mailu_outer_auth.link.create --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.delete --comment auth.mailu_outer_auth.link.delete --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.read --comment auth.postgres_outer_auth.link.read --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.create --comment auth.postgres_outer_auth.link.create --creator 1 - source ./venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.delete --comment auth.postgres_outer_auth.link.delete --creator 1 - source ./venv/bin/activate && python -m auth_backend user_group create --user_id 1 --group_id 1 + source ./.venv/bin/activate && python -m auth_backend user create --email test-admin@profcomff.com --password string + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.group.create --comment auth.group.create --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.group.delete --comment auth.group.delete --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.group.read --comment auth.group.read --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.group.update --comment auth.group.update --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.scope.create --comment auth.scope.create --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.scope.delete --comment auth.scope.delete --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.scope.read --comment auth.scope.read --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.scope.update --comment auth.scope.update --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.user.delete --comment auth.user.delete --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.user.read --comment auth.user.read --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.user.update --comment auth.user.update --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.read --comment auth.airflow_outer_auth.link.read --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.create --comment auth.airflow_outer_auth.link.create --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.delete --comment auth.airflow_outer_auth.link.delete --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.read --comment auth.coder_outer_auth.link.read --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.create --comment auth.coder_outer_auth.link.create --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.delete --comment auth.coder_outer_auth.link.delete --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.read --comment auth.mailu_outer_auth.link.read --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.create --comment auth.mailu_outer_auth.link.create --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.delete --comment auth.mailu_outer_auth.link.delete --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.read --comment auth.postgres_outer_auth.link.read --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.create --comment auth.postgres_outer_auth.link.create --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.delete --comment auth.postgres_outer_auth.link.delete --creator_email test-admin@profcomff.com + source ./.venv/bin/activate && python -m auth_backend user_group create --email test-admin@profcomff.com login-user: curl -X 'POST' 'http://localhost:8000/email/login' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"email": "test-user@profcomff.com", "password": "string"}' diff --git a/auth_backend/cli/process.py b/auth_backend/cli/process.py index bd157d0d..1c8357d7 100644 --- a/auth_backend/cli/process.py +++ b/auth_backend/cli/process.py @@ -40,14 +40,13 @@ def get_args(): scope_subparsers = scope.add_subparsers(dest='subcommand') scope_create = scope_subparsers.add_parser("create") scope_create.add_argument('--name', type=str, required=True) - scope_create.add_argument('--creator', type=str, required=True) + scope_create.add_argument('--creator_email', type=str, required=True) scope_create.add_argument('--comment', type=str, required=True) user_group = subparsers.add_parser("user_group") user_group_subparsers = user_group.add_subparsers(dest='subcommand') user_group_create = user_group_subparsers.add_parser("create") - user_group_create.add_argument('--user_id', type=str, required=True) - user_group_create.add_argument('--group_id', type=str, required=True) + user_group_create.add_argument('--email', type=str, required=True) return parser.parse_args() @@ -67,7 +66,7 @@ def process() -> None: create_group(args.name, args.scopes, args.parent, session) elif args.command == 'scope' and args.subcommand == 'create': print(f'Creating scope with params {args}') - create_scope(args.name, args.creator, args.comment, session) + create_scope(args.name, args.creator_email, args.comment, session) elif args.command == 'user_group' and args.subcommand == 'create': print(f'Creating user_group with params {args}') - create_user_group(args.user_id, args.group_id, session) + create_user_group(args.email, session) diff --git a/auth_backend/cli/scope.py b/auth_backend/cli/scope.py index 84490e96..48f295f7 100644 --- a/auth_backend/cli/scope.py +++ b/auth_backend/cli/scope.py @@ -2,13 +2,14 @@ from sqlalchemy.orm import Session -from auth_backend.models.db import Scope +from auth_backend.models.db import AuthMethod, Scope -def create_scope(name: str, creator_id: int, comment: str, session: Session) -> None: +def create_scope(name: str, creator_email: str, comment: str, session: Session) -> None: if Scope.query(session=session).filter(Scope.name == name).one_or_none(): print("Scope already exists") exit(errno.EIO) + creator_id = AuthMethod.query(session=session).filter(AuthMethod.auth_method == "email", AuthMethod.value == creator_email).one().user_id scope = Scope.create(name=name, creator_id=creator_id, comment=comment, session=session) session.commit() print(f"Created scope: {scope}") diff --git a/auth_backend/cli/user_group.py b/auth_backend/cli/user_group.py index a8f63064..756154ec 100644 --- a/auth_backend/cli/user_group.py +++ b/auth_backend/cli/user_group.py @@ -2,10 +2,12 @@ from sqlalchemy.orm import Session -from auth_backend.models.db import UserGroup +from auth_backend.models.db import AuthMethod, Group, UserGroup -def create_user_group(user_id: int, group_id: int, session: Session) -> None: +def create_user_group(email: str, session: Session) -> None: + user_id = AuthMethod.query(session=session).filter(AuthMethod.auth_method == "email", AuthMethod.value == email).one().user_id + group_id = Group.query(session=session).filter(Group.name == "root").one().id if ( UserGroup.query(session=session) .filter(UserGroup.user_id == user_id, UserGroup.group_id == group_id) From bd70d035e6dcf7b7374d7ebd9ef88139bb819397 Mon Sep 17 00:00:00 2001 From: Semyon Grigoriev Date: Tue, 23 Jul 2024 16:34:07 +0300 Subject: [PATCH 2/3] venv --- Makefile | 82 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/Makefile b/Makefile index 4e21100d..e754ba75 100644 --- a/Makefile +++ b/Makefile @@ -1,64 +1,64 @@ SHELL := /bin/bash run: - source ./.venv/bin/activate && uvicorn --reload --log-config logging_dev.conf auth_backend.routes.base:app + source ./venv/bin/activate && uvicorn --reload --log-config logging_dev.conf auth_backend.routes.base:app -configure: .venv - source ./.venv/bin/activate && pip install -r requirements.dev.txt -r requirements.txt +configure: venv + source ./venv/bin/activate && pip install -r requirements.dev.txt -r requirements.txt -.venv: - python3.11 -m .venv .venv +venv: + python3.11 -m venv venv format: - source ./.venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./auth_backend - source ./.venv/bin/activate && isort ./auth_backend - source ./.venv/bin/activate && black ./auth_backend - source ./.venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./tests - source ./.venv/bin/activate && isort ./tests - source ./.venv/bin/activate && black ./tests - source ./.venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./migrations - source ./.venv/bin/activate && isort ./migrations - source ./.venv/bin/activate && black ./migrations + source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./auth_backend + source ./venv/bin/activate && isort ./auth_backend + source ./venv/bin/activate && black ./auth_backend + source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./tests + source ./venv/bin/activate && isort ./tests + source ./venv/bin/activate && black ./tests + source ./venv/bin/activate && autoflake -r --in-place --remove-all-unused-imports ./migrations + source ./venv/bin/activate && isort ./migrations + source ./venv/bin/activate && black ./migrations db: docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-auth_api postgres:15 migrate: - source ./.venv/bin/activate && alembic upgrade head + source ./venv/bin/activate && alembic upgrade head test: - source ./.venv/bin/activate && python3 -m pytest --verbosity=2 --showlocals --log-level=DEBUG + source ./venv/bin/activate && python3 -m pytest --verbosity=2 --showlocals --log-level=DEBUG create-user: python -m auth_backend user create --email test-user@profcomff.com --password string create-admin: - source ./.venv/bin/activate && python -m auth_backend user create --email test-admin@profcomff.com --password string - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.group.create --comment auth.group.create --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.group.delete --comment auth.group.delete --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.group.read --comment auth.group.read --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.group.update --comment auth.group.update --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.scope.create --comment auth.scope.create --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.scope.delete --comment auth.scope.delete --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.scope.read --comment auth.scope.read --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.scope.update --comment auth.scope.update --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.user.delete --comment auth.user.delete --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.user.read --comment auth.user.read --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.user.update --comment auth.user.update --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.read --comment auth.airflow_outer_auth.link.read --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.create --comment auth.airflow_outer_auth.link.create --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.delete --comment auth.airflow_outer_auth.link.delete --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.read --comment auth.coder_outer_auth.link.read --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.create --comment auth.coder_outer_auth.link.create --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.delete --comment auth.coder_outer_auth.link.delete --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.read --comment auth.mailu_outer_auth.link.read --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.create --comment auth.mailu_outer_auth.link.create --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.delete --comment auth.mailu_outer_auth.link.delete --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.read --comment auth.postgres_outer_auth.link.read --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.create --comment auth.postgres_outer_auth.link.create --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.delete --comment auth.postgres_outer_auth.link.delete --creator_email test-admin@profcomff.com - source ./.venv/bin/activate && python -m auth_backend user_group create --email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend user create --email test-admin@profcomff.com --password string + source ./venv/bin/activate && python -m auth_backend scope create --name auth.group.create --comment auth.group.create --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.group.delete --comment auth.group.delete --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.group.read --comment auth.group.read --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.group.update --comment auth.group.update --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.scope.create --comment auth.scope.create --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.scope.delete --comment auth.scope.delete --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.scope.read --comment auth.scope.read --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.scope.update --comment auth.scope.update --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.user.delete --comment auth.user.delete --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.user.read --comment auth.user.read --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.user.update --comment auth.user.update --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.read --comment auth.airflow_outer_auth.link.read --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.create --comment auth.airflow_outer_auth.link.create --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.airflow_outer_auth.link.delete --comment auth.airflow_outer_auth.link.delete --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.read --comment auth.coder_outer_auth.link.read --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.create --comment auth.coder_outer_auth.link.create --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.coder_outer_auth.link.delete --comment auth.coder_outer_auth.link.delete --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.read --comment auth.mailu_outer_auth.link.read --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.create --comment auth.mailu_outer_auth.link.create --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.mailu_outer_auth.link.delete --comment auth.mailu_outer_auth.link.delete --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.read --comment auth.postgres_outer_auth.link.read --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.create --comment auth.postgres_outer_auth.link.create --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend scope create --name auth.postgres_outer_auth.link.delete --comment auth.postgres_outer_auth.link.delete --creator_email test-admin@profcomff.com + source ./venv/bin/activate && python -m auth_backend user_group create --email test-admin@profcomff.com login-user: curl -X 'POST' 'http://localhost:8000/email/login' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"email": "test-user@profcomff.com", "password": "string"}' From f0e0baa28c3c83f06471e647f41a4019406b70da Mon Sep 17 00:00:00 2001 From: Semyon Grigoriev Date: Tue, 23 Jul 2024 16:34:30 +0300 Subject: [PATCH 3/3] format --- auth_backend/cli/scope.py | 7 ++++++- auth_backend/cli/user_group.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/auth_backend/cli/scope.py b/auth_backend/cli/scope.py index 48f295f7..2629d435 100644 --- a/auth_backend/cli/scope.py +++ b/auth_backend/cli/scope.py @@ -9,7 +9,12 @@ def create_scope(name: str, creator_email: str, comment: str, session: Session) if Scope.query(session=session).filter(Scope.name == name).one_or_none(): print("Scope already exists") exit(errno.EIO) - creator_id = AuthMethod.query(session=session).filter(AuthMethod.auth_method == "email", AuthMethod.value == creator_email).one().user_id + creator_id = ( + AuthMethod.query(session=session) + .filter(AuthMethod.auth_method == "email", AuthMethod.value == creator_email) + .one() + .user_id + ) scope = Scope.create(name=name, creator_id=creator_id, comment=comment, session=session) session.commit() print(f"Created scope: {scope}") diff --git a/auth_backend/cli/user_group.py b/auth_backend/cli/user_group.py index 756154ec..5dbe2aec 100644 --- a/auth_backend/cli/user_group.py +++ b/auth_backend/cli/user_group.py @@ -6,7 +6,12 @@ def create_user_group(email: str, session: Session) -> None: - user_id = AuthMethod.query(session=session).filter(AuthMethod.auth_method == "email", AuthMethod.value == email).one().user_id + user_id = ( + AuthMethod.query(session=session) + .filter(AuthMethod.auth_method == "email", AuthMethod.value == email) + .one() + .user_id + ) group_id = Group.query(session=session).filter(Group.name == "root").one().id if ( UserGroup.query(session=session)