|
|
@ -63,7 +63,7 @@ class UserOut(BaseModel):
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
def from_orm(cls: t.Type["UserOut"], obj: User) -> "UserOut":
|
|
|
|
def from_orm(cls: t.Type["UserOut"], obj: User) -> "UserOut":
|
|
|
|
return cls(pubkey=obj.userinfo.pubkey, encryptedContent=obj.userinfo.encryptedContent)
|
|
|
|
return cls(pubkey=bytes(obj.userinfo.pubkey), encryptedContent=bytes(obj.userinfo.encryptedContent))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LoginOut(BaseModel):
|
|
|
|
class LoginOut(BaseModel):
|
|
|
@ -228,14 +228,15 @@ async def is_etebase():
|
|
|
|
|
|
|
|
|
|
|
|
@authentication_router.post("/login_challenge/", response_model=LoginChallengeOut)
|
|
|
|
@authentication_router.post("/login_challenge/", response_model=LoginChallengeOut)
|
|
|
|
async def login_challenge(user: User = Depends(get_login_user)):
|
|
|
|
async def login_challenge(user: User = Depends(get_login_user)):
|
|
|
|
enc_key = get_encryption_key(user.userinfo.salt)
|
|
|
|
salt = bytes(user.userinfo.salt)
|
|
|
|
|
|
|
|
enc_key = get_encryption_key(salt)
|
|
|
|
box = nacl.secret.SecretBox(enc_key)
|
|
|
|
box = nacl.secret.SecretBox(enc_key)
|
|
|
|
challenge_data = {
|
|
|
|
challenge_data = {
|
|
|
|
"timestamp": int(datetime.now().timestamp()),
|
|
|
|
"timestamp": int(datetime.now().timestamp()),
|
|
|
|
"userId": user.id,
|
|
|
|
"userId": user.id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
challenge = bytes(box.encrypt(msgpack_encode(challenge_data), encoder=nacl.encoding.RawEncoder))
|
|
|
|
challenge = bytes(box.encrypt(msgpack_encode(challenge_data), encoder=nacl.encoding.RawEncoder))
|
|
|
|
return LoginChallengeOut(salt=user.userinfo.salt, challenge=challenge, version=user.userinfo.version)
|
|
|
|
return LoginChallengeOut(salt=salt, challenge=challenge, version=user.userinfo.version)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@authentication_router.post("/login/", response_model=LoginOut)
|
|
|
|
@authentication_router.post("/login/", response_model=LoginOut)
|
|
|
|