[英]Redirect URL does not match on azure
我正在構建一個 django 應用程序,該應用程序托管在 azure web 應用程序服務上。 我使用 azure 廣告進行身份驗證並支持我使用 python 的 MSAL 庫。
在本地主機上,我已經能夠使用 azure 登錄並查看站點數據,但是當應用程序部署到 azure web 應用程序時無法訪問該站點。 我收到以下錯誤。
我已經使用 HTTP://localhos:8000/auth/redirect 作為重定向 uri,並將其用於部署到 azure web 應用程序的應用程序:https://.azurewebsites.net/auth/redirect 但它不起作用並顯示以下內容上面的錯誤。
我正在使用https://github.com/Azure-Samples/ms-identity-python-django-tutorial/tree/main/1-Authentication提供的以下代碼。
我不知道是什么問題。 請幫忙。
編輯:
我無法獲得解決方案,我已將相同的重定向 URL 添加到 azure 以及代碼中。
https://appname.azurewebsites.net/auth/redirect
這是關於我如何在內部代碼中配置重定向 URL 的代碼:這是 aad.config.json 文件:
{
"type": {
"client_type": "CONFIDENTIAL",
"authority_type": "SINGLE_TENANT",
"framework": "DJANGO"
},
"client": {
"client_id": "**",
"client_credential": "*",
"authority": "https://login.microsoftonline.com/*"
},
"auth_request": {
"redirect_uri": null,
"scopes": [],
"response_type": "code"
},
"flask": null,
"django": {
"id_web_configs": "MS_ID_WEB_CONFIGS",
"auth_endpoints": {
"prefix": "auth",
"sign_in": "sign_in",
"edit_profile": "edit_profile",
"redirect": "redirect",
"sign_out": "sign_out",
"post_sign_out": "post_sign_out"
}
}
}
this is the context_processors.py file:
Python
from django.urls import reverse
from django.conf import settings
def context(request):
claims = request.identity_context_data._id_token_claims
exclude_claims = ['iat', 'exp', 'nbf', 'uti', 'aio', 'rh']
claims_to_display = {claim: value for claim, value in claims.items() if claim not in exclude_claims}
client_id=settings.AAD_CONFIG.client.client_id
aad_link="https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/Authentication/appId/" + client_id +"/isMSAApp/"
return dict(claims_to_display=claims_to_display,
redirect_uri_external_link = request.build_absolute_uri(reverse(settings.AAD_CONFIG.django.auth_endpoints.redirect)),
aad_link=aad_link)
AADSTS50011 - 請求中指定的回復 URL 與為應用程序配置的回復 URL 不匹配
原因:當Azure portal
中定義的回復 URL 與應用程序提供給Azure AD
的回復 URL不匹配時,通常會發生此錯誤。
Azure AD 僅接受已在 Azure 門戶中定義的已保存回復 URL 。
解決:
要解決此錯誤,請檢查(解碼)登錄時出現錯誤的web 地址。為此,復制該 Microsoft 登錄頁面的 URL 並將其粘貼到記事本中。 觀察重定向 URI 並基於此,確保在code
和Azure portal
注冊 URI 中添加該重定向 URI。
Go to Azure Portal -> Azure AD -> App Registrations -> Your App -> Authentication -> Add a platform -> Web
檢查您是否有這樣的重定向 URI -> https://yourappname.azurewebsites.net/signin-oidc
用於已部署的 azure web 應用程序。
有關詳細信息,請通過以下參考資料撥打 go(如果它們有幫助)。
參考:
如何通過 django-microsoft-auth 在 Django 中使用 Azure AD 進行身份驗證
https://learn.microsoft.com/en-us/azure/active-directory/develop/reply-url
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.