【Azure Entra ID】當Entra ID中的用戶所屬Group數(shù)量超過200個之后的問題
問題描述
使用Azure Entra ID進行用戶的登錄授權(quán)管理,但是當這個用戶所屬的組(Group)超過200個之后,在ID Token中就無法全部包含,而是返回一個endpoint,需要再次通過這個Endpoint來獲取完整的Group List。
例如:
## 在Group < = 200 的時候

## 在Group > 200 的時候

那么,是否有辦法當Group 大于200的情況下,也可以直接返回所需要的Group list呢?在我們常規(guī)的請求中,根本不需要獲取一個用戶的全部組,只需要獲取當前應用所使用的Group呢?
問題解答
可以的。 Entra ID提供了一個 Group Filtering 的功能來過濾用戶的用戶組(Group), 這樣就可以有效的解決Group超過200個之后的ID Token中無法直接返回的問題。
Group filtering [Configure group claims for applications by using Microsoft Entra ID - Microsoft Entra ID | Microsoft Learn]
Group filtering allows for fine control of the list of groups that's included as part of the group claim. When a filter is configured, only groups that match the filter will be included in the group's claim that's sent to that application. The filter will be applied against all groups regardless of the group hierarchy.
具體的操作步驟如下:
1) 進入Azure Entra ID頁面,進入到“注冊應用”頁面,在 概述(overview)頁面上點擊“Managed Application in ....”,進入此應用的“企業(yè)應用”頁面

2) 選擇“Single sign-on”后,編輯group屬性

3)在Additional Claims 部分,選擇groups,在右側(cè)彈出頁面中的 Advanced Options中,啟用Filter Groups
- Attribute to Match就選擇Display name (注:display name就是group的name)
- Match with 根據(jù)需求,可以選擇前綴匹配(Prefix),后綴匹配(Suffix),包含(Contains)
- String 就填寫我們需要過濾組的名稱的關(guān)鍵字

保存。
再次請求,就可以看見ID Token中的Group信息已經(jīng)列舉出所想要的Group List了。

參考資料
Configure group claims for applications by using Microsoft Entra ID : https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-fed-group-claims#group-filtering
當在復雜的環(huán)境中面臨問題,格物之道需:濁而靜之徐清,安以動之徐生。 云中,恰是如此!

浙公網(wǎng)安備 33010602011771號