SlideShare a Scribd company logo
Authentication & Authorization
RESTful infrastructures
APIConf 2017 - Turin
@_CloudConf_ - #apiconf2017
Walter Dal Mut
github.com/wdalmut
twitter.com/walterdalmut
corley.it
APIs immediately creates a new building block for
any application
I want to add lesystem feature to my application?
https://developers.google.com/drive/v3/web/about-sdk
Manage Files and Folders
Enable collaboration
Detect changes and
revisions
Using Google Drive features
FileSystem as a Service
$fileMetadata = new Google_Service_Drive_DriveFile([
'name' => 'photo.jpg'
]);
$file = $driveService->files->create($fileMetadata, [
'data' => file_get_contents("/tmp/photo.jpg"),
'mimeType' => 'image/jpeg',
'uploadType' => 'multipart',
'fields' => 'id'
]);
Or think about AWS services:
S3 lesystem
Lambda
code as a service: image cropping etc...
ElasticTranscoder video encoding
SQS distributed queues
SNS distributed noti cations
Or think about Docker
an API wraps completely the Docker Engine
Code as a service
Background tasks as a
service
Think how much Docker is di erent thanks to its own API system
than other services that you cannot control programmatically
API to turn ON/OFF a light bulb
Now a simple light bulb have a unique address in the world (URI)
Continuous Integration - Turn ON on
errors
Crepuscular relay for home automation
...
POST /light/1 {"high": true}
POST /light/1 {"high": false}
GET /light/1
So we can decouple our system to di erent and
reusable parts (services)
So now we have a machine-to-machine system,
how we can authenticate and authorize actions?
The most simple way to authenticate is:
Basic Authentication
Example:
BASE64({username}:{password})
GET /user HTTP/1.1
Host: api.walterdalmut.com
Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Encoding: UTF-8
Content-Length: 2
Connection: close
X-Records-Count: 0
X-Records-Page: 1
X-Records-Total: 0
[]
If i change the password the basic token changes,
or if a never change a password the token never
change (expire)...
If you allows multiple passwords you have a token
based authentication system
Create a login endpoint [POST /v1/login]
User send username and password
A new password (randomly generated) is created
This randomly generated password is an authentication
token
So the token is used as a validation mechanism
We can integrate JWT to wrap the base token
You can add: expire, refresh, revoke features to complete your auth system
GET /user HTTP/1.1
Host: api.walterdalmut.com
Authorization: Bearer 35deb6aab84648dc2423cb61d3fceaa6c869a7aa
Security over HTTPs
With this authentication scheme, can we handle
the authorization?
Yes, typically role based (ADMIN, USER, etc)
This authorization scheme works well with tiny
application with a limited API access or reserved
API
With this scheme we grant authorizations over a given resource per user role and not
with a ne grained method
$this->denyUnlessAuthorized($user, $resource));
if i want to grant only limited authorizations to
external applications?
How to handle the privacy problem and grant only a limited set of privileges?
Third party applications?
With the basic auth i have to pass my credential to that application!
With token auth i cannot control the data access because external application use my
current role!
We join di erent APIs togheter right?
Authentication and authorization in res tful infrastructures
OAuth2 is related to Authorization and not Authentication
User centered (focus on third party application data access)
Scope based authorization
Di erent token scheme generation
Secured via HTTPs (like basic auth, token auth...)
Mainly for distributed infrastructures
SOA, microservices...
Distributed infrastructure
OAuth2 scheme allows clients (third party
application) to access to the user information only
after a user grant
User (is you)
Client (third-party)
Resource (information owned by you)
Authorization grant (that you give to the
client)
OAuth2
You grant a limited set of privileges (scopes) to
a resource (that you own) to an external
application (the client)
With OAuth2, the token is linked with a list of
scopes and who have that token can access to
resources in a limited way, depening on the scope
list.
Scopes: -
GET /user HTTP/1.1
Host: api.walterdalmut.com
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUz...
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Encoding: UTF-8
Connection: close
{
"id": 1
}
Scopes: email
GET /user HTTP/1.1
Host: api.walterdalmut.com
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUz...
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Encoding: UTF-8
Connection: close
{
"id": 1,
"username": "walter.dalmut@gmail.com"
}
Scopes: email pro le:read
GET /user HTTP/1.1
Host: api.walterdalmut.com
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUz...
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Encoding: UTF-8
Connection: close
{
"id": 1,
"username": "walter.dalmut@gmail.com",
"firstname": "Walter",
"lastname": "Dal Mut",
"avatarUrl": "https://s.gravatar.com/avatar/d177b2782f268f068952ed05dd52ee01?size=496&default=retro",
"jobPosition": "Engineer",
"signupDate": "2017-04-05T14:49:26+00:00"
}
Scopes: email pro le:read invoice:read
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Encoding: UTF-8
Connection: close
{
"id": 1,
"username": "walter.dalmut@gmail.com",
"firstname": "Walter",
"lastname": "Dal Mut",
"avatarUrl": "https://s.gravatar.com/avatar/d177b2782f268f068952ed05dd52ee01?size=496&default=retro",
"jobPosition": "Engineer",
"signupDate": "2017-04-05T14:49:26+00:00",
"invoiceInfo": {
"id": 1,
"fiscalName": "Corley SRL",
"taxCode": "10669790015",
"fiscalCode": "10669790015",
"address": "P.za Statuto 10",
"zipCode": "10122",
"city": "Torino",
"country": "Italy",
"province": "TO"
}
}
4 [5] ways to get an authorization token
Authorization code
Implicit (javascript
clients)
Password
Client credentials
Refresh token
A token, access or refresh it doesn't matter, must expires in an amount of time and
those tokens can also be revoked by the resource owner.
Authorization code exchange
AngularJs is not able to keep the OAuth2 credential as a secret so the App Server
(Third Party app) will keep it and exchange the authorization code with a token using
also the client credentials
Authorization code exchange
Authorization code exchange
Authorization code exchange
Implicit ow
Used by Javascript client that cannot use a backed server for client validation
Password ow
Tipically used by privileged client to simplify the token generation
It is a privileged application in our network that allows user credentials sharing to
simplify the user login procedure (with backend support)
academy.corley.it (example of password ow)
Client credentials ow
Tipically only for client related jobs (no user resources but client resources)
OAuth2 will generate 2 tokens: access_token and
refresh_token.
The refresh token is not used to access to resources but only to generate a new token
without the whole generation handshake.
access_token (expires in 1 hour)
refresh_token (expires in 1 month)
Just few words...
Thanks for listening

