File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
code/function/fastapp/health Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 1+ import base64
2+ from hashlib import sha256
13from typing import Annotated
4+
25from fastapi import Header , HTTPException
3- from hashlib import sha256
4- import base64
56from 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
You can’t perform that action at this time.
0 commit comments