When a function key is used to perform authentication, we should surface information about that key to the function code (level, source, name).
We might consider making this available via built in binding data in HttpTrigger. Just have to be sure we don't conflict with any user defined binding data coming from the request.
public static HttpResponseMessage Run(HttpRequestMessage req, string keyId)
The other approach I had in mind, is to set a request principal with that information. This would align well with some of the work we need to do in order to expose Easy Auth information to functions as well. That information would be appropriately exposed to Node and scripting functions.
This came up again on this SO question here.
Like @fabiocav proposed having a request principal set with the Key name would be great.
Developpers are used to look at principal for identity and it would avoid having an extra parameter in the Run function.
Any information on this working? I'm looking to add a log of which key was used to invoke the function.
Thanks!
@slawlor, this has been exposed! :)
If you bind to a ClaimsPrincipal, you'll have a principal passed into your function with claims based on the key used.
You can see an example here:
https://github.com/Azure/azure-functions-host/blob/cac35cbab96e94fff1c780cfc7e02990993c5185/sample/CSharp/HttpTrigger-Identities/run.csx#L27-L30
/cc @ConnorMcMahon if any additional information is needed.
Closing as resolved 馃帀
This is awesome! Thanks so much :)
Most helpful comment
This came up again on this SO question here.