久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用 Azure 身份驗證在 Azure Function 中獲取當前

How to get current user identity in Azure Function with Azure Authentication?(如何使用 Azure 身份驗證在 Azure Function 中獲取當前用戶身份?)
本文介紹了如何使用 Azure 身份驗證在 Azure Function 中獲取當前用戶身份?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我創建了一個新的函數應用,為它啟用了應用服務身份驗證/授權(使用身份驗證/授權來保護您的應用程序并使用每個用戶的數據")并禁用非身份驗證請求.

I have created a new Function App, enabled App Service Authentication / Authorization for it ("Use Authentication / Authorization to protect your application and work with per-user data") and disabled non-authenticated requests.

到目前為止,一切似乎都運行正常.如果我嘗試請求我的 HttpTriggered 函數,它需要我先登錄;登錄后,所有請求都會按原樣處理.所以保護您的應用程序"部分沒有問題.

Everything seems to be working correctly so far. If I try to request my HttpTriggered function, it requires me to log in first; once I'm logged in, all requests are processed as they should be. So there is no problem with "protect your application" part.

但是,我完全被處理每個用戶的數據"部分所困擾.我的 Azure 函數被調用為

However, I'm totally stuck with the "work with per-user data" part. My Azure Function is invoked as

public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)

HttpRequestMessage 中沒有與身份驗證相關的內容.(AuthorizationLevel.Anonymous 似乎控制著完全不同的事情——即,函數是否可以由任何人調用,或者只能由具有固定 API 密鑰的人調用).

And there is nothing related to authentication in HttpRequestMessage. (AuthorizationLevel.Anonymous seems to control the entirely different thing - namely, if the function could be called by anyone or only by those who have a fixed API key).

如何獲取調用該函數的經過身份驗證的用戶的身份?

How do I get the identity of authenticated user who called the function?

推薦答案

使用 Azure Function runtime v2.0.12309,你可以檢索 來自 Run 方法中注入的 "noreferrer">ClaimsPrincipal 實例:

Using the Azure Function runtime v2.0.12309, you can retrieve the authenticated user information from the ClaimsPrincipal instance injected in the Run method:

public static async Task<HttpResponseMessage> Run(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]
    HttpRequest httpRequest, 
    ILogger logger, 
    ClaimsPrincipal claimsPrincipal)
 {
            // Explores the authenticated user's claims in claimsPrincipal.
 }

這篇關于如何使用 Azure 身份驗證在 Azure Function 中獲取當前用戶身份?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 久久久久久久久久久爱 | 久久九九99 | 亚洲中字在线 | 亚洲精品视频在线看 | 国产精品中文字幕在线 | 成人蜜桃av| 午夜欧美一区二区三区在线播放 | 欧美亚洲激情 | av片免费 | www视频在线观看 | 五月综合激情在线 | 国产精品无码专区在线观看 | www.青青草| 99热这里有精品 | 亚洲a级 | 欧美久久天堂 | 欧美中文字幕一区二区三区亚洲 | 久久激情五月丁香伊人 | 9久9久9久女女女九九九一九 | 色综合久久88色综合天天 | 国产精品久久久亚洲 | 91精品国产综合久久久密闭 | 国产精品久久一区二区三区 | 成人av一区| 欧美福利久久 | 欧美日韩国产综合在线 | 亚洲福利av | 黄色国产大片 | 成人久久久久 | 色片在线观看 | 精品91av| 日韩www视频| 一区二区三区欧美 | 成人在线视频免费观看 | 国产精品欧美精品日韩精品 | 成人av一区 | 免费黄色在线观看 | www亚洲精品| 免费观看色 | 久草视频在线播放 | 在线国产一区 |