More Related Content

ODP
Mohanraj - Securing Your Web Api With OAuth
PPTX
Securing RESTful Payment APIs Using OAuth 2
PPTX
Connection String Parameter Pollution Attacks
PPTX
An Introduction to OAuth2
PPTX
Hybrid authentication - Talking To Major Social Networks
PDF
Introduction to OAuth2.0
PDF
Demystifying OAuth 2.0
PDF
Url programming
Mohanraj - Securing Your Web Api With OAuth
Securing RESTful Payment APIs Using OAuth 2
Connection String Parameter Pollution Attacks
An Introduction to OAuth2
Hybrid authentication - Talking To Major Social Networks
Introduction to OAuth2.0
Demystifying OAuth 2.0
Url programming

What's hot (20)

PDF
Stateless Auth using OAuth2 & JWT
PPT
Silicon Valley Code Camp 2009: OAuth: What, Why and How
PPTX
Oauth2 and OWSM OAuth2 support
PPTX
FI-WARE Account and OAuth solution
PPT
O auth 2
PPTX
Token Based Authentication Systems with AngularJS & NodeJS
ODP
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
PDF
The Big Picture and How to Get Started
PDF
Json web token api authorization
PPTX
An introduction to OAuth 2
PPTX
Oauth 2.0 security
PDF
What the Heck is OAuth and OIDC - Denver Developer Identity Workshop 2020
PDF
Remote code-with-expression-language-injection
PDF
OAuth2 Authentication
PPTX
Adding Identity Management and Access Control to your Application
PPTX
Secure Code Warrior - XQuery injection
PDF
What the Heck is OAuth and OpenID Connect? Connect.Tech 2017
PPTX
Secure Code Warrior - Insufficient data encoding
PDF
OAuth2 primer
PPTX
OAuth2 + API Security
Stateless Auth using OAuth2 & JWT
Silicon Valley Code Camp 2009: OAuth: What, Why and How
Oauth2 and OWSM OAuth2 support
FI-WARE Account and OAuth solution
O auth 2
Token Based Authentication Systems with AngularJS & NodeJS
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
The Big Picture and How to Get Started
Json web token api authorization
An introduction to OAuth 2
Oauth 2.0 security
What the Heck is OAuth and OIDC - Denver Developer Identity Workshop 2020
Remote code-with-expression-language-injection
OAuth2 Authentication
Adding Identity Management and Access Control to your Application
Secure Code Warrior - XQuery injection
What the Heck is OAuth and OpenID Connect? Connect.Tech 2017
Secure Code Warrior - Insufficient data encoding
OAuth2 primer
OAuth2 + API Security
Ad

