Understanding Resource Specific Consent for Microsoft Graph and SharePoint Online

Microsoft Community Learning
30 Mar 202311:54

Summary

TLDRThis video script discusses the implementation of resource-specific permissions in SharePoint Online and Microsoft Graph, focusing on the 'site.selected' application permission. It explains how to configure this permission for access to specific site collections without granting full control to the entire tenant. The script guides through the process of setting up certificate authentication in Azure Active Directory, granting permissions using Microsoft Graph and PowerShell, and testing access with a .NET application. It demonstrates the powerful capability of targeting specific site collections with application-only tokens, enhancing security and control.

Takeaways

  • 🔒 SharePoint Online and Microsoft Graph require specific permissions for accessing sites, which can be configured using application permissions.
  • 🌐 The 'site.selected' permission allows access to a specific site or set of site collections, rather than the entire tenant.
  • 🔑 To use 'site.selected' permissions, you need to authenticate with a certificate against Azure Active Directory.
  • 📜 Azure Access Control Service (ACS) is no longer needed; direct authentication through Azure Active Directory and OAuth is sufficient.
  • 👤 A global administrator or someone with 'designs.fullcontrol.all' permissions is required to grant 'site.selected' permissions to a target site.
  • 📊 The permissions can be configured as read-only, write, manage, or full control, providing flexibility in access control.
  • 📝 Azure Active Directory applications can be registered with certificate authentication and client secrets for secure access.
  • 📜 Certificates for authentication can be created using PowerShell cmdlets, with both public and private keys managed separately.
  • 🤖 Testing access permissions can be done using .NET Framework applications that attempt to interact with SharePoint Online via Microsoft Graph or the SharePoint REST API.
  • 🚫 Access is denied when attempting to interact with a site collection that has not been granted permissions, demonstrating the effectiveness of the 'site.selected' permission.
  • 🗑 Permissions can be revoked using PowerShell cmdlets, allowing for dynamic management of access rights.

Q & A

  • What is the purpose of the 'site.*selected' permission in SharePoint Online and Microsoft Graph?

    -The 'site.*selected' permission is used to restrict a set of permissions to a specific site or set of site collections in SharePoint Online and Microsoft Graph, rather than granting access to the entire tenant.

  • Why is certificate authentication required for SharePoint Online with application-only tokens?

    -Certificate authentication is required for SharePoint Online when using application-only tokens because it provides a secure way to authenticate against Azure Active Directory without relying on user credentials.

  • How can you configure the 'site.*selected' permission for a specific site collection?

    -You can configure the 'site.*selected' permission for a specific site collection by using either Microsoft Graph API or PowerShell, specifically the PnP (Patterns and Practices) PowerShell cmdlets.

  • What are the steps to create a certificate for certificate authentication?

    -To create a certificate for certificate authentication, you can use the PnP PowerShell cmdlets to generate a certificate, save it as a PFX file with a private key, and as a .cer file with just the public key. You also need to specify a password for the certificate.

  • How can you grant the 'site.*selected' permission to a specific site collection using PowerShell?

    -You can grant the 'site.*selected' permission to a specific site collection using the 'Grant-PnPAzureADSitePermission' PowerShell cmdlet, providing the application ID, display name, target URL of the site, and the desired permission level.

  • What is the difference between using Microsoft Graph and SharePoint REST API for accessing SharePoint Online?

    -Microsoft Graph is a unified API endpoint that provides access to various Microsoft services including SharePoint Online, while the SharePoint REST API is specifically designed for SharePoint Online. Both can be used to access and manipulate SharePoint resources, but Microsoft Graph offers a broader range of services.

  • How can you test the permissions granted to an application in SharePoint Online?

    -You can test the permissions by attempting to perform actions on the SharePoint site, such as creating a list. If the action is successful, it indicates that the permissions are correctly granted. If not, it will result in an access denied error.

  • What is the role of a global administrator in granting the 'site.*selected' permission?

    -A global administrator or someone with 'designs.fullcontrol.all' permission is required to grant the 'site.*selected' permission to the target site collection, ensuring that the permission is correctly assigned and secure.

  • How can you revoke the 'site.*selected' permission that was granted to an application?

    -You can revoke the 'site.*selected' permission using the 'Revoke-PnPAzureADSitePermission' PowerShell cmdlet, providing the permission ID to remove the permission and revoke the grant.

  • What are the benefits of using resource-specific consent in Azure Active Directory?

    -Resource-specific consent allows you to target specific resources with application permissions, enhancing security by limiting the scope of access and reducing the need for broad permissions like 'site.fullcontrol.all'.

