SlideShare a Scribd company logo
Securing RESTful APIs
Using OAuth 2 and OpenID Connect
Jonathan LeBlanc (@jcleblanc)
Global Head of Developer
Evangelism at PayPal
Why do we Need This?
Poor Password Choices
•

4.7% of users have the password password;

•

8.5% have the passwords password or 123456;

•

9.8% have the passwords password, 123456 or
12345678;

•

14% have a password from the top 10 passwords

•

40% have a password from the top 100 passwords

•

79% have a password from the top 500 passwords

•

91% have a password from the top 1000 passwords
…And of What’s Left
1. Pet’s name
2. Significant dates (like a wedding anniversary)
3. Date of birth of close relation
4. Child’s name
5. Other family member’s name
6. Place of birth
7. Favorite holiday
8. Something related to favorite football team
9. Current partner’s name
Handing Over Account Passwords
Malicious Applications
Aspects of Revocation
App Revoked by User

App Revoked by
Service Provider
Path to the Standard
Username & Password to Auth
Rise of the Token
Two Widely Used Specifications
REST Request Components
How Requests are Made
curl -v
https://api.sandbox.paypal.com/v1/payments/payme
nt 
-H "Content-Type:application/json" 
-d '{
"intent": "sale",
"payer": { ... },
"transactions": [{
"amount": { ... }
}]
}'
How Auth is Added in

curl -v
https://api.sandbox.paypal.com/v1/payments/payment 
-H "Content-Type:application/json" 
-H "Authorization: Bearer {accessToken}" 
-d '{
"intent": "sale",
"payer": { ... },
"transactions": [{
"amount": { ... }
}]
}'
Attack Vectors
Man in the Middle

Replay Attacks
Cross-Site Request
Forgery (CSRF)
Adding in the Auth
Reasons for Auth
Rate Limiting and Attack Vector Protection
Having the ability to revoke application
access
Needing to allow users to revoke an
applications access to their data
When You Need Access Security
User Login
(authentication)

User Involvement
(authorization)

Application Only
(monitoring)
Practical Implementation
Redirect the User to Log In
Prepare the Redirect URI
Authorization Endpoint
client_id response_type (token)
scope
redirect_uri

Browser Redirect
Redirect URI
Fetching the Access Token
Fetch the Access Token
Access Token Endpoint
client_id
grant_type
client_secret
code

HTTP POST
Access Token Endpoint
Fetching the Access Token

curl https://api.sandbox.paypal.com/v1/oauth2/token 
-H "Accept: application/json" 
-H "Accept-Language: en_US" 
-u "EOJ2S-Z6OoN_le_K:S1d75wsZ6y0SFd…" 
-d "grant_type=client_credentials"
Access Token Response
{
"scope": "https://api.paypal.com/v1/payments/.*
https://api.paypal.com/v1/vault/credit-card",
"access_token": "EEwJ6tF9x5WCIZDYzyZGaz6K…",
"token_type": "Bearer",
"app_id": "APP-6XR95014SS315863X",
"expires_in": 28800
}
Using the Access Token
Fetch Privileged Resources
Resource Endpoint
Token Type (Authorization header)
Access Token (Authorization header)

HTTP GET / PUT / POST /
DELETE
Resource Endpoint
Using the Access Token

curl -v
https://api.sandbox.paypal.com/v1/payments/payment

-H "Content-Type:application/json" 
-H "Authorization:Bearer EMxItHE7Zl4cMdkv…" 
-d "{...}"
Maintaining SDK Consistency
Defining APIs with WADL / WSDL
<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="http://www.w3.org/ns/wsdl" ...>
<types> … </types>
<interface name="Interface1"> … </interface>
<binding name="HttpBinding" interface="tns:Interface1”>
<operation ref="tns:Get" whttp:method="GET"/>
</binding>
<binding name="SoapBinding" interface="tns:Interface1" …>
<operation ref="tns:Get" />
</binding>

<service name="Service1" interface="tns:Interface1">
<endpoint name="HttpEndpoint" binding="tns:HttpBinding"
address="http://www.example.com/rest/"/>
<endpoint name="SoapEndpoint" binding="tns:SoapBinding"
address="http://www.example.com/soap/"/>
</service>
</description>
<?xml version="1.0"?>
<application xmlns:xsi=…>
<grammars>
<include href="NewsSearchResponse.xsd"/>
<include href="Error.xsd"/>
</grammars>

