What is "X-Require-Whisk-Auth" (IBM Cloud Functions) in IBM Cloud Code Engine functions?

22 Views Asked by At

I have some IBM Cloud Functions secured web actions that I want to migrate to IBM Cloud Code Engine functions. The web action is using "X-Require-Whisk-Auth". What would be the equivalent in Code Engine? How can I implement that?

1

There are 1 best solutions below

1
data_henrik On BEST ANSWER

Using __ce_headers in the parameters passed to your Code Engine function, you have access to all headers and their values which were part of the functions request. This includes the "Authorization" header (if used) or "X-Require-Whisk-Auth" if simulating Cloud Functions behavior.

The following Python code snippet shows how to obtain the value for that header.

def main(params):
    auth=""
    # check for "X-Require-Whisk-Auth" header
    if "X-Require-Whisk-Auth" in params["__ce_headers"]:
        auth=params["__ce_headers"]["X-Require-Whisk-Auth"]
        # perform next steps