Similar to Authentication and authorization in res tful infrastructures (20)

PDF
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
PPTX
HTTP Services & REST API Security
PPTX
How to build Simple yet powerful API.pptx
PPTX
REST API Security: OAuth 2.0, JWTs, and More!
PDF
When and Why Would I use Oauth2?
PDF
OAuth2
PPTX
OAuth2 para desarrolladores
PDF
OAuth in the Real World featuring Webshell
PPTX
OAuth 2
PDF
Securing APIs with OAuth 2.0
PDF
Full stack security
PPTX
Api security
PPTX
Best Practices in Building an API Security Ecosystem
PPTX
Oauth
PPTX
Devteach 2017 OAuth and Open id connect demystified
PDF
De la bonne utilisation de OAuth2
PDF
Stateless authentication for microservices applications - JavaLand 2015
PPTX
API Security : Patterns and Practices
PDF
Oauth Nightmares Abstract OAuth Nightmares
PPTX
(1) OAuth 2.0 Overview
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
HTTP Services & REST API Security
How to build Simple yet powerful API.pptx
REST API Security: OAuth 2.0, JWTs, and More!
When and Why Would I use Oauth2?
OAuth2
OAuth2 para desarrolladores
OAuth in the Real World featuring Webshell
OAuth 2
Securing APIs with OAuth 2.0
Full stack security
Api security
Best Practices in Building an API Security Ecosystem
Oauth
Devteach 2017 OAuth and Open id connect demystified
De la bonne utilisation de OAuth2
Stateless authentication for microservices applications - JavaLand 2015
API Security : Patterns and Practices
Oauth Nightmares Abstract OAuth Nightmares
(1) OAuth 2.0 Overview
Ad

More from Corley S.r.l. (20)

PDF
Aws rekognition - riconoscimento facciale
PDF
AWSome day 2018 - scalability and cost optimization with container services
PDF
AWSome day 2018 - API serverless with aws
PDF
AWSome day 2018 - database in cloud
PDF
Trace your micro-services oriented application with Zipkin and OpenTracing
PDF
Apiconf - The perfect REST solution
PDF
Apiconf - Doc Driven Development
PDF
Flexibility and scalability of costs in serverless infrastructures
PDF
CloudConf2017 - Deploy, Scale & Coordinate a microservice oriented application
PDF
React vs Angular2
PDF
A single language for backend and frontend from AngularJS to cloud with Clau...
PPTX
AngularJS: Service, factory & provider
PPTX
The advantage of developing with TypeScript
PDF
Angular coding: from project management to web and mobile deploy
PDF
Corley cloud angular in cloud
PDF
Measure your app internals with InfluxDB and Symfony2
PDF
Read Twitter Stream and Tweet back pictures with Raspberry Pi & AWS Lambda
PDF
Deploy and Scale your PHP App with AWS ElasticBeanstalk and Docker- PHPTour L...
PDF
Middleware PHP - A simple micro-framework
PDF
From Chef to Saltstack on Cloud Providers - Incontro DevOps 2015
Aws rekognition - riconoscimento facciale
AWSome day 2018 - scalability and cost optimization with container services
AWSome day 2018 - API serverless with aws
AWSome day 2018 - database in cloud
Trace your micro-services oriented application with Zipkin and OpenTracing
Apiconf - The perfect REST solution
Apiconf - Doc Driven Development
Flexibility and scalability of costs in serverless infrastructures
CloudConf2017 - Deploy, Scale & Coordinate a microservice oriented application
React vs Angular2
A single language for backend and frontend from AngularJS to cloud with Clau...
AngularJS: Service, factory & provider
The advantage of developing with TypeScript
Angular coding: from project management to web and mobile deploy
Corley cloud angular in cloud
Measure your app internals with InfluxDB and Symfony2
Read Twitter Stream and Tweet back pictures with Raspberry Pi & AWS Lambda
Deploy and Scale your PHP App with AWS ElasticBeanstalk and Docker- PHPTour L...
Middleware PHP - A simple micro-framework
From Chef to Saltstack on Cloud Providers - Incontro DevOps 2015

