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?
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