Skip to content

Commit 80c8ff6

Browse files
committed
adressing PR feedback (hpsin)
1 parent a784211 commit 80c8ff6

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

articles/active-directory/develop/scenario-protected-web-api-verification-scope-app-roles.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ private void ValidateAppRole(string appRole)
132132
// The `role` claim tells you what permissions the client application has in the service.
133133
// In this case we look for a `role` value of `access_as_application`
134134
//
135-
136-
if (!isAppOnlyToken)
137-
{
138-
}
139135
Claim roleClaim = ClaimsPrincipal.Current.FindFirst("roles");
140136
if (roleClaim == null || !roleClaim.Value.Split(' ').Contains(appRole))
141137
{
@@ -152,7 +148,7 @@ This sample code is for ASP.NET. For ASP.NET Core, just replace `ClaimsPrincipal
152148

153149
### Accepting app only tokens if the Web API should only be called by daemon apps
154150

155-
The `roles` claim is also used for users in user assignment patterns (See [How to: Add app roles in your application and receive them in the token](howto-add-app-roles-in-azure-ad-apps.md)). So just checking roles will allow apps to sign in as users and the other way around.
151+
The `roles` claim is also used for users in user assignment patterns (See [How to: Add app roles in your application and receive them in the token](howto-add-app-roles-in-azure-ad-apps.md)). So just checking roles will allow apps to sign in as users and the other way around, if the roles are assignable to both. We recommend having different roles declared for users and apps to prevent this confusion.
156152

157153
If you want to only allow daemon applications to call your Web API, you'll want to add a condition, when you validate the app role, that the token is an app-only token:
158154

@@ -162,7 +158,7 @@ string sub = ClaimsPrincipal.Current.FindFirst("sub");
162158
bool isAppOnlyToken = oid == sub;
163159
```
164160

165-
Of course checking the inverse condition will allow only app that sign-in a user to call your API.
161+
Checking the inverse condition will allow only apps that sign in a user, to call your API.
166162

167163
## Next steps
168164

0 commit comments

Comments
 (0)