<resources base="http://api.search.yahoo.com/NewsSearchService/V1/">
<resource path="newsSearch">
<method name="GET" id="search">
<request>
<param name="appid" type="xsd:string" required="true"/>
<param name="query" type="xsd:string" required="true"/>
</request>
<response status="400">
<representation mediaType="application/xml" element="ya:Error"/>
</response>
</method>
</resource>
</resources>
</application>
Genio (templates)
https://github.com/paypal/genio

Genio Parser (model builder)
https://github.com/paypal/genio-parser

Genio Samples
https://github.com/paypal/genio-sample

Building SDKs Automatically
Final Considerations
REST and OAuth are specifications,
not religions
Don’t alienate your developers
with security
Open source is your friend
Thank You! Questions?
http://slideshare.net/jcleblanc
Jonathan LeBlanc (@jcleblanc)
Global Head of Developer
Evangelism at PayPal

More Related Content

PPTX
A10 - Unvalidated Redirects and Forwards
PDF
Facebook data breach and OAuth2
PPT
Security 101
PPTX
Securing your APIs with OAuth, OpenID, and OpenID Connect
PDF
Stateless authentication for microservices - GR8Conf 2015
PPTX
OAuth2 + API Security
PPTX
Securing RESTful APIs using OAuth 2 and OpenID Connect
PPTX
Securing RESTful Payment APIs Using OAuth 2
A10 - Unvalidated Redirects and Forwards
Facebook data breach and OAuth2
Security 101
Securing your APIs with OAuth, OpenID, and OpenID Connect
Stateless authentication for microservices - GR8Conf 2015
OAuth2 + API Security
Securing RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful Payment APIs Using OAuth 2

What's hot (20)

PDF
Pentesting RESTful webservices
PPTX
A8 cross site request forgery (csrf) it 6873 presentation
PDF
CIS14: OAuth and OpenID Connect in Action
PDF
Owasp eee 2015 csrf
ODP
Mohanraj - Securing Your Web Api With OAuth
PPTX
A simple PHP LinkedIn OAuth 2.0 example
PPTX
Best Practices in Building an API Security Ecosystem
PPTX
Secure Code Warrior - Issues with origins
PPTX
Owasp web security
PPTX
Oauth2 and OWSM OAuth2 support
PDF
Top 10 Web App Security Risks
PPTX
Single-Page-Application & REST security
PPTX
An Introduction to OAuth2
PPTX
Token Authentication for Java Applications
PPTX
Transient client secret extension
PPTX
O auth2.0 20141003
PDF
Stateless Auth using OAuth2 & JWT
PDF
How to authenticate users in your apps using FI-WARE Account - Introduction
PPT
Silicon Valley Code Camp 2009: OAuth: What, Why and How
Pentesting RESTful webservices
A8 cross site request forgery (csrf) it 6873 presentation
CIS14: OAuth and OpenID Connect in Action
Owasp eee 2015 csrf
Mohanraj - Securing Your Web Api With OAuth
A simple PHP LinkedIn OAuth 2.0 example
Best Practices in Building an API Security Ecosystem
Secure Code Warrior - Issues with origins
Owasp web security
Oauth2 and OWSM OAuth2 support
Top 10 Web App Security Risks
Single-Page-Application & REST security
An Introduction to OAuth2
Token Authentication for Java Applications
Transient client secret extension
O auth2.0 20141003
Stateless Auth using OAuth2 & JWT
How to authenticate users in your apps using FI-WARE Account - Introduction
Silicon Valley Code Camp 2009: OAuth: What, Why and How
Ad

Viewers also liked (6)

PPTX
The Upheaval of Open Commerce
PPTX
Patologia benigna de estomago
PPTX
Building on Social Application Platforms
PPTX
Facebook for the Floundering
PDF
OAuth2 and LinkedIn
PDF
Salem State College's Employee Handbook
The Upheaval of Open Commerce
Patologia benigna de estomago
Building on Social Application Platforms
Facebook for the Floundering
OAuth2 and LinkedIn
Salem State College's Employee Handbook
Ad

Similar to Securing RESTful APIs using OAuth 2 and OpenID Connect (20)

