Language

RequiredScopeOrAppPermissionAttribute Class

Definition

This attribute is used on a controller, pages, or controller actions to declare (and validate) the scopes or app permissions required by a web API. Authorization succeeds when an accepted scope is present in a scope claim or an accepted app permission is present in a role claim. Matching a role does not classify the token as app-only. These scopes or app permissions can be declared in two ways: hardcoding them, or declaring them in the configuration. Depending on your choice, use either one or the other of the constructors. For details, see https://aka.ms/ms-id-web/required-scope-or-app-permissions-attribute.

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method)]
public class RequiredScopeOrAppPermissionAttribute : Attribute, Microsoft.Identity.Web.IAuthRequiredScopeOrAppPermissionMetadata
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method)>]
type RequiredScopeOrAppPermissionAttribute = class
    inherit Attribute
    interface IAuthRequiredScopeOrAppPermissionMetadata
Public Class RequiredScopeOrAppPermissionAttribute
Inherits Attribute
Implements IAuthRequiredScopeOrAppPermissionMetadata
Inheritance
RequiredScopeOrAppPermissionAttribute
Attributes
Implements

Constructors

Name Description
RequiredScopeOrAppPermissionAttribute()

Default constructor.

RequiredScopeOrAppPermissionAttribute(String[], String[])

Declares the scopes and app permissions accepted by this web API. Authorization succeeds when the token has any of these acceptedScopes in its scope claims or any of these acceptedAppPermissions in its role claims.

Properties

Name Description
AcceptedAppPermission

App permissions accepted by this web API. App permissions appear in role claims. A matching role does not classify the token as app-only.

AcceptedScope

Scopes accepted by this web API.

RequiredAppPermissionsConfigurationKey

Fully qualified name of the configuration key containing the required app permissions (separated by spaces).

RequiredScopesConfigurationKey

Fully qualified name of the configuration key containing the required scopes (separated by spaces).

Applies to