Outlines

00:00

🔒 Resource-Specific Consent in SharePoint Online

This paragraph discusses the concept of resource-specific consent in SharePoint Online and Microsoft Graph. It explains how to configure application permissions for a specific site or set of site collections, rather than the entire tenant, using the 'site.selected' permission. The speaker illustrates how this can be done without relying on Azure ACS, by directly using Azure Active Directory and Open Authorization. The process requires a global administrator or someone with 'designs.fullcontrol.all' permissions to grant the selected permission to the target site. The paragraph also covers how to grant permissions using Microsoft Graph and PowerShell, and the different levels of access that can be configured: read-only, write, manage, or full control.

05:01

🛠 Granting and Testing Permissions with PowerShell

The second paragraph delves into the technical process of granting permissions to an application using PowerShell. It explains how to connect to a specific site collection and grant permissions to an application with the 'site.selected' permission. The speaker demonstrates how to use the 'Grant-PnPAzureADSitePermission' PowerShell cmdlet to assign permissions and how to update them with 'Set-PnPAzureADSitePermission'. The paragraph also includes a practical test of these permissions using a .NET Framework console application, which attempts to access and manipulate SharePoint Online sites with and without the granted permissions. The results of these tests are expected to show access granted to the site with permissions and access denied for the site without permissions.

10:03

📝 Revoking Permissions and Additional Resources

The final paragraph wraps up the discussion by showing how to revoke permissions using the 'Revoke-PnPAzureADSitePermission' cmdlet in PowerShell. It emphasizes the powerful capability of targeting specific site collections with application-only permissions without needing the broad 'site.fullcontrol.all' permissions. The speaker also points out the successful creation of lists in the site with granted permissions and the inability to do so in the site without permissions. Lastly, the paragraph provides additional links for further exploration of the topic and concludes with a thank you note to the viewers.

Mindmap

Keywords

💡SharePoint Online

SharePoint Online is a cloud-based service that is part of the Microsoft Office 365 suite. It provides collaboration and document management features for businesses. In the video, SharePoint Online is central to the discussion as it is the platform for which the script discusses permissions and authentication mechanisms. The video mentions configuring permissions for SharePoint Online using application permissions and accessing it via Microsoft Graph.

💡Microsoft Graph

Microsoft Graph is a RESTful web API that enables developers to access Microsoft cloud service resources. It is used to interact with data from services like Azure Active Directory, Office 365, and more. In the script, Microsoft Graph is discussed in the context of obtaining access tokens and managing permissions for SharePoint Online.

💡Application Permission

Application permissions are a type of permission in Azure Active Directory that allow applications to access resources without a signed-in user's presence. The script specifically discusses the 'site.selected' application permission, which is used to restrict permissions to a specific site or set of site collections within SharePoint Online.

💡Certificate Authentication

Certificate authentication is a method of verifying an identity using a digital certificate. In the context of the video, it is used for authenticating applications against Azure Active Directory to access SharePoint Online resources. The script describes how to create and use a certificate for this purpose.

💡Azure Active Directory

Azure Active Directory (Azure AD) is a cloud-based identity and access management service. It is used to control access to applications and services while providing advanced capabilities like device management and identity protection. The script mentions Azure AD in relation to registering applications and managing permissions for SharePoint Online.

💡OAuth

OAuth is an open standard for access delegation, commonly used as a way for Internet users to grant websites or applications access to their information on other websites without giving them the passwords. The script refers to OAuth in the context of obtaining access tokens for SharePoint Online and Microsoft Graph.

💡Site Collection

A site collection in SharePoint is a group of SharePoint sites that share the same administrative settings, permission settings, and site templates. The video script discusses how to grant permissions to specific site collections rather than the entire tenant, using the 'site.selected' permission.

💡PnP PowerShell

PnP PowerShell is a set of PowerShell commands for SharePoint Online that simplifies the automation of common tasks. In the script, PnP PowerShell is used to grant permissions to a specific site collection and to create a certificate for authentication purposes.

