INNER CODE UNIT · Python

handle

openfaas/workshop · hmac-protected/hmac-protected/handler.py:19

def handle(req):
    # We receive the hashed message in form of a header
    receivedHMAC = os.getenv("Http_Hmac")

    # Read secret from inside the container
    with open("/var/openfaas/secrets/payload-secret","r") as secretContent:
        payloadKey = secretContent.read()

    # Function to validate the HMAC
    if validateHMAC(req, payloadKey, receivedHMAC):
        return "Successfully validated: " + req
    return "HMAC validation failed."

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…