PDF
REST API Authentication Methods.pdf
PPTX
Designing JavaScript APIs
PDF
Securing APIs with OAuth 2.0
PPTX
Securing APIs using OAuth 2.0
PPT
Securing RESTful API
PDF
API Security In Cloud Native Era
PPTX
Devteach 2017 OAuth and Open id connect demystified
PDF
OAuth Base Camp
PDF
Understanding Authentication and Authorization in RESTful API: A Comprehensiv...
PPTX
Secure RESTful API Automation With JavaScript
PDF
Open Identity - getting to know your users
PDF
Authentication and authorization in res tful infrastructures
PPTX
Protecting your APIs with Doorkeeper and OAuth 2.0
PDF
PayPal Access GDG DevFest
PDF
O auth2.0 guide
PPTX
Id fiware upm-dit
PDF
Beyond API Authorization
PPTX
OAuth
PDF
Security for oauth 2.0 - @topavankumarj
PDF
Saadhvi Summit - oAuth Standards
REST API Authentication Methods.pdf
Designing JavaScript APIs
Securing APIs with OAuth 2.0
Securing APIs using OAuth 2.0
Securing RESTful API
API Security In Cloud Native Era
Devteach 2017 OAuth and Open id connect demystified
OAuth Base Camp
Understanding Authentication and Authorization in RESTful API: A Comprehensiv...
Secure RESTful API Automation With JavaScript
Open Identity - getting to know your users
Authentication and authorization in res tful infrastructures
Protecting your APIs with Doorkeeper and OAuth 2.0
PayPal Access GDG DevFest
O auth2.0 guide
Id fiware upm-dit
Beyond API Authorization
OAuth
Security for oauth 2.0 - @topavankumarj
Saadhvi Summit - oAuth Standards

More from Jonathan LeBlanc (20)

PDF
JavaScript App Security: Auth and Identity on the Client
PDF
Improving Developer Onboarding Through Intelligent Data Insights
PDF
Better Data with Machine Learning and Serverless
PPTX
Best Practices for Application Development with Box
PPTX
Box Platform Overview
PPTX
Box Platform Developer Workshop
PPTX
Modern Cloud Data Security Practices
PPTX
Box Authentication Types
PPTX
Understanding Box UI Elements
PPTX
Understanding Box applications, tokens, and scoping
PPTX
The Future of Online Money: Creating Secure Payments Globally
PDF
Modern API Security with JSON Web Tokens
PPTX
Creating an In-Aisle Purchasing System from Scratch
PDF
Secure Payments Over Mixed Communication Media
PDF
Protecting the Future of Mobile Payments
PDF
Node.js Authentication and Data Security
PDF
PHP Identity and Data Security
PPTX
Secure Payments Over Mixed Communication Media
PDF
Protecting the Future of Mobile Payments
PPTX
Future of Identity, Data, and Wearable Security
JavaScript App Security: Auth and Identity on the Client
Improving Developer Onboarding Through Intelligent Data Insights
Better Data with Machine Learning and Serverless
Best Practices for Application Development with Box
Box Platform Overview
Box Platform Developer Workshop
Modern Cloud Data Security Practices
Box Authentication Types
Understanding Box UI Elements
Understanding Box applications, tokens, and scoping
The Future of Online Money: Creating Secure Payments Globally
Modern API Security with JSON Web Tokens
Creating an In-Aisle Purchasing System from Scratch
Secure Payments Over Mixed Communication Media
Protecting the Future of Mobile Payments
Node.js Authentication and Data Security
PHP Identity and Data Security
Secure Payments Over Mixed Communication Media
Protecting the Future of Mobile Payments
Future of Identity, Data, and Wearable Security

Recently uploaded (20)

PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Cloud computing and distributed systems.
DOCX
The AUB Centre for AI in Media Proposal.docx
PPT
Teaching material agriculture food technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Spectral efficient network and resource selection model in 5G networks
Assigned Numbers - 2025 - Bluetooth® Document
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Cloud computing and distributed systems.
The AUB Centre for AI in Media Proposal.docx
Teaching material agriculture food technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
sap open course for s4hana steps from ECC to s4
Chapter 3 Spatial Domain Image Processing.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
Encapsulation_ Review paper, used for researhc scholars
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Spectral efficient network and resource selection model in 5G networks

