Skip to content

Initial add of the Governor-Sharing App #593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
352 changes: 352 additions & 0 deletions solutions/governor-sharing/.eslintrc.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions solutions/governor-sharing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Logs
logs
*.log
npm-debug.log*

# Dependency directories
node_modules

# Build generated files
dist
lib
release
solution
temp
*.sppkg
.heft

# Coverage directory used by tools like istanbul
coverage

# OSX
.DS_Store

# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj

# Resx Generated Code
*.resx.ts

# Styles Generated Code
*.scss.ts
16 changes: 16 additions & 0 deletions solutions/governor-sharing/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
!dist
config

gulpfile.js

release
src
temp

tsconfig.json
tslint.json

*.log

.yo-rc.json
.vscode
23 changes: 23 additions & 0 deletions solutions/governor-sharing/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Hosted workbench",
"type": "msedge",
"request": "launch",
"url": "https://{tenantDomain}/_layouts/workbench.aspx",
"webRoot": "${workspaceRoot}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///.././src/*": "${webRoot}/src/*",
"webpack:///../../../src/*": "${webRoot}/src/*",
"webpack:///../../../../src/*": "${webRoot}/src/*",
"webpack:///../../../../../src/*": "${webRoot}/src/*"
},
"runtimeArgs": [
"--remote-debugging-port=9222",
"-incognito"
]
}
]
}
13 changes: 13 additions & 0 deletions solutions/governor-sharing/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Place your settings in this file to overwrite default and user settings.
{
// Configure glob patterns for excluding files and folders in the file explorer.
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/bower_components": true,
"**/coverage": true,
"**/lib-amd": true,
"src/**/*.scss.ts": true
},
"typescript.tsdk": ".\\node_modules\\typescript\\lib"
}
21 changes: 21 additions & 0 deletions solutions/governor-sharing/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"@microsoft/generator-sharepoint": {
"plusBeta": false,
"isCreatingSolution": true,
"nodeVersion": "16.20.0",
"sdksVersions": {
"@microsoft/microsoft-graph-client": "3.0.2",
"@microsoft/teams-js": "2.12.0"
},
"version": "1.18.0",
"libraryName": "microsoft-governor-sharing",
"libraryId": "4502d2aa-3b7f-46ec-886a-f5346da9e16c",
"environment": "spo",
"packageManager": "npm",
"solutionName": "microsoft-governor-sharing",
"solutionShortDescription": "microsoft-governor-sharing description",
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"componentType": "webpart"
}
}
176 changes: 176 additions & 0 deletions solutions/governor-sharing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Governor Sharing

## Summary

SPFx WebPart shows documents which have been (explicitly) shared within a SharePoint site or Team.

It does this by using the following steps:
- Issueing a Search Query (KQL) against the Graph API to retrieve documents where the managed property SharedWithUsersOWSUSER contains a value
- Iterate through the result of the search query to get the permissions (e.g. sharing information) per file (/permissions endpoint of driveItems on GraphAPI)
- Show the results in a ShimmeredDetailsList and the Pagination control for paging the results
- By selecting a document and clicking on the Sharing Settings button will open the Manage Access pane for further review of the sharing

Here is an example with a list of shared documents, with a clear distinction when they are shared with external users (notice the tooltip & icon in front of the document)
![Example Image](/assets/screenshot.png)

When you want to know more about the sharing settings of a particlar document, you can select the document and then click on the <b>Sharing Settings</b> button, this will open up the Manage Access page for the selected document which tells you that a sharing link was created for the external user.
![Example Image](/assets/screenshot2.png)

## Used SharePoint Framework Version

![version](https://img.shields.io/badge/version-1.18.0-green.svg)

## Applies to

- [SharePoint Framework](https://aka.ms/spfx)
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)

> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)

## Minimal Path to Awesome

* Clone this repository
* Move to right solution folder
* in the command line run:
* `npm install`
* `gulp serve`

## Solution

| Solution | Author(s) |
| ----------- | ------------------------------------------------------- |
| Governor Sharing | Robin Meure MSFT |

## Version history

| Version | Date | Comments |
| ------- | ---------------- | --------------- |
| 1.0 | October 27, 2023 | Initial release |

