BUG555: Chacha20アルゴリズムで暗号化。注:このコミットは全員の開発環境に存在する必要があります。その後、/#/domainページにアクセスし、暗号化されていないアカウントの「編集」をクリックして直接保存し、暗号化されていないアカウントを暗号化します。

This commit is contained in:
Mouriya
2024-08-02 09:30:12 +09:00
parent 24fca834e0
commit 48f2c4a2d1
4 changed files with 49 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ from sqlalchemy import and_
import typing as t
from . import models, schemas
from app.core.security import get_password_hash
from app.core.security import chacha20Decrypt, get_password_hash
def get_user(db: Session, user_id: int):
@@ -184,6 +184,7 @@ def get_flows_by_app(db: Session, domainid: int, appid: str):
return flows
def create_domain(db: Session, domain: schemas.DomainBase):
domain.encrypt_kintonepwd()
db_domain = models.Domain(
tenantid = domain.tenantid,
name=domain.name,
@@ -208,6 +209,7 @@ def delete_domain(db: Session,id: int):
def edit_domain(
db: Session, domain: schemas.DomainBase
) -> schemas.Domain:
domain.encrypt_kintonepwd()
db_domain = db.query(models.Domain).get(domain.id)
if not db_domain:
raise HTTPException(status.HTTP_404_NOT_FOUND, detail="Domain not found")
@@ -264,12 +266,19 @@ def get_domain(db: Session, userid: str):
domains = db.query(models.Domain).join(models.UserDomain,models.UserDomain.domainid == models.Domain.id ).filter(models.UserDomain.userid == userid).all()
if not domains:
raise HTTPException(status_code=404, detail="Data not found")
for domain in domains:
decrypted_pwd = chacha20Decrypt(domain.kintonepwd)
domain.kintonepwd = decrypted_pwd
return domains
def get_domains(db: Session,tenantid:str):
domains = db.query(models.Domain).filter(models.Domain.tenantid == tenantid ).all()
if not domains:
raise HTTPException(status_code=404, detail="Data not found")
for domain in domains:
decrypted_pwd = chacha20Decrypt(domain.kintonepwd)
domain.kintonepwd = decrypted_pwd
return domains
def get_events(db: Session):

View File

@@ -2,6 +2,7 @@ from pydantic import BaseModel
from datetime import datetime
import typing as t
from app.core.security import chacha20Decrypt, chacha20Encrypt
class Base(BaseModel):
create_time: datetime
@@ -119,6 +120,10 @@ class DomainBase(BaseModel):
kintoneuser: str
kintonepwd: str
def encrypt_kintonepwd(self):
encrypted_pwd = chacha20Encrypt(self.kintonepwd)
self.kintonepwd = encrypted_pwd
class Domain(Base):
id: int
tenantid: str