CHAPTER 6
With SharePoint 2013, the default authentication mode is the claim-based authentication mode, which has been present, but optional, since SharePoint 2010. The classic authentication mode has been deprecated.
With the introduction of claim-based authentication, you can support several authentication and authorization scenarios, such as app requirements, all thanks to the presence of a Security Token Service (STS).
In claim-based authentication, by default, the authentication provider generates a security token that contains a set of claims that describe the user’s authentication, and when a user logs on to a website, the user's token is validated and then used to access SharePoint. The user's token is a secure token issued by an identity provider.
All of this is also possible by using a protocol called OAuth.
OAuth is an open protocol for authorization. OAuth enables secure authorization from desktop and web apps in a simple and standard way. OAuth enables users to approve an app to act on their behalf without sharing their user name and password.
For example, it enables users to share their private resources or data (contact list, documents, photos, videos, and so on) that are stored on one site with another site, without users having to provide their credentials (typically, user name and password).
OAuth enables users to authorize the service provider (in this case, SharePoint 2013) to provide tokens instead of credentials (for example, user name and password) to their data that is hosted by a given service provider (that is, SharePoint 2013).
Each token grants access to a specific site (for example, a SharePoint document repository) for specific resources (such as documents from a folder) and for a defined duration, say 30 minutes. This enables a user to grant a third-party site access to information that is stored with another service provider (in this case, SharePoint), without sharing their user name and password, and without sharing all the data that they have on SharePoint.
The OAuth protocol is used to authenticate and authorize apps and services. The OAuth protocol is used:
If the apps and services that you build for SharePoint 2013 do not require the previous authentication approach, you do not have to use the OAuth protocol when you create your apps and services.
If you plan to build an app for SharePoint that runs in a remote web app and communicates back to SharePoint 2013, you will need to use OAuth.
In SharePoint 2013, a typical app for SharePoint usage scenario is as follows:

The authorization process verifies that an authenticated subject (an app or a user the app is acting on behalf of) has permission to perform certain operations or to access specific resources (for example, a list or a SharePoint document folder).
SharePoint 2013 provides three types of authorization policies. The authenticated identities on the call determine which authorization policy is used.
The authenticated identities can be:
The authorization policy can be:
For example, if the user+app policy is used, both the app and the user the app is acting on behalf of must have permissions to the resources being accessed. In the case of app-only policies, the access check only goes against the app's rights. In Figure 25, you can analyze the security flow that the SharePoint Engine uses for user authentication.

The permissions that the app must have in order to work are defined within the AppManifest.xml file and are defined by three values:

Here are the same permissions in XML format:
<AppPermissionRequests> <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="Read" /> <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web/list" Right="FullControl"> <Property Name="BaseTemplateId" Value="101"/> </AppPermissionRequest> <AppPermissionRequest Scope="http://sharepoint/search" Right="QueryAsUserIgnoreAppPrincipal" /> </AppPermissionRequests> |
But how do permissions work? Take a look at Figure 27.

An app permission request contains a scope attribute and a right attribute. The scope attribute contains a string that includes the following pieces of information:
The right attribute defines the type of permission being requested. SharePoint standardizes four basic rights: Read, Write, Manage and FullControl.However, some permission types, such as search permissions, use specialized permissions like QueryAsUserIgnoreAppPrincipal.
The flag on the page allows you to choose which type of permits the app must have:
In this chapter, we learned about authentication and authorization in SharePoint 2013. We have also learned about app permissions; it’s very important to be able to access the code of the app with resources that SharePoint offers through the CSOM or REST API.