簡體   English   中英

Angular應用程序和Spring Boot與Azure AD的集成

[英]Integration of Angular Application and Spring Boot with Azure AD

我正在使用角度啟動和彈簧啟動來構建應用程序。 我需要從前端將Azure AD用於SSO,然后使用令牌保護Spring Boot服務。 (簡而言之,我的angular將與office 365連接以登錄,然后用戶將通過spring security對連接進行身份驗證,在那里它將驗證令牌,如果有效,它將給出響應。)在angular中,我使用的是adal-angular4,在春季啟動azure活動目錄春季啟動啟動器。 另外,如何在Azure AD門戶中注冊應用程序(前端和后端)。

我嘗試使用一些文章。 當我使用令牌點擊URL時,我得到了郵遞員的回應。

{
    "code": 500,
    "status": "failure",
    "path": "/api/echo",
    "message": "com.microsoft.aad.adal4j.AuthenticationException: {\"error_description\":\"AADSTS500131: Assertion audience does not match the Client app presenting the assertion. The audience in the assertion was '48eb1c7f-e02b-43a9-913a-XXXXXXXX' and the expected audience is 'a3edefea-1ff3-43ed-b2d7-=XXXXXXXXXXXXX' or one of the Application Uris of this application with App ID 'a3edefea-1ff3-43ed-b2d7-=XXXXXXXXXX'(PulseBE).\\r\\nTrace ID: 2aced69c-f12d-4b5d-97db-XXXXXXXXXX\\r\\nCorrelation ID: 226816c8-a2ed-488c-86ec-XXXXXXXXXXXXXXXX\\r\\nTimestamp: 2019-06-17 19:10:34Z\",\"error\":\"invalid_grant\",\"error_uri\":\"https:\\/\\/login.microsoftonline.com\\/error?code=500131\"}",
    "timeStamp": "Tue Jun 18 00:40:35 IST 2019",
    "trace": null
}

iamelix,我有同樣的問題。 我的問題是我的身份驗證URL和令牌URL不包括resource參數。

下面是Azure身份驗證URL和令牌URL的格式。

郵遞員Azure AD

身份驗證URL格式https://login.microsoftonline.com/[tenant_id]/oauth2/authorize?resource=[application_id] : https://login.microsoftonline.com/[tenant_id]/oauth2/authorize?resource=[application_id] oauth2/authorize?resource https://login.microsoftonline.com/[tenant_id]/oauth2/authorize?resource=[application_id]

訪問令牌URL格式https://login.microsoftonline.com/[tenant_id]/oauth2/token?resource=[application_id] : https://login.microsoftonline.com/[tenant_id]/oauth2/token?resource=[application_id] oauth2/token?resource https://login.microsoftonline.com/[tenant_id]/oauth2/token?resource=[application_id]

對我來說,關鍵是將資源參數添加到身份驗證URL和令牌URL,現在我請求的令牌包括有效的訪問者,因此它被Azure AD毫無錯誤地接受。 我從這篇非常有用的文章中找到了上述信息: https : //www.bruttin.com/2017/11/21/azure-api-postman.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM