共用方式為


使用 Microsoft Entra ID 設定 RStudio Connect 的 SAML 身份驗證,以啟用單一登入功能。

在本文中,您將瞭解如何整合 RStudio Connect SAML Authentication 與 Microsoft Entra ID。 將 RStudio Connect SAML Authentication 與 Microsoft Entra ID 整合後,您可以:

  • 在 Microsoft Entra ID 中控制可存取 RStudio Connect SAML Authentication 的人員。
  • 讓使用者以其 Microsoft Entra 帳戶自動登入 RStudio Connect SAML Authentication。
  • 在一個集中式位置管理您的帳戶。

必要條件

本文中所述的案例假設您已經具備下列必要條件:

案例描述

在本文中,您會在測試環境中設定及測試Microsoft Entra 單一登錄。

  • RStudio Connect 的 SAML 認證支持 SP 和 IDP 起始的 SSO。

  • RStudio Connect SAML Authentication 支援 Just In Time 使用者佈建。

若要進行將 RStudio Connect SAML Authentication 整合到 Microsoft Entra ID 的設定,您必須將 RStudio Connect SAML Authentication 從資源庫新增至受控 SaaS 應用程式清單中。

  1. 以至少 雲端應用程式系統管理員 的身分登入 Microsoft Entra 系統管理中心
  2. 請流覽至 Entra ID>企業應用程式>新增應用程式
  3. 從圖庫新增 區段的搜尋方塊中輸入 RStudio Connect SAML Authentication
  4. 從結果面板選取 [RStudio Connect SAML Authentication],然後新增應用程式。 將應用程式新增至您的租戶時,請稍候幾秒鐘。

或者,您也可以使用企業應用程式組態精靈。 在此精靈中,您可以將應用程式新增至租戶,將使用者或群組新增至應用程式,指派角色,以及完成 SSO 設定。 深入了解 Microsoft 365 精靈。

為 RStudio Connect SAML Authentication 設定及測試 Microsoft Entra SSO

以名為 B.Simon 的測試使用者,設定及測試與 RStudio Connect SAML Authentication 搭配運作的 Microsoft Entra SSO。 為確保 SSO 能正常執行,您必須在 Microsoft Entra 使用者與 RStudio Connect SAML Authentication 中的相關使用者之間建立連結關聯性。

若要設定及測試與 RStudio Connect SAML Authentication 搭配運作的 Microsoft Entra SSO,請執行下列步驟:

  1. 設定 Microsoft Entra SSO - 讓使用者能夠使用此功能。
    1. 建立 Microsoft Entra 測試使用者 - 使用 Britta Simon 測試Microsoft Entra 單一登錄。
    2. 指派Microsoft Entra 測試使用者 - 讓 Britta Simon 能夠使用 Microsoft Entra 單一登錄。
  2. 設定 RStudio Connect SAML Authentication SSO - 在應用程式端設定單一登入設定。
    1. 建立 RStudio Connect SAML Authentication 測試用戶 - 將 RStudio Connect SAML Authentication 中的對應 Britta Simon 與 Microsoft Entra 中的用戶表示連結。
  3. 測試 SSO - 確認組態是否正常運作。

設定 Microsoft Entra SSO

