From c8ede06c263df5eee780ebd7ca8b3b1583581c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Wed, 16 Mar 2022 14:16:56 +0000 Subject: [PATCH] cryptContext source --- api/kiwi_vpn_api/routers/install.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/kiwi_vpn_api/routers/install.py b/api/kiwi_vpn_api/routers/install.py index 184b025..f6b9678 100644 --- a/api/kiwi_vpn_api/routers/install.py +++ b/api/kiwi_vpn_api/routers/install.py @@ -5,7 +5,7 @@ from secrets import token_hex from fastapi import APIRouter, Depends, HTTPException, status from peewee import Database -from ..config import CRYPT_CONTEXT, BaseConfig +from ..config import BaseConfig from ..db import Certificate, DistinguishedName, User, UserCapability router = APIRouter(prefix="/install") @@ -109,6 +109,7 @@ async def check_db( async def create_db( admin_name: str, admin_password: str, + config: BaseConfig = Depends(load_config), db: Database = Depends(connect_db), ): if await has_tables(db): @@ -116,8 +117,9 @@ async def create_db( db.create_tables([Certificate, DistinguishedName, User, UserCapability]) + cryptContext = await config.crypto.cryptContext admin = User.create( name=admin_name, - password=CRYPT_CONTEXT.hash(admin_password), + password=cryptContext.hash(admin_password), ) UserCapability.create(user=admin, capability="admin")