You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/active-directory/develop/scenario-protected-web-api-verification-scope-app-roles.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,7 +153,10 @@ You can also verify the scopes for the whole controller
153
153
154
154
##### Verify the scopes on a controller with hardcoded scopes
155
155
156
-
The following code snippet shows the usage of the `[RequiredScope]` attribute with hardcoded scopes on the controller.
156
+
The following code snippet shows the usage of the `[RequiredScope]` attribute with hardcoded scopes on the controller. To use the RequiredScopeAttribute, you'll need to either:
157
+
158
+
- Use `AddMicrosoftIdentitWebApi` in the Startup.cs, as seen in [Code configuration](scenario-protected-web-api-app-configuration.md)
159
+
- or otherwise add the `ScopeAuthorizationRequirement` to the authorization policies as explained in [authorization policies](https://github.com/AzureAD/microsoft-identity-web/wiki/authorization-policies).
For a full version of `ValidateScopes` for ASP.NET Core, [_ScopesRequiredHttpContextExtensions.cs_](https://github.com/AzureAD/microsoft-identity-web/blob/master/src/Microsoft.Identity.Web/Resource/ScopesRequiredHttpContextExtensions.cs)
251
254
252
255
---
253
-
254
256
## Verify app roles in APIs called by daemon apps
255
257
256
258
If your web API is called by a [daemon app](scenario-daemon-overview.md), that app should require an application permission to your web API. As shown in [Exposing application permissions (app roles)](./scenario-protected-web-api-app-registration.md#expose-application-permissions-app-roles), your API exposes such permissions. One example is the `access_as_application` app role.
@@ -274,7 +276,6 @@ public class TodoListController : ApiController
274
276
}
275
277
```
276
278
277
-
278
279
Instead, you can use the [Authorize(Roles = "access_as_application")] attributes on the controller or an action (or a razor page).
For a full version of `ValidateAppRole` for ASP.NETCore, see [_RolesRequiredHttpContextExtensions.cs_](https://github.com/AzureAD/microsoft-identity-web/blob/master/src/Microsoft.Identity.Web/Resource/RolesRequiredHttpContextExtensions.cs) code.
328
329
329
330
---
330
-
331
331
### Verify app roles in APIs called on behalf of users
0 commit comments