Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebou12 authored Apr 19, 2024
1 parent cff56e1 commit a0c272b
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@


from dataclasses import dataclass
from typing import List, Optional

from pydantic import BaseModel

class DeviceBind(BaseModel):
Expand Down Expand Up @@ -1012,17 +1010,13 @@ class ClientSSLError(Exception):
from starlette.status import HTTP_401_UNAUTHORIZED, HTTP_404_NOT_FOUND
from datetime import datetime
import hashlib
import os
from Crypto.PublicKey import RSA
from Crypto.Signature import pkcs1_15
from Crypto.Hash import SHA256
from Crypto.Cipher import PKCS1_OAEP
import binascii
from base64 import b64encode, b64decode

from pydantic import BaseModel
from typing import Optional

security_basic = HTTPBasic()
API_KEY_NAME = "access_token"
api_key_header = APIKeyHeader(name=API_KEY_NAME, auto_error=False)
Expand Down Expand Up @@ -1154,17 +1148,6 @@ def generate_key(request: Request, email: str, password: str, renpho: RenphoWeig
except Exception as e:
return APIResponse(status="error", message="Failed to generate API key.", data=str(e))

@app.get("/decrypt_api_key", response_model=dict)
def decrypt_key(api_key: str = Depends(api_key_header)):
"""
Decrypts an API key to extract the email and password.
This endpoint should be secured and limited to administrative use.
"""
if not api_key or not verify_api_key(api_key):
raise HTTPException(status_code=403, detail="Invalid or missing API key")

return decrypt_api_key(api_key)

@app.get("/info", response_model=APIResponse)
async def get_info(renpho: RenphoWeight = Depends(get_current_user)):
try:
Expand Down

0 comments on commit a0c272b

Please sign in to comment.