## Deployment Overview
- [SharePoint App Deployment](#sharepoint-app-deployment)
- [Prerequisites](#prerequisites-1)
- [Step 1 - Add the app to the SharePoint App catalog](#step-1---add-the-app-to-the-sharepoint-app-catalog)
- [Step 2 - Provide API consent](#step-2---provide-api-consent)
- [Step 3 - Adding the app to a SharePoint site](#step-3---adding-the-app-to-a-sharepoint-site)

- [Teams App Deployment](#teams-app-deployment)
- [Prerequisites](#prerequisites-2)
- [Step 1 - Add the app to Teams App Catalog](#step-1---add-the-app-to-teams-app-catalog)
- [Step 2 - Add the app to a Teams a tab](#step-2---add-the-app-to-a-teams-a-tab)

# SharePoint App Deployment

## Prerequisites
- A copy of the solution .sppkg package.
- The user deploying an app must be a SharePoint Administrator or Global Administrator in Microsoft 365.
- The same user needs to approve and provide consent for the API permissions (this to call the Graph Search endpoint).

## Step 1 - Add the app to the SharePoint App catalog

Follow the steps below to add the app to the SharePoint App catalog:

- Go to [More features](https://go.microsoft.com/fwlink/?linkid=2185077) in the SharePoint admin center, and sign in with an account that has the SharePoint Administrator or Global Administrator for your organization.
- Under Apps, select Open. If you didn’t have an app catalog before, it might take a few minutes to load.

<img src="assets/SharePoint_Admin_Center_Manage_apps.png" width="1000"/>

- On the Manage apps page, click <b>Upload</b>, and browse to location fo the app package. The package file should have .sppkg extension.
- Select <b>Enable this app and add it to all sites</b>. This will automatically add the app to the sites, so that site owners will not need to do it themselves. Unchecked the box <b>Add to Teams</b>. If you want to add the App to Teams you need to follow these instructions. Click <b>Enable app</b> at the bottom of the side panel.

<img src="assets/SharePoint_Admin_Center_Enable_app.png" width="300"/>

## Step 2 - Provide API consent

After the API is Enable you will need to provide consent. For this step you need the Global Administrator role.
You will provide delegated permissions that will allow the application to act on a user's behalf. The application will never be able to access anything the signed in user themselves couldn't access. To learn more about delegated permissions see: https://learn.microsoft.com/en-us/entra/identity-platform/permissions-consent-overview#types-of-permissions

- Click on <b>Go to the API access</b> page.

<img src="assets/SharePoint_Admin_Center_API_Consent.png" width="300"/>

- Click <b>Approve</b> to provide consent.

<img src="assets/SharePoint_Admin_Center_API_Consent_Approve.png" width="600"/>

## Step 3 - Adding the app to a SharePoint site

- On the site where you want to use the app go to a page and open it for editing or create a new page for this purpose.
- Click on the <b>“+”</b> to add a new web part and search for “Governor sharing”. Click on it to add it to the page.

<img src="assets/Govenor_Sharing_AddtoSharePointSite.png" width="600"/>

- The webpart should now be added to your page.

<img src="assets/Govenor_Sharing_SharedItemsExample.png" width="900"/>

- Save or Republish the page to see the changes applied.

# Teams App Deployment

For the Teams App deployment, the app needs to be deployed to the SharePoint App Catalog first (Step 1 and Step 2).

## Prerequisites
- A copy of the Teams Apps solution [package](/assets/governorsharing_teamspackage.zip)
- The user deploying the app must be a Teams Administrator or Global Administrator in Microsoft 365.

## Step 1 - Add the app to Teams App Catalog

- Browse to the Manage Apps page in the Teams Admin Center: https://admin.teams.microsoft.com/policies/manage-apps
- Click <b>Upload new App</b>, Click <b>Upload</b> and browse to the teams app package location. The package file should have .zip extension. After selecting the package click <b>Open</b>. The app will be uploaded.

<img src="assets/Teams_Admin_Center_Manage_apps.png" width="500"/>

<img src="assets/Teams_Admin_Center_Manage_apps_Upload.png" width="500"/>

<img src="assets/Teams_Admin_Center_Manage_apps_Uploaded.png" width="500"/>

- You may need to adjust your Teams App policies to make the app availabe for you organisation. For more information see https://learn.microsoft.com/en-us/microsoftteams/teams-app-permission-policies.

## Step 2 - Add the app to a Teams a tab

- Go to MS Teams and click on the <b>Apps</b> on the left bar to open the App store of Teams.
- On the left menu choose <b>Built for your Org</b> option to prefilter the apps and select “Governor sharing”. Click <b>Add</b>.

<img src="assets/Govenor_Sharing_AddtoTeam.png" width="500"/>

- Click on <b>Add to a team</b>, choose a team and a channel where you want the app to be added and click <b>Set up a tab</b> on the bottom right of the pop-up window.
<img src="assets/Govenor_Sharing_AddtoTeamTab.png" width="500"/>

<img src="assets/Govenor_Sharing_AddtoTeam_SelectTeam.png" width="500"/>

- Click on <b>Save</b>

<img src="assets/Govenor_Sharing_AddtoTeam_Save.png" width="500"/>

- The app has been added to a Team. The settings panel on the right side can be closed.

<img src="assets/Govenor_Sharing_AddedtoTeam.png" width="500"/>


# Troubleshooting

If you face any other errors, you can enable the debugging mode from the configuration pane. When this is enabled, there is a lot more details being outputted to the written to the console.

- In green you see the search (KQL) query what is used to retrieve documents
- In yellow, you see the search results
- In blue, you see the transformation of combining the searchresults and the permission calls

<img src="assets/debug.png" width="500"/>

## Known errors

Issue: We can't upload the app because there's already an app in the catalog with the same app ID. To upload a new app, change the app ID and try again. To update an existing app, go to the app details page.

Solution: Detele the app in the Teams Apps overview and re-add the package.

More information about deleting apps in Teams can found here: https://learn.microsoft.com/en-us/microsoftteams/teams-custom-app-policies-and-settings#delete-custom-apps-from-your-organizations-catalog


<img src="https://pnptelemetry.azurewebsites.net/sp-dev-solutions/solutions/governorsharing" />

## Disclaimer

**THIS CODE IS PROVIDED _AS IS_ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

---
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added solutions/governor-sharing/assets/debug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added solutions/governor-sharing/assets/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions solutions/governor-sharing/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"sharing-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/sharing/SharingWebPart.js",
"manifest": "./src/webparts/sharing/SharingWebPart.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"SharingWebPartStrings": "lib/webparts/sharing/loc/{locale}.js",
"ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js"
}
}
7 changes: 7 additions & 0 deletions solutions/governor-sharing/config/deploy-azure-storage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./release/assets/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "microsoft-governor-sharing",
"accessKey": "<!-- ACCESS KEY -->"
}
47 changes: 47 additions & 0 deletions solutions/governor-sharing/config/package-solution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "Governor Sharing",
"id": "81a9fd71-f423-4420-8a6d-393fba93dc95",
"iconPath": "530be57e-cc29-49a2-9596-2068462b6d9a_96_color.png",
"version": "2.0.0.6",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"developer": {
"name": "Robin Meure",
"websiteUrl": "http://github.com/robinmeure",
"privacyUrl": "https://privacy.microsoft.com/en-us/privacystatement",
"termsOfUseUrl": "https://www.microsoft.com/en-us/servicesagreement",
"mpnId": "Undefined-1.15.0"
},
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Sites.Read.All"
}
],
"metadata": {
"shortDescription": {
"default": "App that shows explicit sharing on a site or team."
},
"longDescription": {
"default": "App that shows explicit sharing on a site or a team."
},
"screenshotPaths": [],
"videoUrl": "",
"categories": []
},
"features": [
{
"title": "governor-sharing Feature",
"description": "The feature that activates elements of the governor-sharing solution.",
"id": "75e0dfb2-a990-45a2-b138-53bb431534c8",
"version": "1.0.0.0"
}
]
},
"paths": {
"zippedPackage": "solution/governor-sharing.sppkg"
}
}
3 changes: 3 additions & 0 deletions solutions/governor-sharing/config/sass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
}
6 changes: 6 additions & 0 deletions solutions/governor-sharing/config/serve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://{tenantDomain}/_layouts/workbench.aspx"
}
4 changes: 4 additions & 0 deletions solutions/governor-sharing/config/write-manifests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
}
Loading