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
1
3
from typing import Annotated
4
+
2
5
from fastapi import Header , HTTPException
3
- from hashlib import sha256
4
- import base64
5
6
from fastapp .core .config import settings
6
7
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 :
8
12
"""Returns true if SHA256 of header_value matches WEBSITE_AUTH_ENCRYPTION_KEY.
9
-
13
+
10
14
x_ms_auth_internal_token: Value of the x-ms-auth-internal-token header.
11
15
RETURNS (bool): Specifies whether the header matches.
12
16
"""
13
17
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" )
15
21
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
+ )
17
25
else :
18
26
return True
You can’t perform that action at this time.
0 commit comments