SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
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?
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

Contenu connexe

Tendances

Oauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportOauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 support
Gaurav Sharma
 
Remote code-with-expression-language-injection
Remote code-with-expression-language-injectionRemote code-with-expression-language-injection
Remote code-with-expression-language-injection
Mickey Jack
 

Tendances (20)

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

Similaire à Authentication and authorization in res tful infrastructures

Nk API - examples
Nk API - examplesNk API - examples
Nk API - examples
nasza-klasa
 

Similaire à Authentication and authorization in res tful infrastructures (20)

iMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within MicroservicesiMasters Intercon 2016 - Identity within Microservices
iMasters Intercon 2016 - Identity within Microservices
 
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
 
Nk API - examples
Nk API - examplesNk API - examples
Nk API - examples
 
UserCentric Identity based Service Invocation
UserCentric Identity based Service InvocationUserCentric Identity based Service Invocation
UserCentric Identity based Service Invocation
 
Web 20 Security - Vordel
Web 20 Security - VordelWeb 20 Security - Vordel
Web 20 Security - Vordel
 
Securing RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectSecuring RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID Connect
 
20190516 web security-basic
20190516 web security-basic20190516 web security-basic
20190516 web security-basic
 
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
 
24032022 Zero Trust for Developers Pub.pdf
24032022 Zero Trust for Developers Pub.pdf24032022 Zero Trust for Developers Pub.pdf
24032022 Zero Trust for Developers Pub.pdf
 
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
 
MongoDB World 2019: Securing Application Data from Day One
MongoDB World 2019: Securing Application Data from Day OneMongoDB World 2019: Securing Application Data from Day One
MongoDB World 2019: Securing Application Data from Day One
 
Securing RESTful API
Securing RESTful APISecuring RESTful API
Securing RESTful API
 
Shibboleth 2.0 IdP slides - Installfest (Edited)
Shibboleth 2.0 IdP slides - Installfest (Edited)Shibboleth 2.0 IdP slides - Installfest (Edited)
Shibboleth 2.0 IdP slides - Installfest (Edited)
 
HATEOAS 101 - Opinionated Introduction to a REST API Style
HATEOAS 101 - Opinionated Introduction to a REST API StyleHATEOAS 101 - Opinionated Introduction to a REST API Style
HATEOAS 101 - Opinionated Introduction to a REST API Style
 
Kasten securing access to your kubernetes applications
Kasten securing access to your kubernetes applicationsKasten securing access to your kubernetes applications
Kasten securing access to your kubernetes applications
 
Restful api
Restful apiRestful api
Restful api
 
Building IAM for OpenStack
Building IAM for OpenStackBuilding IAM for OpenStack
Building IAM for OpenStack
 
IBM Connections Activity Stream 3rd Party Integration - Social Connect VI - P...
IBM Connections Activity Stream 3rd Party Integration - Social Connect VI - P...IBM Connections Activity Stream 3rd Party Integration - Social Connect VI - P...
IBM Connections Activity Stream 3rd Party Integration - Social Connect VI - P...
 
Sso every where
Sso every whereSso every where
Sso every where
 
SIngle Sign On with Keycloak
SIngle Sign On with KeycloakSIngle Sign On with Keycloak
SIngle Sign On with Keycloak
 

Plus de Corley S.r.l.

Plus de Corley S.r.l. (20)

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

Dernier

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Dernier (20)

Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 

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?
  • 20.
  • 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)