I have been looking at the official Authenticating to Azure AD in daemon apps with certificates sample for Azure Active Directory on GitHub. The Web API service seems to have no knowledge of the client whatsoever.
- You are not told to log into Azure and add permission for the daemon client to access the Web API using the "Permissions to other applications" section.
- The Web API controller actions don't check the claims of the caller to ensure that it is the client app. It does have this code though which I don't entirely understand:
public IEnumerable Get() { // // The Scope claim tells you what permissions the client application has in the service. // In this case we look for a scope value of user_impersonation, or full access to the service as the user. // Claim scopeClaim = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/scope"); if (scopeClaim != null) { if (scopeClaim.Value != "user_impersonation") { throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.Unauthorized, ReasonPhrase = "The Scope claim does not contain 'user_impersonation' or scope claim not found" }); } } // A user's To Do list is keyed off of the NameIdentifier claim, which contains an immutable, unique identifier for the user. Claim subject = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier); return from todo in todoBag where todo.Owner == subject.Value select todo; }
Am I correct in thinking that any client registered with my Azure AD can access the Web API, with the way this sample is setup.