如何使用Sharepoint (應用程式)

注意:針對使用Adobe的Sharepoint的專案,請繼續 此處.

如果您使用SharePoint作為內容來源,AEM會使用註冊的Microsoft Azure應用程式來存取您的內容。 此應用程式具有 委派許可權 已定義,可讓服務代表使用者存取SharePoint。 此使用者需要註冊至使用SharePoint的專案。

或者,服務也可以認證為應用程式並使用 應用程式許可權 以存取網站。 這需要SharePoint網站管理員進行額外設定,才能授予應用程式的許可權。

首選的設定是使用 應用程式許可權 ​中,如此可縮小服務對特定SharePoint網站的存取許可權,且不需要共用技術使用者的任何秘密。 此外,它還可減少密碼輪換的問題。

以下說明如何設定 應用程式許可權 專案的。 如果您想要設定技術使用者,請繼續 此處.

設定SharePoint的過程包含下列步驟:

  1. 建立或識別將作為檔案式編寫網站的Sharepoint網站
  2. 在SharePoint中建立將作為網站根目錄的資料夾。
  3. 設定 fstab.yaml 與個別資料夾
  4. 存取註冊入口網站
  5. 註冊應用程式
  6. 套用 sites.selected SharePoint網站的許可權

1.建立或識別Sharepoint網站

請洽詢您的IT部門,以識別或建立將用於檔案式撰寫的Sharepoint網站。 一個網站可以「託管」多個網站(專案)。 此網站稍後將收到個別許可權,以便發佈服務能夠存取它。

2.建立網站根資料夾

導覽至您在上面建立或識別的SharePoint網站中想要的位置,並建立將作為網站根目錄的根資料夾。 最好不要直接使用SharePoint清單根目錄,這樣您就有供作者放置附屬檔案的共用空間,例如草稿資料夾或如何撰寫檔案。

範例檔案結構可能如下所示,使用 website 作為根的資料夾:

3.設定fstab.yaml

下一步是設定此掛接點於 fstab.yaml 以指向網站根目錄。 其形式通常為

https://<tenant>.SharePoint.com/sites/<sp-site>/Shared%20Documents/website

但這可能會因您建立SharePoint網站和清單的方式而異。 為了取得url,最簡單的方法是從瀏覽器位址複製並超過第一部分,例如:

然後手動新增其餘的(請注意,透過UI複製共用連結會新增不必要的資訊,而且最好使用URL的規範表示法)。 撰寫URL後,您可以在瀏覽器中再次輸入以進行測試。 您最後應該會進入網站根目錄的資料夾檢視。

之後,請更新 fstab.yaml 視情況而定。

例如:

mountpoints:
  /: https://adobeenterprisesupportaem.SharePoint.com/sites/hlx-test-project/Shared%20Documents/website

若要完成設定,請認可 fstab.yaml 返回主要分支。

4.存取註冊入口網站

概觀

為了讓AEM服務存取編寫的內容,它需要一些資訊和設定。 AEM服務(雲端功能)會存取 MS Graph API 代表應用程式(或已設定的使用者)。 若要這麼做,它需要在上下文中先驗證 應用. 這很重要,因為指定給應用程式的範圍定義了服務在MS Graph API上的許可權。 例如,應該允許讀取和寫入檔案,但不允許變更存取控制。

應用程式在租使用者的個別Active Directory中會顯示為「企業應用程式」。 授予該企業應用程式的許可權最終定義服務可在該租使用者的資源中存取什麼。 使用者使用應用程式前,某些許可權必須由Active Directory管理員核准。 這稱為「管理員同意」,是驗證及控制應用程式可擁有哪些許可權的機制。 這是為了避免可疑應用程式欺騙使用者信任非官方應用程式。 擁有額外的管理員同意步驟,IT安全性就能控制員工可以使用哪些應用程式。

1.登入註冊入口網站

欄(包含)

<h3>在Azure入口網站中檢視企業應用程式</h3>

假設Azure中目前沒有Franklin Enterprise應用程式(Microsoft Entra Id)

<h3>存取Franklin註冊入口網站</h3>

前往 https://admin.hlx.page/register,輸入專案的github url

<h3>以非管理員使用者身分登入</h3>

以使用者身分登入,該 不會 擁有管理員許可權會顯示需要核准的錯誤,即應用程式需要管理員同意。

問題:如果使用者從未登入,系統就不會註冊企業應用程式。

<h3>以管理員使用者身分登入</h3>

一種解決方案是以使用者身分登入,該解決方案可 擁有管理員許可權:

(請注意,目前企業應用程式尚未在azure中註冊)

<h3>Franklin Registration Service在UI中可見</h3>

如果管理員登入(未勾選核取方塊也未授予每個人同意),則表示存在企業應用程式。

使用MSGraph或Powershell建立應用程式

或者,您可以透過MSGraph或Powershell建立Enterprise應用程式。

若要使其在Azure UI中可見,您也需要新增 WindowsAzureActiveDirectoryIntegratedApp 標籤之間。 這可以在建立應用程式時直接完成。

使用圖表總管:

POST https://graph.microsoft.com/v1.0/servicePrincipals
Content-type: application/json
{
    "appId": "e34c45c4-0919-43e1-9436-448ad8e81552",
    "tags": [
        "WindowsAzureActiveDirectoryIntegratedApp"
    ]
}

使用powershell:

PS> connect-MgGraph -Scopes "Application.ReadWrite.All"
PS> New-MgServicePrincipal -AppId e34c45c4-0919-43e1-9436-448ad8e81552 -Tags WindowsAzureActiveDirectoryIntegratedApp
欄(包含)

之後,如果您希望非管理員使用者登入,仍需提供管理員同意。

另請參閱:

<h3>檢閱許可權</h3>

請注意 Franklin Registration Service (e34c45c4-0919-43e1-9436-448ad8e81552) 註冊期間才需要應用程式,以驗證使用者是否具有sharepoint的讀取存取權。 它有以下功能 委派許可權

  • Openid
    允許使用者以其工作或學校帳戶登入應用程式,並允許應用程式檢視基本的使用者設定檔資訊。
  • Profile
    允許應用程式檢視使用者的基本設定檔(例如名稱、圖片、使用者名稱、電子郵件地址)
  • Files.ReadWrite.All
    允許應用程式讀取、建立、更新及刪除所有登入使用者可存取的檔案。

<h3>使用者已登入註冊入口網站</h3>

完成此初始步驟後,使用者即會登入註冊入口網站

使用應用程式許可權新增Franklin服務

欄(包含)

<h3>新增企業應用程式</h3>

登入註冊入口網站時,專案使用的內容來源必須連線至 Franklin Service 應用程式。 這是必要的,這樣系統才能存取SharePoint中的檔案,並將其轉換為內部格式(Markdown),並儲存在Adobe的儲存空間(S3/R2)中以便快速傳送。

使用應用程式 sites.selected 許可權會比較安全,因為它將範圍限制在單一sharepoint網站。 若要連線,請按一下 Connect Application 按鈕。

如果您之前從未註冊過應用程式或使用者,您可能會看到以下錯誤:

code language-none
Unable to validate access: Either scp or roles claim need to be present in the token.

與上述相同,此應用程式的 Franklin Service (83ab2922-5f11-4e4d-96f3-d1e0ff152856) Azure中尚未出現,

若要新增圖表,請使用圖表總管或Powershell進行新增:

使用圖表總管:

POST https://graph.microsoft.com/v1.0/servicePrincipals
Content-type: application/json
{
    "appId": "83ab2922-5f11-4e4d-96f3-d1e0ff152856",
    "tags": [
        "WindowsAzureActiveDirectoryIntegratedApp"
    ]
}

使用powershell:

PS> connect-MgGraph -Scopes "Application.ReadWrite.All"
PS> New-MgServicePrincipal -AppId 83ab2922-5f11-4e4d-96f3-d1e0ff152856 -Tags WindowsAzureActiveDirectoryIntegratedApp

另請參閱:

欄(包含)

<h3>新增應用程式角色</h3>

現在的企業應用程式 Franklin Service 在azure中可見。 但是它沒有 Sites.Selected 應用程式許可權。

問題:使用管理員同意UI會授與所有應用程式和委派許可權,我們不想要這麼做。

一種簡單的方式是同意所有許可權,然後再次移除委派的許可權。

使用Powershell或Graph Explorer新增應用程式角色

或者,您也可以透過下列步驟新增應用程式角色:

  1. 尋找企業應用程式的服務主體(principalId)。 這是您在上方建立的專案。
  2. 尋找Microsoft Graph API的服務主體(resourceId)
  3. 尋找ID Sites.Selected 應用程式角色(appRoleId)
  4. 將應用程式角色指派給Managed識別(企業應用程式)

使用 powershell 您可以透過以下方式完成:

$ObjectId = "abcdef-1234-49b6-b660-cc85b34fe516"    <<------ replace with your enterprise app id
$AAD_SP = Get-AzureADServicePrincipal -SearchString "Microsoft Graph";
$AAD_SP

$MSI = Get-AzureADServicePrincipal -ObjectId $ObjectId
if($MSI.Count -gt 1)
  {
  Write-Output "More than 1 principal found, please find your principal and copy the right object ID. Now use the syntax $MSI = Get-AzureADServicePrincipal -ObjectId <your_object_id>"
  Exit
  }

