如何使用Sharepoint (應用程式)
注意:針對使用Adobe的Sharepoint的專案,請繼續 此處.
如果您使用SharePoint作為內容來源,AEM會使用註冊的Microsoft Azure應用程式來存取您的內容。 此應用程式具有 委派許可權 已定義,可讓服務代表使用者存取SharePoint。 此使用者需要註冊至使用SharePoint的專案。
或者,服務也可以認證為應用程式並使用 應用程式許可權 以存取網站。 這需要SharePoint網站管理員進行額外設定,才能授予應用程式的許可權。
首選的設定是使用 應用程式許可權 中,如此可縮小服務對特定SharePoint網站的存取許可權,且不需要共用技術使用者的任何秘密。 此外,它還可減少密碼輪換的問題。
以下說明如何設定 應用程式許可權 專案的。 如果您想要設定技術使用者,請繼續 此處.
設定SharePoint的過程包含下列步驟:
- 建立或識別將作為檔案式編寫網站的Sharepoint網站
- 在SharePoint中建立將作為網站根目錄的資料夾。
- 設定
fstab.yaml
與個別資料夾 - 存取註冊入口網站
- 註冊應用程式
- 套用
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.登入註冊入口網站
使用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
使用應用程式許可權新增Franklin服務
與上述相同,此應用程式的 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
另請參閱:
使用Powershell或Graph Explorer新增應用程式角色
或者,您也可以透過下列步驟新增應用程式角色:
- 尋找企業應用程式的服務主體(
principalId
)。 這是您在上方建立的專案。 - 尋找Microsoft Graph API的服務主體(
resourceId
) - 尋找ID
Sites.Selected
應用程式角色(appRoleId
) - 將應用程式角色指派給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
使用 圖表總管 其中涉及更多步驟:
- 尋找企業應用程式的主體:
GET https://graph.microsoft.com/v1.0/servicePrincipals?$filter=appId eq '83ab2922-5f11-4e4d-96f3-d1e0ff152856'
...
"value": [
{
"id": "6761ada0-733b-4a02-98b2-3db970834fe0",
...
這是我們的 principalId
- 尋找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
. (定義應用程式角色的資源)
- 尋找應用程式角色的識別碼。
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
- 將應用程式角色指派給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"
}
新增許可權至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"
}
}
]
}