💡Resource-Specific Consent

Resource-specific consent is a feature in Azure AD that allows permissions to be granted to an application for specific resources rather than for the entire service. The script explains how to use resource-specific consent for SharePoint Online and Microsoft Graph to grant permissions to a particular site collection.

💡API

API stands for Application Programming Interface, which is a set of routines, protocols, and tools for building software applications. In the video, the term API is used in the context of Microsoft Graph API, which is the interface used to access SharePoint Online and other Microsoft services programmatically.

💡Client Secret

A client secret is a secret known only to the application and the authorization server. It is used in OAuth 2.0 flows to authenticate the application with the authorization server. The script mentions using a client secret for application authentication with Microsoft Graph.

Highlights

Introduction to SharePoint Online and Microsoft Graph with specific consent permissions for application-level access control.

Explanation of using site-scoped permissions to restrict access to specific sites or site collections instead of the entire tenant.

How to configure site-scoped permissions for Microsoft Graph and SharePoint Online using Azure Active Directory.

The requirement of a global administrator or someone with 'designs.fullcontrol.all' permission to grant site-scoped permissions.

Demonstration of granting site-scoped permissions using Microsoft Graph API and PowerShell.

Creating a certificate for certificate authentication in Azure Active Directory using PowerShell cmdlets.

Uploading the public key (.cer file) of the certificate to Azure Active Directory for authentication.

Using the PM PowerShell cmdlet to connect to a SharePoint Online site and grant permissions to an application.

Testing application permissions by attempting to access and manipulate SharePoint Online sites with and without granted permissions.

Differences in behavior when accessing SharePoint Online with and without the required permissions.

Using .NET Framework console applications to test access to SharePoint Online sites with different permissions.

Code walkthrough of consuming SharePoint Online sites via Microsoft Graph SDK with client secret credentials.

Code walkthrough of consuming SharePoint Online sites via CSOM with certificate-based authentication.

Observing the outcome of list creation attempts in SharePoint Online with and without the necessary permissions.

Revoking previously granted permissions using PowerShell to demonstrate dynamic access control.

Practical application of site-scoped permissions to enhance security and control in SharePoint Online environments.

Additional resources and links for further exploration of the discussed topics.

Conclusion and thanks for watching the video on SharePoint Online and Microsoft Graph permissions.

Transcripts

play00:00

foreign

play00:09

specific consent permission for

play00:12

SharePoint online and Microsoft graph

play00:15

initial active directory we have an

play00:17

application permission called site dot

play00:20

selected that we can configure for

play00:23

micrograph and SharePoint online and

play00:25

when you do that for SharePoint online

play00:27

you need to get an access token with a

play00:30

certificate authentication against Azure

play00:33

active directory this permission for

play00:36

application is really useful whenever

play00:39

you want to have a set of permissions

play00:42

restricted to a specific site or set of

play00:46

site Collections and not to the whole

play00:48

tenant just to make an example it is

play00:51

something like what you used to do with

play00:53

the Azure access cardboard service when

play00:56

you registered an application in a Dean

play00:59

built with initial pointed in model just

play01:01

with permissions for a specific site

play01:04

collection nowadays we decide dot

play01:07

selected permission you can do the same

play01:09

without relying to Azure ACS but just

play01:14

relying on each directly directory and

play01:16

open authorization and you don't need

play01:19

anymore to provide the

play01:22

size.fullcontrol.all permission to your

play01:24

Azure active directory registered

play01:26

applications in order to being able to

play01:28

have access to a specific set collection

play01:31

with the elevated privileges whenever

play01:35

you do that you will require a global

play01:38

administrator or someone with

play01:42

designs.fullcontrol.all or an

play01:43

application with those permissions to

play01:46

Grant the selected permission to the

play01:47

Target site indeed that the requirement

play01:50

otherwise it would be an hack so

play01:54

when you use the

play01:57

scithe.selected permissions you need to

play01:59

Grant those permissions to a specific

play02:01

Target site collection either using a

play02:04

micrographing point or using PMP

play02:07

Powershell then you can simply use

play02:10

system or SPO rest and you can consume

play02:15

SharePoint and why consuming SharePoint

play02:18

