-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClaimsPrincipal
doesn't include identity when authType
is anonymous
#3857
Comments
@ConnorMcMahon would it be ok to assign this to the current sprint? I'll have it in Triage for now |
Sounds good. |
@fabiocav and @ConnorMcMahon is this still on the backlog to be addressed in the current sprint? I ask because i'm working on functions app solution for a customer and have an end of week milestone to deliver. Trying to determine if i'll be able to get away with not having to implement and document inclusion of function ?code=<function code> in addition to oauth Authorization header security. Should I just watch for an azure functions runtime update from the current Have you folks decided on whether or not the fix for this will involving moving to |
I have a PR that addresses this issue (#3904). @myusrn, we are planning on future integrations with EasyAuth, but we are still deciding whether we want to utilize the AuthorizationLevel.User field, or whether we want to do a more robust configuration that would allow users to do similar things to the Authorize attribute within the function.json/HttpTriggerAttribute. |
Hi there, I have defined my own roles in AAD and I can see that in the bearer token received by the http trigger (in the req param) is populated with the roles my predefined roles.
Found 1 identities. Any idea where the missing link is? |
@maryammadzadeh I would check . . .
|
@ConnorMcMahon with the fix in place do we . . .
|
|
I see this fix went out with: https://github.com/Azure/azure-functions-host/releases/tag/v2.0.12309 However, I am still experiencing this issue. My function app's runtime is 2.0.12332.0. Is it expected that this issue should not occur on this runtime running in Azure? |
@matt-dib, I just tested against my app running on 2.0.12332, and it appears to be working. Can you share your function name and application name with me? If you want to share your app name without giving it publicly, you can share this information instead. |
@ConnorMcMahon |
@matt-dib From what I can tell everything looks good configwise on your site. Can you check that inside of your function the HTTP request has the header X-MS-CLIENT-PRINCIPAL? |
I checked inside the function and the X-MS-CLIENT-PRINCIPAL is present on the HttpRequest object. After base64 decode on the value the claims do exist in the header value. However, the System.Security.Claims.ClaimsPrincipal.Current is still null. I did a little bit more experimentation as well to rule out any other potential influences.
By no change, what I mean is System.Security.Claims.ClaimsPrincipal.Current is always null. |
@matt-dib an additional thing to confirm is that the token being providing in api calls has the audience "aud" claim set to <application (client) id>/user_impersonation and not the function app's azure ad | <application> | expose an api | scope displayed value of api://<application (client) id>/user_impersonation. In application code this was achieved by setting the microsoft authentication library [msal] scopes parameter to just <application (client) id>/user_impersonation vs api://<application (client) id>/user_impersonation. |
@matt-dib, we don't actually populate Instead, we support passing in the You can see our documentation on the feature here. |
@ConnorMcMahon That was indeed the issue. Thanks so much. |
Investigative information
Please provide the following:
Repro steps
Provide the steps required to reproduce the problem:
ClaimsPrincipal
parameter.ClaimsPrincipal
.authLevel
toanonymous
, instead of using a function key.Expected behavior
The
ClaimsPrincipal.Identities
property should be populated with the Azure AD identity, and all claims.Actual behavior
The
ClaimsPrincipal.Identities
property does not include the Azure AD identity whenauthLevel
is set toanonymous
.Known workarounds
Change the function's
authLevel
to a different value.Related information
Example function code:
Example
function.json
:(Also note the documentation says that
you should set the HTTP-triggered function authentication level to anonymous
when using AAD authentication.)The text was updated successfully, but these errors were encountered: