Deep dive into security and o auth in apps for share-point

71
Curso Desarrollo Office 365 Marzo 2015

Transcript of Deep dive into security and o auth in apps for share-point

Page 1: Deep dive into security and o auth in apps for share-point

Curso Desarrollo Office 365Marzo 2015

Page 2: Deep dive into security and o auth in apps for share-point

Deep Dive into Security and OAuth

Alberto Diaz Martin (@adiazcan)Principal Team Leader en ENCAMINAMVP de SharePoint Server

Page 3: Deep dive into security and o auth in apps for share-point

Azure Active DirectoryOAuth PrimerDevelopment Scenarios

Agenda

Page 4: Deep dive into security and o auth in apps for share-point

Azure Active Directory

Page 5: Deep dive into security and o auth in apps for share-point

5

Identity and Access Management for the cloud

Can create new directories or manage existing ones in Azure subscription

Used by Office 365 for authentication

Used by Azure for user authentication and application authorization

Azure Active Directory

Page 6: Deep dive into security and o auth in apps for share-point

6

Term for User Accounts in AAD

Required to Access Microsoft Cloud Services

Tenant-Based

Organizational Accounts

Page 7: Deep dive into security and o auth in apps for share-point

7

Log into Microsoft Azure subscription as administrator

Click on the Active Directory link.

Click New>Active Directory>Directory>Custom Create

Select to Add an Existing Directory

Follow the steps to add an existing directory

Link Office 365 and Azure

Page 8: Deep dive into security and o auth in apps for share-point

8

User Authentication

Page 9: Deep dive into security and o auth in apps for share-point

9

User Authentication

User attempts to accessSharePoint online resource

Page 10: Deep dive into security and o auth in apps for share-point

10

User Authentication

Redirected to login.microsoftonline.com

Page 11: Deep dive into security and o auth in apps for share-point

11

User Authentication

Login withOrganizational Account

Page 12: Deep dive into security and o auth in apps for share-point

12

User Authentication

Issue SAML token

Page 13: Deep dive into security and o auth in apps for share-point

13

User Authentication

Present token

Page 14: Deep dive into security and o auth in apps for share-point

14

User Authentication

Return FedAuth cookie

Page 15: Deep dive into security and o auth in apps for share-point

15

User Authentication

Subsequent requestsUtilize FedAuth cookie

Page 16: Deep dive into security and o auth in apps for share-point

OAuth Primer

Page 17: Deep dive into security and o auth in apps for share-point

17

Simple mechanism to grant a third party access to a user’s resources without sharing the user’s password.

Cross platform app authorization

Internet Standard supported by Azure, Facebook, Google, Twitter, and more

What is OAuth 2.0?

Page 18: Deep dive into security and o auth in apps for share-point

18

Client: application requesting access to a user’s resources

Resource Owner: the user who can grant rights to the application

Resource Server: the server hosting the protected resources and exposing a web-based API

Authorization Server – server issuing tokens

OAuth 2.0 Actors

Page 19: Deep dive into security and o auth in apps for share-point

19

Client: SharePoint app, Azure web application, Windows 8 app

Resource Owner: individual or administrator with an Organizational Account in Azure Active Directory

Resource Server: SharePoint, Exchange

Authorization Server: Azure Access Control Services

OAuth 2.0 Actors in Office 365

Page 20: Deep dive into security and o auth in apps for share-point

20

Client ID is used to uniquely identify applications

Client Secret is used to authenticate token requests

Application Principals

Page 21: Deep dive into security and o auth in apps for share-point

21

Context TokenInformation about the Resources Owner and Client that can be used to get an Access Token later.

Refresh TokenA token used to get an Access Token from the Authorization Server.

Access TokenA token passed to the Resource Server authorizing the Client to access resources.

Authorization CodeA code that can be used to register an app on-the-fly.

OAuth 2.0 Tokens

Page 22: Deep dive into security and o auth in apps for share-point

22

OAuth 2.0 Access Tokens are unbound tokens (a.k.a, “Bearer Tokens”)

• An Access Token can be used by any application that possesses it

• Always use SSL – OAuth design depends on it!

• Never expose tokens in JavaScript or allow them to be accessed by client-side debugging tools

• If an Access Token is compromised, damage is limited by expiration

