語言

RequiredScopeAttribute 類別

定義

此屬性用於控制器、頁面或控制器動作,用以宣告(並驗證)網頁 API 所需的作用範圍。 這些作用域可以透過兩種方式宣告:硬編碼,或在配置中宣告。 根據你的選擇,使用其中一種建造器。 如需詳細資訊,請參閱 https://aka.ms/ms-id-web/required-scope-attribute。

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method)]
public class RequiredScopeAttribute : Attribute, Microsoft.Identity.Web.IAuthRequiredScopeMetadata
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method)>]
type RequiredScopeAttribute = class
    inherit Attribute
    interface IAuthRequiredScopeMetadata
Public Class RequiredScopeAttribute
Inherits Attribute
Implements IAuthRequiredScopeMetadata
繼承
RequiredScopeAttribute
屬性
實作

建構函式

名稱 Description
RequiredScopeAttribute()

預設建構函式。

RequiredScopeAttribute(String[])

驗證網頁 API 是否以正確的範圍呼叫。 若該 API 所取得的權杖代表已認證使用者,且其作用域主張中沒有這些 acceptedScopes ,該方法會更新 HTTP 回應,提供狀態碼 403(禁止),並寫入訊息給回應主體,告知該令牌預期包含哪些範圍。

屬性

名稱 Description
AcceptedScope

此網頁 API 允許的範圍。

IsReusable

未使用:與授權過濾器介面相容性。

RequiredScopesConfigurationKey

包含所需作用域的配置鍵的完全限定名稱(以空格分隔)。

適用於