Skip to content

Commit 251ac26

Browse files
committed
lint
1 parent d7defba commit 251ac26

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1+
import base64
2+
from hashlib import sha256
13
from typing import Annotated
4+
25
from fastapi import Header, HTTPException
3-
from hashlib import sha256
4-
import base64
56
from fastapp.core.config import settings
67

7-
async def verify_health_auth_header(x_ms_auth_internal_token: Annotated[str, Header()]) -> bool:
8+
9+
async def verify_health_auth_header(
10+
x_ms_auth_internal_token: Annotated[str, Header()]
11+
) -> bool:
812
"""Returns true if SHA256 of header_value matches WEBSITE_AUTH_ENCRYPTION_KEY.
9-
13+
1014
x_ms_auth_internal_token: Value of the x-ms-auth-internal-token header.
1115
RETURNS (bool): Specifies whether the header matches.
1216
"""
1317
website_auth_encryption_key = settings.WEBSITE_AUTH_ENCRYPTION_KEY
14-
hash = base64.b64encode(sha256(website_auth_encryption_key.encode('utf-8')).digest()).decode('utf-8')
18+
hash = base64.b64encode(
19+
sha256(website_auth_encryption_key.encode("utf-8")).digest()
20+
).decode("utf-8")
1521
if hash != x_ms_auth_internal_token:
16-
raise HTTPException(status_code=400, detail="x-ms-auth-internal-token is invalid")
22+
raise HTTPException(
23+
status_code=400, detail="x-ms-auth-internal-token is invalid"
24+
)
1725
else:
1826
return True

0 commit comments

Comments
 (0)