$AAD_AppRole = $AAD_SP.AppRoles | Where-Object {$_.Value -eq "Sites.Selected"}
New-AzureADServiceAppRoleAssignment -ObjectId $MSI.ObjectId  -PrincipalId $MSI.ObjectId  -ResourceId $AAD_SP.ObjectId[0]  -Id $AAD_AppRole.Id

使用 圖表總管 其中涉及更多步驟:

  1. 尋找企業應用程式的主體:
  GET https://graph.microsoft.com/v1.0/servicePrincipals?$filter=appId eq '83ab2922-5f11-4e4d-96f3-d1e0ff152856'
...
  "value": [
        {
            "id": "6761ada0-733b-4a02-98b2-3db970834fe0",
...

這是我們的 principalId

  1. 尋找Microsoft Graph API的服務主體
GET https://graph.microsoft.com/v1.0/servicePrincipals?$filter=appId eq '00000003-0000-0000-c000-000000000000'
...
  "value": [
        {
            "id": "5159db96-7193-414e-9730-b1d1e4448443",
...

這是 resourceId. (定義應用程式角色的資源)

  1. 尋找應用程式角色的識別碼。
GET https://graph.microsoft.com/v1.0/servicePrincipals/5159db96-7193-414e-9730-b1d1e4448443/appRoles
...
        {
            "allowedMemberTypes": [
                "Application"
            ],
            "description": "Allow the application to access a subset of site collections without a signed in user.  The specific site collections and the permissions granted will be configured in SharePoint Online.",
            "displayName": "Access selected site collections",
            "id": "883ea226-0bf2-4a8f-9f9d-92c9162a727d",
            "isEnabled": true,
            "origin": "Application",
            "value": "Sites.Selected"
        },
...

此ID為 appRoleId

  1. 將應用程式角色指派給Managed Identity。 請求的格式為:
POST https://graph.microsoft.com/v1.0/servicePrincipals/${principalId}/appRoleAssignedTo
Content-Type: application/json

{
  "principalId": "${principalId}",
  "resourceId": "${resourceId}",
  "appRoleId": "${appRoleId}"
}
https://graph.microsoft.com/v1.0/servicePrincipals/6761ada0-733b-4a02-98b2-3db970834fe0/appRoleAssignedTo
Content-type: application/json
{
    "principalId": "6761ada0-733b-4a02-98b2-3db970834fe0",
    "resourceId": "5159db96-7193-414e-9730-b1d1e4448443",
    "appRoleId": "883ea226-0bf2-4a8f-9f9d-92c9162a727d"
}
欄(包含)

<h3>驗證許可權</h3>

最終,您應該會在UI中看到已授與的應用程式許可權。

回到註冊入口網站,應該已變更為:

code language-none

The resource specified in the fstab.yaml does either not exist, or you do not have permission to access it. Please make sure that the url is correct, the enterprise application: "Franklin Service (83ab2922-5f11-4e4d-96f3-d1e0ff152856)" is consented for the required scopes, and that the logged in user has permissions to access it.

(請注意,在撰寫時,此訊息不是很準確,應該寫成:

fstab.yaml中指定的資源不存在,或您沒有存取許可權。 請確定URL正確無誤,企業應用程式:「Franklin Service (83ab2922-5f11-4e4d-96f3-d1e0ff152856)」已透過「Sites.Selected」許可權被授與存取設定的Sharepoint網站。


新增許可權至Sharepoint網站

若要將許可權新增至SharePoint網站,我們需要尋找其 SiteId.

這可以再次使用圖表總管來完成:

GET https://graph.microsoft.com/v1.0/sites/{host-name}:/{server-relative-path}

範例:

GET https://graph.microsoft.com/v1.0/sites/adobeenterprisesupportaem.sharepoint.com:/sites/hlx-test-project

{
...
    "id": "adobeenterprisesupportaem.sharepoint.com,03cc3587-0e4d-405e-b06c-ffb0a622b7ac,5fbc1df5-640c-4780-8b59-809e3193c043",
...
}

使用 Id 我們可以設定許可權:

POST https://graph.microsoft.com/v1.0/sites/adobeenterprisesupportaem.sharepoint.com,03cc3587-0e4d-405e-b06c-ffb0a622b7ac,5fbc1df5-640c-4780-8b59-809e3193c043/permissions
Content-type: application/json

{
    "roles": [
        "write"
    ],
    "grantedToIdentities": [
        {
            "application": {
                "id": "83ab2922-5f11-4e4d-96f3-d1e0ff152856",
                "displayName": "Franklin Service"
            }
        }
    ]
}
欄(包含)
之後,註冊入口網站應顯示 canRead: ok
recommendation-more-help
10a6ce9d-c5c5-48d9-8ce1-9797d2f0f3ec