• If a Refresh Token is compromised, damage is limited because the Client ID and Client Secret are required to get an Access Token from a Refresh Token.

Bearer Tokens

Page 23: Deep dive into security and o auth in apps for share-point

Development Scenarios

Page 24: Deep dive into security and o auth in apps for share-point

Provider-Hosted Apps

Development Scenarios

Page 25: Deep dive into security and o auth in apps for share-point

25

Apps must be registered with SharePoint onlineClient ID – generated during the registration processClient Secret – generated during the registration processApp Host Domain – the domain of the Azure web site hosting the appRedirect URL – the URL of the return page after permissions are granted

SharePoint provides registration management pagesAppRegNew.aspx – for registering a new appAppInv.aspx – for updating registered appsAppPrincipals.aspx – lists all registered apps

App Principals

Page 26: Deep dive into security and o auth in apps for share-point

26

Registering a New App

Generated value

Generated value

Free text value

Azure domain (e.g., myapp.azurewebsites.net)Web address (e.g., https://myapp.azurewebsites.net)

Page 27: Deep dive into security and o auth in apps for share-point

27

User has Organizational Account

App registered with SharePoint Online

App deployed to SharePoint Online

Remote Web deployed as an Azure Website

Client ID and Client Secret defined in AAD

Provider-Hosted App Flow Scenario

Page 28: Deep dive into security and o auth in apps for share-point

28

OAuth 2.0 Flow Provider-Hosted App

End User(Resource Owner)

Azure ACS(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Page 29: Deep dive into security and o auth in apps for share-point

29

OAuth 2.0 Flow Provider-Hosted App

End User(Resource Owner)

Azure ACS(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

User launches app

Page 30: Deep dive into security and o auth in apps for share-point

30

OAuth 2.0 Flow Provider-Hosted App

End User(Resource Owner)

Azure ACS(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Request Context token for user

Page 31: Deep dive into security and o auth in apps for share-point

31

OAuth 2.0 Flow Provider-Hosted App

End User(Resource Owner)

Azure ACS(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Context Token returned

Page 32: Deep dive into security and o auth in apps for share-point

32

OAuth 2.0 Flow Provider-Hosted App

End User(Resource Owner)

Azure ACS(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Context Token returnedand user redirected to app

Page 33: Deep dive into security and o auth in apps for share-point

33

OAuth 2.0 Flow Provider-Hosted App

End User(Resource Owner)

Azure ACS(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

App extracts Refresh Token from Context Token

Page 34: Deep dive into security and o auth in apps for share-point

34

OAuth 2.0 Flow Provider-Hosted App

End User(Resource Owner)

Azure ACS(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

App requests Access Tokenusing refresh Token

Page 35: Deep dive into security and o auth in apps for share-point

35

OAuth 2.0 Flow Provider-Hosted App

End User(Resource Owner)

Azure ACS(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Access Token returned

Page 36: Deep dive into security and o auth in apps for share-point

36

OAuth 2.0 Flow Provider-Hosted App

End User(Resource Owner)

Azure ACS(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Access Token presentedAlong with request

Page 37: Deep dive into security and o auth in apps for share-point

37

OAuth 2.0 Flow Provider-Hosted App

End User(Resource Owner)

Azure ACS(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Response returned

Page 38: Deep dive into security and o auth in apps for share-point

SharePointAcsContext Class• Inherits SharePointContext• Provides specific properties and methods for

dealing with context and access tokens• CSOM

CreateAppOnlyClientContextForSPAppWeb CreateAppOnlyClientContextForSPHost CreateUserClientContextForSPAppWeb CreateUserClientContextForSPHost

• REST AppOnlyAccessTokenForSPAppWeb AppOnlyAccessTokenForSPHost UserAccessTokenForSPAppWeb UserAccessTokenForSPHost

Page 39: Deep dive into security and o auth in apps for share-point

Making REST Calls with OAuth

Page 40: Deep dive into security and o auth in apps for share-point

Making CSOM Calls with OAuth

Page 41: Deep dive into security and o auth in apps for share-point

PROVIDER-HOSTED APP

demo

Page 42: Deep dive into security and o auth in apps for share-point

Office 365 APIs

Development Scenarios

Page 43: Deep dive into security and o auth in apps for share-point

43

User has Organizational Account

Application deployed as an Azure Web Site

Application does not require explicit permission grant

Office 365 APIS Flow Scenario

Page 44: Deep dive into security and o auth in apps for share-point

44

OAuth 2.0 Flow Office 365 APIs

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Page 45: Deep dive into security and o auth in apps for share-point

45

OAuth 2.0 Flow Office 365 APIs

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

User accessesWeb application

Page 46: Deep dive into security and o auth in apps for share-point

46

OAuth 2.0 Flow Office 365 APIs

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Redirected to AAD

Page 47: Deep dive into security and o auth in apps for share-point

47

OAuth 2.0 Flow Office 365 APIs

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Consent dialogdisplayed

Page 48: Deep dive into security and o auth in apps for share-point

48

OAuth 2.0 Flow Office 365 APIs

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Grant access usingConsent Dialog

Page 49: Deep dive into security and o auth in apps for share-point

49

OAuth 2.0 Flow Office 365 APIs

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Auth Codereturned and

user redirected

Page 50: Deep dive into security and o auth in apps for share-point

50

OAuth 2.0 Flow Office 365 APIs

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Auth Code, App Id, App Secret

sent

Page 51: Deep dive into security and o auth in apps for share-point

51

OAuth 2.0 Flow Office 365 APIs

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Access and RefreshTokens returned

Page 52: Deep dive into security and o auth in apps for share-point

52

OAuth 2.0 Flow Office 365 APIs

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Access Token presentedAlong with request

Page 53: Deep dive into security and o auth in apps for share-point

53

OAuth 2.0 Flow Office 365 APIs

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Response returned

Page 54: Deep dive into security and o auth in apps for share-point

Automatically determine URL of Office 365 services

Supports device app and website flows

Secured using Azure AD authentication

Serves information stored about services in AAD

Office 365 discovery services

Page 55: Deep dive into security and o auth in apps for share-point

AadGraphClient – Azure Active Directory

ExchangeClient – Calendar, Contacts, Mail

SharePointClient - Files

Office 365 Clients

55

Page 56: Deep dive into security and o auth in apps for share-point
Page 57: Deep dive into security and o auth in apps for share-point

OAuth Controller

Development Scenarios

Page 59: Deep dive into security and o auth in apps for share-point

59

User has Organizational Account

App deployed as an Azure Web Site

App registered with Azure Active Directory

Client ID and Client Secret defined in AAD

Permissions granted specifically in AAD

OAuth Controller Flow Scenario

Page 60: Deep dive into security and o auth in apps for share-point

60

OAuth 2.0 Flow OAuth Controller

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Page 61: Deep dive into security and o auth in apps for share-point

61

OAuth 2.0 Flow OAuth Controller

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

User accessesWeb application

Page 62: Deep dive into security and o auth in apps for share-point

62

OAuth 2.0 Flow OAuth Controller

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Redirected to AAD

Page 63: Deep dive into security and o auth in apps for share-point

63

OAuth 2.0 Flow OAuth Controller

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Auth Codereturned and

user redirected

The consent form is not utilized when permissions are explicitly granted in AAD.

Page 64: Deep dive into security and o auth in apps for share-point

64

OAuth 2.0 Flow OAuth Controller

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Auth Code, App Id, App Secret

sent

Page 65: Deep dive into security and o auth in apps for share-point

65

OAuth 2.0 Flow OAuth Controller

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Access and RefreshTokens returned

Page 66: Deep dive into security and o auth in apps for share-point

66

OAuth 2.0 Flow OAuth Controller

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Access Token presentedAlong with request

Page 67: Deep dive into security and o auth in apps for share-point

67

OAuth 2.0 Flow OAuth Controller

End User(Resource Owner)

Azure Active Directory(Authorization Server)

Azure Web Site(Client)

SharePoint Online(Resource Server)

Response returned

Page 68: Deep dive into security and o auth in apps for share-point

68

Programming the OAuth Controller

Page 69: Deep dive into security and o auth in apps for share-point

OAUTH CONTROLLER

demo

Page 70: Deep dive into security and o auth in apps for share-point

70

Azure Active Directory

OAuth Primer

Development Scenarios

Summary

Page 71: Deep dive into security and o auth in apps for share-point

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.