Securing RESTful APIs using OAuth 2 and OpenID Connect

  • 1. Securing RESTful APIs Using OAuth 2 and OpenID Connect Jonathan LeBlanc (@jcleblanc) Global Head of Developer Evangelism at PayPal
  • 2. Why do we Need This?
  • 3. Poor Password Choices • 4.7% of users have the password password; • 8.5% have the passwords password or 123456; • 9.8% have the passwords password, 123456 or 12345678; • 14% have a password from the top 10 passwords • 40% have a password from the top 100 passwords • 79% have a password from the top 500 passwords • 91% have a password from the top 1000 passwords
  • 4. …And of What’s Left 1. Pet’s name 2. Significant dates (like a wedding anniversary) 3. Date of birth of close relation 4. Child’s name 5. Other family member’s name 6. Place of birth 7. Favorite holiday 8. Something related to favorite football team 9. Current partner’s name
  • 8. App Revoked by User App Revoked by Service Provider
  • 9. Path to the Standard
  • 11. Rise of the Token
  • 12. Two Widely Used Specifications
  • 14. How Requests are Made curl -v https://api.sandbox.paypal.com/v1/payments/payme nt -H "Content-Type:application/json" -d '{ "intent": "sale", "payer": { ... }, "transactions": [{ "amount": { ... } }] }'
  • 15. How Auth is Added in curl -v https://api.sandbox.paypal.com/v1/payments/payment -H "Content-Type:application/json" -H "Authorization: Bearer {accessToken}" -d '{ "intent": "sale", "payer": { ... }, "transactions": [{ "amount": { ... } }] }'
  • 16. Attack Vectors Man in the Middle Replay Attacks Cross-Site Request Forgery (CSRF)
  • 18. Reasons for Auth Rate Limiting and Attack Vector Protection Having the ability to revoke application access Needing to allow users to revoke an applications access to their data
  • 19. When You Need Access Security
  • 22. Redirect the User to Log In Prepare the Redirect URI Authorization Endpoint client_id response_type (token) scope redirect_uri Browser Redirect Redirect URI
  • 23. Fetching the Access Token Fetch the Access Token Access Token Endpoint client_id grant_type client_secret code HTTP POST Access Token Endpoint
  • 24. Fetching the Access Token curl https://api.sandbox.paypal.com/v1/oauth2/token -H "Accept: application/json" -H "Accept-Language: en_US" -u "EOJ2S-Z6OoN_le_K:S1d75wsZ6y0SFd…" -d "grant_type=client_credentials"
  • 25. Access Token Response { "scope": "https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card", "access_token": "EEwJ6tF9x5WCIZDYzyZGaz6K…", "token_type": "Bearer", "app_id": "APP-6XR95014SS315863X", "expires_in": 28800 }
  • 26. Using the Access Token Fetch Privileged Resources Resource Endpoint Token Type (Authorization header) Access Token (Authorization header) HTTP GET / PUT / POST / DELETE Resource Endpoint
  • 27. Using the Access Token curl -v https://api.sandbox.paypal.com/v1/payments/payment -H "Content-Type:application/json" -H "Authorization:Bearer EMxItHE7Zl4cMdkv…" -d "{...}"
  • 29. Defining APIs with WADL / WSDL
  • 30. <?xml version="1.0" encoding="UTF-8"?> <description xmlns="http://www.w3.org/ns/wsdl" ...> <types> … </types> <interface name="Interface1"> … </interface> <binding name="HttpBinding" interface="tns:Interface1”> <operation ref="tns:Get" whttp:method="GET"/> </binding> <binding name="SoapBinding" interface="tns:Interface1" …> <operation ref="tns:Get" /> </binding> <service name="Service1" interface="tns:Interface1"> <endpoint name="HttpEndpoint" binding="tns:HttpBinding" address="http://www.example.com/rest/"/> <endpoint name="SoapEndpoint" binding="tns:SoapBinding" address="http://www.example.com/soap/"/> </service> </description>
  • 31. <?xml version="1.0"?> <application xmlns:xsi=…> <grammars> <include href="NewsSearchResponse.xsd"/> <include href="Error.xsd"/> </grammars> <resources base="http://api.search.yahoo.com/NewsSearchService/V1/"> <resource path="newsSearch"> <method name="GET" id="search"> <request> <param name="appid" type="xsd:string" required="true"/> <param name="query" type="xsd:string" required="true"/> </request> <response status="400"> <representation mediaType="application/xml" element="ya:Error"/> </response> </method> </resource> </resources> </application>
  • 32. Genio (templates) https://github.com/paypal/genio Genio Parser (model builder) https://github.com/paypal/genio-parser Genio Samples https://github.com/paypal/genio-sample Building SDKs Automatically
  • 33. Final Considerations REST and OAuth are specifications, not religions Don’t alienate your developers with security Open source is your friend
  • 34. Thank You! Questions? http://slideshare.net/jcleblanc Jonathan LeBlanc (@jcleblanc) Global Head of Developer Evangelism at PayPal