語言

ScopesRequiredHttpContextExtensions.VerifyUserHasAnyAcceptedScope 方法

定義

當應用於 HttpContext時,會驗證在網頁 API 中驗證的使用者是否擁有任何可接受的範圍。 如果沒有認證使用者,回應是 401(未認證)。 若已認證的使用者不具備上述任何這些, acceptedScopes方法會更新 HTTP 回應,提供狀態碼 403(禁止),並寫入回應實體,告知該標記中預期的範圍。 我們建議改用控制器、頁面或動作上的 RequiredScope 屬性。 參見 https://aka.ms/ms-id-web/required-scope-attribute。

public static void VerifyUserHasAnyAcceptedScope(this Microsoft.AspNetCore.Http.HttpContext context, params string[] acceptedScopes);
static member VerifyUserHasAnyAcceptedScope : Microsoft.AspNetCore.Http.HttpContext * string[] -> unit
<Extension()>
Public Sub VerifyUserHasAnyAcceptedScope (context As HttpContext, ParamArray acceptedScopes As String())

參數

context
HttpContext

HttpContext(來自控制器)。

acceptedScopes
String[]

此網頁 API 允許的範圍。

適用於