-
Notifications
You must be signed in to change notification settings - Fork 72
Minimal SharePoint CSOM permissions plugin #1018
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
Comments
Here's how it could work. In devproxyrc.json, you activate the new plugin and specify the path to the file that defines scopes for the different CSOM actions: {
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.25.0/rc.schema.json",
"plugins": [
{
"name": "MinimalSharePointCSOMPermissionsPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
"configSection": "minimalSharePointCSOMPermissionsPlugin"
}
],
"urlsToWatch": [
"https://*.sharepoint.com/*"
],
"minimalSharePointCSOMPermissionsPlugin": {
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.25.0/minimalsharepointcsompermissionsplugin.schema.json",
"permissionsFile": "csom.json"
},
"logLevel": "information",
"newVersionNotification": "stable",
"showSkipMessages": true,
"record": true
} In the csom.json file, which we ship with Dev Proxy, we define the list of actions and the supported scopes: {
"$schema": "schema.json",
"types": {
// for readability to map CSOM type GUIDs to human-readable names
"268004ae-ef6b-4e9b-8425-127220d84719": "Microsoft.SharePoint.SPTenant"
},
"actions": {
"268004ae-ef6b-4e9b-8425-127220d84719.RemoveDeletedSite": {
"delegated": [
// all permissions that can be used to perform this operation
// sorted ascending by privilege level, least privileged first
"AllSites.FullControl"
],
"application": [
"Sites.FullControl.All"
]
}
}
} We include these mappings in a separate files, so that users are not blocked in case they need actions that we haven't documented yet. At runtime, this plugin intercepts requests to The complexity of the implementation is twofold:
|
nice idea 👍 |
We could do absolutely do that @Adam-it. That's a nice suggestion that'll make it all a bit more readable with fewer look up, especially as the file grows. |
Here's a POC of how detecting permissions from CSOM requests could work: https://github.com/waldekmastykarz/dotnet-parse-csom |
To detect minimal permissions when using SharePoint CSOM, we need to build a new plugin. CSOM uses a single endpoint (
/_vti_bin/client.svc/ProcessQuery
) to which you POST the body with one or more CSOM operations. This is why we can't use the existing plugin based on OpenAPI specs, but rather need a new plugin that will parse the request body, extract the operations and determine the necessary set of minimal permissions.The text was updated successfully, but these errors were encountered: