Skip to content

Commit

Permalink
fixing types
Browse files Browse the repository at this point in the history
  • Loading branch information
witlox committed Nov 1, 2024
1 parent dee3a57 commit 44aa7b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
10 changes: 7 additions & 3 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
DEBUG=False
UI=False
UI=True#change-me
CORS=*
CLOCK_OFFSET=0.0
PLANNING_WINDOW=31
PLANNING_INTERVAL=1
REDIS_URL=redis://redis:6379/0
OLTP_INSECURE=True
OLTP_INSECURE=True#change-me
OLTP_COLLECTOR_URL=http://collector:4317
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS=".*session.*,set-cookie"
OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS=".*session.*,set-cookie"
PEER_KEY=c3daXP0DDO#change-me
PEER_SECRET=4xST4WqrLF6LjE55vyWeaP2w#change-me
PEER_SALT=98fc47e49cb666023f438cbd6582af65#change-me
PEERS=server1,server2,server3#change-me
11 changes: 7 additions & 4 deletions horao/auth/peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import binascii
import logging
import os
from typing import Tuple

from cryptography.fernet import Fernet
from cryptography.hazmat.primitives import hashes
Expand Down Expand Up @@ -70,18 +71,20 @@ def generate_digest(username: str, password: str, secret: str, salt: bytes) -> b
return encode(f"{username}{password}", secret, salt)


def extract_username_password(token: bytes, secret: str, salt: bytes) -> (str, str):
def extract_username_password(
token: bytes, secret: str, salt: bytes
) -> Tuple[str, str]:
"""
This function returns the username and password from the token
:param token: token
:param secret: secret
:param salt: salt
:return: typle of username and password
"""
token = decode(token, secret, salt)
result = decode(token, secret, salt)
return (
token[0 : len(token) - len(os.getenv("PEER_KEY"))],
token[len(token) - len(os.getenv("PEER_KEY")) :],
result[0 : len(result) - len(os.getenv("PEER_KEY"))], # type: ignore
result[len(result) - len(os.getenv("PEER_KEY")) :], # type: ignore
)


Expand Down

0 comments on commit 44aa7b9

Please sign in to comment.