ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o...

26
Koushik Hajra & Xueming Wu ArcGIS Runtime: Authenticating Your Apps with the ArcGIS Platform

Transcript of ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o...

Page 1: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Koushik Hajra & Xueming Wu

ArcGIS Runtime: Authenticating Your Apps with the ArcGIS Platform

Page 2: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Agenda

➢ Introductiono When is Authentication needed

o Authentication Manager

➢ Authenticating a Usero Authentication Challenges

o Authentication Challenge Handler UI OAuth

➢ Caching User Credentials

Page 3: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Introduction

Page 4: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Introduction

➢ When is authentication neededo Access a user’s private content

o Create and publish content

o Access premium content on ArcGIS Online

➢ Authentication Modeso OAuth 2.0

o Token-based

o Public Key Infrastructure (PKI)

o HTTP/Windows Authentication (HTTP basic, HTTP digest or Integrated Windows Authentication(IWA))

Page 5: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Goals for Authentication API

○ Less code

○ Central logic

■ Avoid different failure points

■ Do it once and in one place

o Handle all authentication modes

o Common pattern in Runtime SDKs

Page 6: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Authentication Manager

○ Central place and go-to class for■ Set an authentication challenge handler

■ Manage OAuth configurations

■ Manage client/server certificates

■ Manage in-memory credential cache

o Singleton

o Guide Doc https://developers.arcgis.com/android/latest/guide/access-the-arcgis-platform.htm

https://developers.arcgis.com/ios/latest/swift/guide/access-the-arcgis-platform.htm

https://developers.arcgis.com/net/latest/wpf/guide/access-the-arcgis-platform.htm

https://developers.arcgis.com/qt/latest/qml/guide/access-the-arcgis-platform.htm

https://developers.arcgis.com/java/latest/guide/access-the-arcgis-platform.htm

Page 7: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Authentication Manager

Page 8: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Demo:Authentication Manager

Page 9: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Authenticating A User

Page 10: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Authentication Process

Server or PortalAuthentication

ManagerChallenge

Page 11: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Authentication Challenge

➢ Authentication Challenge

○ Is created when due to inability to authenticate

○ Contains information such as exception, credential, URL and number of trials

○ Is issued to an authentication challenge handler

○ Can be turned on/off through RequestConfiguration

Page 12: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Authentication Challenge

➢ Types of Challenges○ Username / password

○ OAuth

○ Client Certificate

○ Untrusted Host

➢ Challenge Actions○ Provide Username / password

○ Provide OAuth token

○ Provide Client Certificate

○ Trust a Host

○ Cancel

➢ Handling Challenge○ Default handler

○ Custom handler

○ Extend and override

Page 13: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Handling Challenge - Default Handler

○ UX for challenge○ Credentials (username / password, token, client certificate)○ Self-signed server certificate

Page 14: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

OAuth 2.0

➢ Have you heard about OAuth?

➢ Authentication patternso Named User login

Allow ArcGIS Online users to authorize your application on their behalf

ArcGIS Online prompts for credentials

o App login

App uses hard-coded credential to log

Users access content on your behalf

Page 15: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

OAuth 2.0 – Named User Login

➢ Two steps processo Authorization → authorization code

Client ID

Redirect URI

Refresh token expiration(optional)

o Exchange code for tokens (access & refresh)

➢ Access token & refresh token○ Refresh access token

Short lived access token (30 minutes)

Refresh using refresh token

○ Exchange refresh token

Refresh token: 2 weeks ~ 90 days

Exchange refresh token every 24 hours by default

Page 16: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

OAuth 2.0 – Named User Login

➢ Working with default handler

○ Create OAuthConfiguration

Client ID

Redirect URI

Refresh token expiration(optional)

○ Add to AuthenticationManager

➢ Support social login

Page 17: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Demo:OAuth

Page 18: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Handling Challenge - Custom Handler

➢ Platform specific workflow

➢ Android / Java SDKs

○ Implement AuthenticationChallengeHandler

○ Override handleChallenge()

○ Set AuthenticationChallengeHandler on AuthenticationManager

○ Implement UI

Page 19: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Demo:Custom Handler

Page 20: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Caching User Credentials

Page 21: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Credential Cache

o In memory cache

Enabled by default

o Global

Reusable by objects in the same domain

o Persist credentials:

Between user sessions

Between apps

Between devices

Page 22: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Credential Cache

➢ Persist credentialso Android & Java SDKs

Persist Credential Cache to json string

Developer is responsible to encrypt the json string

o iOS SDK – Sync Credential Cache to Keychain

o Qt SDK – persist credential to json string

➢ Remove & revoke credentials

Page 23: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Demo:Credential Cache

Page 24: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Offline content security

➢ Unsecured Mobile Map Package (MMPK)

➢ Unsecured extracted geodatabase on disk

Page 25: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Summary

➢ Introductiono When is Authentication needed

o Authentication Manager

➢ Authenticating a Usero Authentication Challenges

o Authentication Challenge Handler UI OAuth

➢ Caching User Credentials

Page 26: ArcGIS Runtime: Authenticating Your Apps with the ArcGIS ... · When is authentication needed o Access a user’s private content o Create and publish content o Access premium content

Thank you!

GeoNet:

https://community.esri.com/community/developers/native-app-developers