遵循下列步驟來啟用 Microsoft Entra SSO。

  1. 以至少 雲端應用程式系統管理員 的身分登入 Microsoft Entra 系統管理中心

  2. 流覽至 Entra ID>企業應用>RStudio Connect SAML Authentication>單一簽入

  3. 在 [選取單一登入方法] 頁面上,選取 [SAML]

  4. 在 [設定使用 SAML 單一登入] 頁面上,選取 [基本 SAML 組態] 的鉛筆圖示來編輯設定。

    編輯基本 SAML 組態

  5. 在 [基本 SAML 設定] 區段上,如果您想要以 IDP 起始模式設定應用程式,請執行下列步驟,將 <example.com> 取代為您的 RStudio Connect SAML Authentication 伺服器位址和連接埠:

    一。 在 [識別碼] 文字方塊中,使用下列模式來輸入 URL:https://<example.com>/__login__/saml

    b。 在 [回覆 URL] 文字方塊中,使用下列模式來輸入 URL:https://<example.com>/__login__/saml/acs

  6. 如果您想要以 SP 起始模式設定應用程式,請選取 [設定其他 URL],然後執行下列步驟:

    在 [登入 URL] 文字方塊中,以下列模式輸入 URL︰https://<example.com>/

    這些數值不是真實的。 請使用實際的「識別碼」、「回覆 URL」及「登入 URL」來更新這些值。 這些值是由 RStudio Connect SAML Authentication 伺服器位址 (在上述範例中為 https://example.com) 來決定。 如果遇到問題,請連絡 RStudio Connect SAML Authentication 支援小組。 您也可以參考 [基本 SAML 組態] 區段中所顯示的模式。

  7. RStudio Connect SAML Authentication 應用程式期望以特定格式接收 SAML 聲明,這要求您將自訂屬性對應新增到 SAML 令牌屬性配置中。 下列螢幕擷取畫面顯示預設屬性清單,其中的 nameidentifieruser.userprincipalname 相對應。 RStudio Connect SAML Authentication 應用程式預期 nameidentifier 要與 user.mail 對應,因此您必須選取 [ 編輯 ] 圖示並變更屬性對應來編輯屬性對應。

    圖片

  8. [使用 SAML 設定單一 Sign-On] 頁面上的 [SAML 簽署憑證] 區段中,選取 [複製] 按鈕以複製 應用程式同盟元數據 URL,並將它儲存在您的計算機上。

    憑證下載連結

建立並指派 Microsoft Entra 測試使用者

請遵循 建立並指派用戶帳戶 快速入門中的指導方針,以建立名為 B.Simon 的測試用戶帳戶。

設定 RStudio Connect SAML 驗證 SSO

若要針對 RStudio Connect SAML Authentication 設定單一登入,您必須使用上面所使用的應用程式同盟中繼資料 URL伺服器位址。 這能透過位於 /etc/rstudio-connect.rstudio-connect.gcfg 的 RStudio Connect SAML Authentication 設定檔來完成。

這是範例的設定檔:

[Server]
SenderEmail =

; Important! The user-facing URL of your RStudio Connect SAML Authentication server.
Address = 

[Http]
Listen = :3939

[Authentication]
Provider = saml

[SAML]
Logging = true

; Important! The URL where your IdP hosts the SAML metadata or the path to a local copy of it placed in the RStudio Connect SAML Authentication server.
IdPMetaData = 

IdPAttributeProfile = azure
SSOInitiated = IdPAndSP

如果 IdPAttributeProfile = azure,則設定檔會在其他設定中將 NameIDFormat 設定為永續性,並覆寫設定檔案中定義的任何其他指定屬性。

如果您想要事先使用 RStudio Connect API 建立使用者,並在使用者第一次登入之前套用權限,這就會變成問題。 NameIDFormat 應該設定為 emailAddress 或其他唯一識別碼,因為當其設定為永續性時,該值就會經過雜湊處理,您無法事先知道值是什麼。 因此,使用 API 無法運作。 用於建立 SAML 使用者的 API:https://docs.rstudio.com/connect/api/#post-/v1/users

因此,在此情況下,您可以在設定檔中擁有此項目:

[SAML]
NameIDFormat = emailAddress
UniqueIdAttribute = NameID
UsernameAttribute = http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
FirstNameAttribute = http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname
LastNameAttribute = http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname
EmailAttribute = http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailAddress

將您的伺服器位址 儲存在 Server.Address 值中,然後將 [應用程式同盟中繼資料 URL] 儲存在 SAML.IdPMetaData 值中。 請注意,此範例設定會使用未加密的 HTTP 連線,而 Microsoft Entra ID 需要使用加密的 HTTPS 連線。 您可以使用 RStudio Connect SAML Authentication 前面的反向 Proxy,或將 RStudio Connect SAML Authentication 設定為直接使用 HTTPS

如果您遇到設定上的問題,請參閱 系統管理指南或傳送電子郵件給 RStudio 支援小組以取得協助。

建立 SAML 驗證的 RStudio Connect 測試使用者

本節會在 RStudio Connect SAML Authentication 中建立名為 Britta Simon 的使用者。 RStudio Connect 的 SAML Authentication 支援即時佈建,且這項功能是預設啟用的。 本節中沒有需要您完成的項目。 如果 RStudio Connect SAML Authentication 中還沒有使用者,當您嘗試存取 RStudio Connect SAML Authentication 時,就會建立新的使用者。

測試 SSO

在本節中,您會使用下列選項來測試您的 Microsoft Entra 單一登入設定。

SP 啟動:

  • 選取 [測試此應用程式],此選項會重新導向至您可以在其中起始登入流程的 RStudio Connect SAML 驗證登入 URL。

  • 直接移至 RStudio Connect SAML Authentication 登入 URL,然後從該處起始登入流程。

IDP 啟動:

  • 選取 [ 測試此應用程式],您應該會自動登入您已設定 SSO 的 RStudio Connect SAML 驗證。

您也可以使用 Microsoft「我的應用程式」,以任何模式測試應用程式。 當您在 My Apps 中選取 [RStudio Connect SAML Authentication] 圖格時,如果是在 SP 模式中設定,您會重新導向至 [應用程式登入] 頁面來起始登入流程,如果在 IDP 模式中設定,則應該會自動登入您已設定 SSO 的 RStudio Connect SAML Authentication。 如需詳細資訊,請參閱 Microsoft Entra 我的應用程式

設定 RStudio Connect SAML Authentication 後,您可以強制執行工作階段控制項,以即時防止組織的敏感資料遭到外洩和滲透。 會話控制是從條件式存取衍生而來的。 了解如何使用 Microsoft Defender for Cloud Apps 實施工作階段控制