Skip to content

Commit 457da40

Browse files
committed
Incorporated OIDC for authenticating towards Azure in GH Action
1 parent 60498f1 commit 457da40

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hvalfangst_function/function_app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import logging
3+
import os
34
from io import StringIO
45

56
import azure.functions as func
@@ -72,13 +73,13 @@ def validate_jwt(token: str, audience: str) -> bool:
7273
return False
7374

7475

75-
@app.route(route="upload_csv", auth_level=func.AuthLevel.FUNCTION)
76+
@app.route(route="upload_csv", auth_level=func.AuthLevel.ANONYMOUS)
7677
@app.blob_output(arg_name="outbound", path="hvalfangstcontainer/in/input.csv", connection="AzureWebJobsStorage")
7778
def upload_csv(req: func.HttpRequest, outbound: func.Out[str]) -> str:
7879
try:
7980

8081
token = req.headers.get("Authorization").split(" ")[1] # Extract Bearer token
81-
if not validate_jwt(token, audience="61b4a548-3979-48df-b2df-37dc4e5e0e02"):
82+
if not validate_jwt(token, audience=os.environ.get("FUNCTION_APP_CLIENT_ID")):
8283
return func.HttpResponse("Unauthorized", status_code=401)
8384

8485
logging.info("Received HTTP request to upload CSV")

0 commit comments

Comments
 (0)