you can configure the selected

play02:20

permission as read only write manage or

play02:25

full control

play02:26

this is a really powerful capability and

play02:30

let's move to the domain variant to see

play02:32

how to use it in practice

play02:36

in Azure active directory I registered

play02:38

an application in order to show you how

play02:40

the resource specific consent works this

play02:44

application is configured with

play02:46

certificate authentication as well as

play02:49

with client secret I have configured

play02:53

certificate authentication because as

play02:54

already said from a SharePoint online

play02:57

point of view if you want to consume

play02:59

SharePoint online with application only

play03:02

token you need to authenticate using an

play03:05

x509 certificate while decline secret

play03:08

can be used the one you want to rely on

play03:12

Microsoft graph in the API permission

play03:14

section for this application I simply

play03:17

have the size.selected application

play03:19

permission for graph and decide the

play03:22

selected application permission for

play03:24

SharePoint and you can find them by

play03:25

clicking on micrograph application

play03:27

permission and then you search for sites

play03:31

and you will find site dot selected and

play03:34

the same applies a for SharePoint so

play03:37

first of all how can you create a

play03:39

certificate for certificate

play03:40

authentication well you can rely on

play03:43

the PMP Powershell commandlets and you

play03:47

can use the new PMP Azure certificate

play03:49

which allows you to create a certificate

play03:52

to save the certificate as a pfx with

play03:55

private key and as a DOT Sir with just

play03:57

the public key and you can specify a

play04:00

password for your certificate so by

play04:02

doing that you will get back a

play04:03

certificate that you can upload from

play04:05

right here you click on certificate you

play04:07

upload the public key so the dot sir

play04:10

file and you are done and then of course

play04:12

you will also have to store in a safe

play04:14

place the private key of your

play04:16

certificate so now let's say that we

play04:18

want to use this application to access a

play04:21

Target site collection with a selected

play04:24

permission so I don't want to give the

play04:27

permission to see all of the site

play04:29

collection to this application but I

play04:31

simply want to Target a specific set

play04:33

collection or a specific set of site

play04:35

collections so here I have in SharePoint

play04:38

online one set collection which is

play04:40

called the site selected granted site

play04:43

and another one which is the site

play04:45

selected not granted site what I'm going

play04:48

to do here

play04:49

in the graph Explorer is to show you

play04:52

that right now from a permissions point

play04:55

of view in this target site I will query

play04:58

the permissions and I don't have any

play05:00

specific permission assigned to this set

play05:03

collection this is the endpoint that you

play05:06

can use in micrograph to read or assign

play05:09

permissions to an app whenever we have

play05:12

as the size dot selected application

play05:15

permission granted so now I want to use

play05:19

the PMP Powershell command lens to

play05:22

connect to the site selected granted

play05:24

site and to Grant a specific permission

play05:27

to my application so first of all I will

play05:31

connect to the Target side let's do that

play05:34

run selection and now I'm connected if I

play05:37

will do a get PMP Azure ID upside

play05:40

permissions we can see that right now as

play05:43

like as it was with graph Explorer we

play05:45

don't have any permission specific

play05:48

permission granted to any application

play05:50

but by using the grand PMP Azure ID up

play05:55

site permission commandlet providing the

play05:58

ID of the application that we have in

play06:01

Azure active directory so this is the

play06:05

application ID that we have right here

play06:07

and by

play06:09

providing a display name for this

play06:12

permission Grant the target URL of the

play06:15

site and a permission that we want to

play06:17

provide for example the right permission

play06:19

we will be able to Grant to that

play06:21

application so let me run the selection

play06:24

again we will be able to Grant to that

play06:26

application a specific permission this

play06:29

will be the unique ID of the permission

play06:32

that was granted to my application and

play06:35

if now I will make one more time a get

play06:37

of the permissions we can see that now

play06:39

we have one permission now you can also

play06:43

use the set PMP Azure ID upside

play06:46

permission providing the unique ID of

play06:48

the permission that you want to update

play06:50

and providing the new permission which

play06:53

can even be full control so if I will do

play06:55

that f8 to run the selection I now Grant

play06:59

it full control compare with the right

play07:02

permission that I granted initially now

play07:05

my application can only have full

play07:08

control targeting this specific selected

play07:11

site collection if I will Target any