Recently uploaded (20)

PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Transform Your Business with a Software ERP System
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPT
JAVA ppt tutorial basics to learn java programming
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
ISO 45001 Occupational Health and Safety Management System
2025 Textile ERP Trends: SAP, Odoo & Oracle
Online Work Permit System for Fast Permit Processing
VVF-Customer-Presentation2025-Ver1.9.pptx
Transform Your Business with a Software ERP System
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Which alternative to Crystal Reports is best for small or large businesses.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Understanding Forklifts - TECH EHS Solution
Softaken Excel to vCard Converter Software.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
JAVA ppt tutorial basics to learn java programming
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms II-SECS-1021-03
Materi-Enum-and-Record-Data-Type (1).pptx
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
ManageIQ - Sprint 268 Review - Slide Deck
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free

Authentication and authorization in res tful infrastructures

  • 1. Authentication & Authorization RESTful infrastructures APIConf 2017 - Turin @_CloudConf_ - #apiconf2017
  • 4. APIs immediately creates a new building block for any application
  • 5. I want to add lesystem feature to my application? https://developers.google.com/drive/v3/web/about-sdk Manage Files and Folders Enable collaboration Detect changes and revisions Using Google Drive features
  • 6. FileSystem as a Service $fileMetadata = new Google_Service_Drive_DriveFile([ 'name' => 'photo.jpg' ]); $file = $driveService->files->create($fileMetadata, [ 'data' => file_get_contents("/tmp/photo.jpg"), 'mimeType' => 'image/jpeg', 'uploadType' => 'multipart', 'fields' => 'id' ]);
  • 7. Or think about AWS services: S3 lesystem Lambda code as a service: image cropping etc... ElasticTranscoder video encoding SQS distributed queues SNS distributed noti cations
  • 8. Or think about Docker an API wraps completely the Docker Engine Code as a service Background tasks as a service Think how much Docker is di erent thanks to its own API system than other services that you cannot control programmatically
  • 9. API to turn ON/OFF a light bulb Now a simple light bulb have a unique address in the world (URI) Continuous Integration - Turn ON on errors Crepuscular relay for home automation ... POST /light/1 {"high": true} POST /light/1 {"high": false} GET /light/1
  • 10. So we can decouple our system to di erent and reusable parts (services)
  • 11. So now we have a machine-to-machine system, how we can authenticate and authorize actions?
  • 12. The most simple way to authenticate is: Basic Authentication Example: BASE64({username}:{password}) GET /user HTTP/1.1 Host: api.walterdalmut.com Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Encoding: UTF-8 Content-Length: 2 Connection: close X-Records-Count: 0 X-Records-Page: 1 X-Records-Total: 0 []
  • 13. If i change the password the basic token changes, or if a never change a password the token never change (expire)...
  • 14. If you allows multiple passwords you have a token based authentication system Create a login endpoint [POST /v1/login] User send username and password A new password (randomly generated) is created This randomly generated password is an authentication token So the token is used as a validation mechanism We can integrate JWT to wrap the base token You can add: expire, refresh, revoke features to complete your auth system GET /user HTTP/1.1 Host: api.walterdalmut.com Authorization: Bearer 35deb6aab84648dc2423cb61d3fceaa6c869a7aa
  • 16. With this authentication scheme, can we handle the authorization? Yes, typically role based (ADMIN, USER, etc)
  • 17. This authorization scheme works well with tiny application with a limited API access or reserved API With this scheme we grant authorizations over a given resource per user role and not with a ne grained method $this->denyUnlessAuthorized($user, $resource));
  • 18. if i want to grant only limited authorizations to external applications? How to handle the privacy problem and grant only a limited set of privileges?
  • 19. Third party applications? With the basic auth i have to pass my credential to that application! With token auth i cannot control the data access because external application use my current role! We join di erent APIs togheter right?
  • 21. OAuth2 is related to Authorization and not Authentication User centered (focus on third party application data access) Scope based authorization Di erent token scheme generation Secured via HTTPs (like basic auth, token auth...) Mainly for distributed infrastructures SOA, microservices...
  • 23. OAuth2 scheme allows clients (third party application) to access to the user information only after a user grant User (is you) Client (third-party) Resource (information owned by you) Authorization grant (that you give to the client)
  • 24. OAuth2 You grant a limited set of privileges (scopes) to a resource (that you own) to an external application (the client)
  • 25. With OAuth2, the token is linked with a list of scopes and who have that token can access to resources in a limited way, depening on the scope list.
  • 26. Scopes: - GET /user HTTP/1.1 Host: api.walterdalmut.com Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUz... HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Encoding: UTF-8 Connection: close { "id": 1 }
  • 27. Scopes: email GET /user HTTP/1.1 Host: api.walterdalmut.com Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUz... HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Encoding: UTF-8 Connection: close { "id": 1, "username": "walter.dalmut@gmail.com" }
  • 28. Scopes: email pro le:read GET /user HTTP/1.1 Host: api.walterdalmut.com Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUz... HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Encoding: UTF-8 Connection: close { "id": 1, "username": "walter.dalmut@gmail.com", "firstname": "Walter", "lastname": "Dal Mut", "avatarUrl": "https://s.gravatar.com/avatar/d177b2782f268f068952ed05dd52ee01?size=496&default=retro", "jobPosition": "Engineer", "signupDate": "2017-04-05T14:49:26+00:00" }
  • 29. Scopes: email pro le:read invoice:read HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Encoding: UTF-8 Connection: close { "id": 1, "username": "walter.dalmut@gmail.com", "firstname": "Walter", "lastname": "Dal Mut", "avatarUrl": "https://s.gravatar.com/avatar/d177b2782f268f068952ed05dd52ee01?size=496&default=retro", "jobPosition": "Engineer", "signupDate": "2017-04-05T14:49:26+00:00", "invoiceInfo": { "id": 1, "fiscalName": "Corley SRL", "taxCode": "10669790015", "fiscalCode": "10669790015", "address": "P.za Statuto 10", "zipCode": "10122", "city": "Torino", "country": "Italy", "province": "TO" } }
  • 30. 4 [5] ways to get an authorization token Authorization code Implicit (javascript clients) Password Client credentials Refresh token A token, access or refresh it doesn't matter, must expires in an amount of time and those tokens can also be revoked by the resource owner.
  • 31. Authorization code exchange AngularJs is not able to keep the OAuth2 credential as a secret so the App Server (Third Party app) will keep it and exchange the authorization code with a token using also the client credentials
  • 35. Implicit ow Used by Javascript client that cannot use a backed server for client validation
  • 36. Password ow Tipically used by privileged client to simplify the token generation
  • 37. It is a privileged application in our network that allows user credentials sharing to simplify the user login procedure (with backend support) academy.corley.it (example of password ow)
  • 38. Client credentials ow Tipically only for client related jobs (no user resources but client resources)
  • 39. OAuth2 will generate 2 tokens: access_token and refresh_token. The refresh token is not used to access to resources but only to generate a new token without the whole generation handshake. access_token (expires in 1 hour) refresh_token (expires in 1 month)