play07:13

other set collection my application will

play07:15

not have any access permission okay so

play07:19

how can we test it well however

play07:22

an application based on.net framework

play07:26

through which we can try to access a

play07:30

Target site collection and right here

play07:32

this is a console application with

play07:34

dependency injection in place I have a

play07:37

consume SPO selected site via graph

play07:39

which I will try to use targeting a site

play07:42

where I have granted the permission and

play07:45

which I will try targeting a site where

play07:47

I have not granted the permissions to

play07:49

see how the behavior will change and we

play07:52

do the same with SharePoint online via

play07:55

season instead of graph so that you can

play07:58

also see how it behaves when you use

play08:00

season so the consume SPO selective site

play08:04

via graph is a really simple method we

play08:08

can dig into it so we can see what's

play08:11

inside of it and we can see that we

play08:15

simply use

play08:16

a client's secret credential object to

play08:20

authenticate with Microsoft graph SDK to

play08:24

get access to the site that we have in

play08:26

Target so we say graph client dot size

play08:31

and we get a site by path and we try to

play08:35

create a new list in the Target site you

play08:39

see we create a new list object of

play08:42

micrograph SDK and then we add

play08:43

asynchronously the new list and of

play08:45

course if we can successfully at the

play08:47

list it means that we have proper

play08:49

permissions if not it means that we are

play08:51

not granted the permission to work

play08:53

targeting that site and the same logic

play08:57

but with season is in the consumers peer

play09:00

selected site by a season where we get

play09:03

through the PMP framework Library the

play09:07

authentication manager and we use the

play09:09

create with certificate method of the

play09:12

authentication manager of PMP framework

play09:14

to get a season client context for

play09:16

providing the x509 certificate to

play09:19

authenticate against Azure ID and then

play09:22

we see if the current user is an admin

play09:25

or not just for the sake of it and then

play09:28

we try to create a new instance of a

play09:31

list still using season as like as we

play09:33

did with graph but now using system and

play09:36

we execute the query and again if it

play09:38

will be successfully created it means

play09:40

that we have proper permissions if not

play09:42

we will get a failure and we will see

play09:44

what the behavior will be so let me

play09:47

execute this application now that we

play09:50

have the permissions granted to the

play09:52

first side that I showed you so Ctrl F5

play09:55

this is the console application running

play09:57

as you can see here I start the

play10:00

application I start consuming the site

play10:03

selected granted site with selected

play10:05

permission via micrograph and I can

play10:08

successfully add a list to the site and

play10:10

we will see the list shortly then when

play10:12

we try to do the same with the site

play10:14

selected not granted site we will get an

play10:17

access denied because the current

play10:19

application does not have access to the

play10:21

site not granted side

play10:23

and the same applies for season so when

play10:26

we try to use season to create a list

play10:30

that we successfully do that targeting

play10:33

the site where we have got the

play10:36

permissions granted and we fail and we

play10:39

cannot create the list in the other side

play10:42

and we get an attempt to perform in an

play10:44

authorized operation if I will go back

play10:47

to my SharePoint site we can go to site

play10:50

contents and we can see that right here

play10:52

we have the generated via micrograph and

play10:55

degenerative biasism lists in this site

play10:58

selected with granted permissions while

play11:00

in the site contents of this site we

play11:03

don't have any list because we were not

play11:05

able to create such a content of course

play11:09

if you want to later on get rid of the

play11:12

permissions you can also use the revoke

play11:14

PMP Azure ID up site permissions

play11:17

providing the permission ID and you will

play11:19

be able to remove the permission and

play11:21

revoke the grind this is a really

play11:23

powerful capability because you will be

play11:26

able to Target just specific site

play11:29

collector with application only without

play11:31

the need to have any more decide dot

play11:34

full control dot all permission that we

play11:36

used to use in the past in application

play11:38

only to consume SharePoint online size

play11:42

here you can see additional links if you

play11:45

want to dig into the topic covered and

play11:48

like always thank you for watching this

play11:50

video

play11:50

foreign

Rate This

5.0 / 5 (0 votes)

Related Tags
SharePoint OnlineMicrosoft GraphAzure ADCertificate AuthSite PermissionsAPI AccessSecurityOAuthPowershellSPO ManagementResource Consent