SlideShare a Scribd company logo
1 of 43
Download to read offline
There is REST and
then there is “REST”
Radovan Semančík
November 2017
Who Am I?
Ing. Radovan Semančík, PhD.
Software Architect at Evolveum
Architect of Evolveum midPoint
Apache Foundation committer
Contributor to ConnId and Apache Directory API
What is REST?
Server
JavaScript in browser
Mobile application
Enterprise application
CLI tool
Desktop client
…
Client HTTP
JSON
request
Web application
Enterprise application
“Cloud” application
Whatever as a Service
“Serverless” server
...
JSON
response
What is REST?
Server
JavaScript in browser
Mobile application
Enterprise application
CLI tool
Desktop client
…
Client HTTP
JSON
request
JSON
response
Web application
Enterprise application
“Cloud” application
Whatever as a Service
“Serverless” server
...
This is simple, easy to understand … and wrong
Who Are You?
I know
everything
about
REST
already
Whatever.
I do not need
to know REST
This may be interesting
Back to 1990s ...
● 1990: WWW invented
• Tim Berners-Lee
● 1996: HTTP 1.0
● 1997: HTTP 1.1
● 2000: Representational State Transfer
• Roy Fielding
● 2002: WWW Architecture
REpresentational State Transfer
REST (according to Fielding)
● Architectural style
• Not “architecture”, not “protocol”, not “API”
● Retro-architecture (HTTP 1.1)
● Transfer of resource representations
• HTML page is a representation, HTTP is transfer protocol
● Architectural constraints
• Client-server, Stateless, Cache, Uniform interface, Layered
system, Code on demand
Representational State Transfer
Source: Fielding R.: Architectural Styles and the Design of Network-based Software Architectures, 2000
So, what exactly is wrong?
ServerClient HTTP
JSON
request
JSON
response
JSON? Not really ...
ServerClient HTTP
request
response
Request-response … kind of ...
ServerClient HTTP
URL
resource
representation
Operations (verbs):
● GET
● PUT
● DELETE
● POST
● ...
REST is not RPC
● Objects (resources) addressed by URL
● Fixed operation set (verbs)
• GET, HEAD, PUT, DELETE, POST, OPTIONS, TRACE, CONNECT
● Stateless
• Sessions are evil
● Hypertext
• Thou shalt not construct your URLs
Theory and Practice
● Theory: REST is architectural style for
hypertext applications
● Practice: we really need RCP
● REST is not good for RPC
… but REST is popular, we want it …
● Result: RESTful APIs
RESTful APIs
● Not really REST
• Not hypertext
• Mostly resource-based, but still some RPC
● Not really API
• Application Programming Interface
• Problematic interface definition (Swagger/OpenAPI?)
• Security? Reliability? Transactions?
● Read: “HTTP-based service”
Reinvented Wheel … again
● 1976: RFC 707
● 1981: Xerox Courier
● 1991: CORBA
● 1993: DCE/RPC → DCOM
● 1995: SunRPC
● 1998: SOAP
● 200x: “RESTful” API
Pure REST
● It is possible to implement pure REST service
… but it is going to be real pain (very likely)
• Careful design and implementation
• Unnecessary complexity
• Too many network round-trips
• Expect poor performance
● Hypertext is not suitable for everything
What do we do?
● Keep the parts that fit
• Resources, URLs, representations
• GET, DELETE, POST, …
● Ditch the parts that do not fit
• Hypertext
● Compromises
• Statelessness, caching, security, consistency, ...
● Interface definition
• Swagger/OpenAPI
Practical “REST”
● Try to stick to resources and representations
• URL represents object (resource)
● GET as safe operation
● Use POST for RPC when needed
• But do not abuse
● Define the interface
• URL formats and meaning, data types, inputs/outputs, ...
Practical case study: midPoint
● MidPoint: comprehensive identity
management and governance system
• Identity management, provisioning, role-based access control,
audit, workflow, entitlement management, password management,
policy management, segregation of duties, …
● 100% open source
● Started in 2011
● 700k lines of (mostly) Java code
(things are a bit
complex in this part)
MidPoint Services
midPoint
Self-service
application
IDE
User
Developer
Custom
client
Enterprise
integration
Mobile
application
MidPoint “REST” service
● Development started in 2013
● Existing data model and operations
• Object-based: User, Role, Organizational unit, Account, Task,
Security policy, ...
• CRUD … but there are exceptions
● “RESTful” part and RPC part
● Kept as close to REST ideas as was practical
RESTful Operations: object
http://…./rest/users/02c15378­c48b­11e7­b010­1ff8606bae23
prefix type object identifier (OID)
Verbs:
● GET: read
● POST: modify
● DELETE: delete
● PUT: create (not recommended)
How does object look like?
<user oid="02c15378­c48b­11e7­b010­1ff8606bae23">
    <name>jack</name>
    <description>Where's the rum?</description>
    <fullName>Jack Sparrow</fullName>
    <givenName>Jack</givenName>
    <familyName>Sparrow</familyName>
    <emailAddress>jack.sparrow@evolveum.com</emailAddress>
    <locality>Caribbean</locality>
    <activation>
     <administrativeStatus>enabled</administrativeStatus>
    </activation>
</user>
{
    "name" : "jack",
    "fullName" : "Jack Sparrow",
    "givenName" : "Jack", 
    "familyName" : "Sparrow",
    …
XML
JSON
RESTful Operations: collection
http://…./rest/users
prefix type
Verbs:
● GET: list objects, search (theoretically)
● POST: create new object
● DELETE: not supported
● PUT: not supported
Search
● Query language
<q:equal>
    <q:path>name</q:path>
    <q:value>jack</q:value>
</q:equal>
● Search with POST: convenience
● Deviation from REST
• Dedicated “search” resource for POST instead of GET
• Should return list of URLs, but returns objects (to save round trips)
http://…./rest/users/search
HTTP verbs
● GET is safe
● POST used for many things
● DELETE deletes
● PUT is not very useful
● PATCH for modification
• But POST works as well
● Typical “REST” API
Error Codes
● 1xx: Information. Stay tuned.
● 2xx: Success. All done.
● 3xx: Redirection or “in progress” (we will get to that)
● 4xx: Client error (e.g. bad request)
● 5xx: Server error (e.g. bug in server code)
Trivial, isn’t it? Now let’s have a
look at the interesting stuff.
Asynchronous Operations
● Operations that take a looooong time (days)
● Cannot return success (2xx)
● Solution: redirects (3xx)
Asynchronous Operations
midPointclient
Modify user
POST …/users/12345
Redirect
302: …/tasks/87654
Start operation:
create new task
Task
87654
Check task
GET …/tasks/87654
200: <task>...</task>
RPC Operations: object-related
http://…/rest/tasks/c68d7770­c493­11e7­bce6­9bec1fc3b57c/suspend
prefix type object identifier (OID)
Verbs:
● GET: not applicable
● POST: execute the operation
● DELETE: not applicable
● PUT: not applicable
op
Object-related RPC operations
● Deviation from pure REST
• Should be modeled as resource changes or separate resources
… but that is a pain
● Error handling
RPC Operations: global
http://…/rest/notifyChange
prefix
Verbs:
● GET: not applicable
● POST: execute the operation
● DELETE: not applicable
● PUT: not applicable
operation
Global RPC operations
● Complex input and output data structures
● Huge deviation from pure REST
● It was necessary to keep the interface simple
and efficient
Next: really hard problems ...
Security
● REST is stateless
• Cookie-based sessions are out
● HTTP Basic authentication
• Oh, really?
● OAuth2 / OpenID Connect
• “best” practice for REST APIs
● JSON Web Tokens (JWT)
• SAML tokens reinvented
Interface Definition
● Swagger / OpenAPI
• WSDL reinvented (CORBA IDL reinvented)
• JSON-oriented
• Still quite limited, but at least something
● REST purists hate it
• Because this goes directly against hypertext principles
Stub and Skeleton
Client
app
t1.suspend()
Interface definition
stub
Server
suspend() {
  …
}
skeleton
HTTP
POST
generate
code
generate
code
Does not really works in “RESTful” APIs (yet)
Transactions and Consistency
● Transactions (ACID)
• Forget it
● Consistency
• Cannot forget it, but it is tricky
• Optimistic locking / MVCC is best bet
• ETag (RFC7232) is a standard mechanism
• But a lot of proprietary mechanisms is used instead
Conclusion
● REST is no good for RPC
… but we are going to use it anyway
● And it is practical
… with some tweaks and compromises
● Future?
Questions and Answers
Radovan Semančík
www.evolveum.com
Thank You

More Related Content

What's hot

OpenIDM - Flexible Provisioning Platform - April 28 Webinar
OpenIDM - Flexible Provisioning Platform - April 28 WebinarOpenIDM - Flexible Provisioning Platform - April 28 Webinar
OpenIDM - Flexible Provisioning Platform - April 28 WebinarForgeRock
 
OpenID Foundation RISC WG Update - 2017-10-16
OpenID Foundation RISC WG Update - 2017-10-16OpenID Foundation RISC WG Update - 2017-10-16
OpenID Foundation RISC WG Update - 2017-10-16MikeLeszcz
 
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Arnaud Bouchez
 
angular-wakanda ngParis meetup 15 at 42
angular-wakanda ngParis meetup 15 at 42angular-wakanda ngParis meetup 15 at 42
angular-wakanda ngParis meetup 15 at 42Alexandre Morgaut
 
Characerizing and Validating QoS in the Emerging IoT Network
Characerizing and Validating QoS in the Emerging IoT NetworkCharacerizing and Validating QoS in the Emerging IoT Network
Characerizing and Validating QoS in the Emerging IoT NetworkHans Ashlock
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013Alexandre Morgaut
 
OpenID Foundation Connect Working Group Update - October 22, 2018
OpenID Foundation Connect Working Group Update - October 22, 2018OpenID Foundation Connect Working Group Update - October 22, 2018
OpenID Foundation Connect Working Group Update - October 22, 2018OpenIDFoundation
 
OpenID Foundation Workshop at EIC 2018 - OpenID Certification Update
OpenID Foundation Workshop at EIC 2018 - OpenID Certification UpdateOpenID Foundation Workshop at EIC 2018 - OpenID Certification Update
OpenID Foundation Workshop at EIC 2018 - OpenID Certification UpdateMikeLeszcz
 
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Connect Working Group U...
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Connect Working Group U...OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Connect Working Group U...
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Connect Working Group U...OpenIDFoundation
 
OIDF Workshop 4/29/2019 -- OpenID Certification Update
OIDF Workshop 4/29/2019 -- OpenID Certification UpdateOIDF Workshop 4/29/2019 -- OpenID Certification Update
OIDF Workshop 4/29/2019 -- OpenID Certification UpdateOpenIDFoundation
 
ServerlessConf: Serverless for the Enterprise - Rafal Gancarz
ServerlessConf: Serverless for the Enterprise - Rafal GancarzServerlessConf: Serverless for the Enterprise - Rafal Gancarz
ServerlessConf: Serverless for the Enterprise - Rafal GancarzOpenCredo
 
Front-end for Java developers Devoxx France 2018
Front-end for Java developers Devoxx France 2018Front-end for Java developers Devoxx France 2018
Front-end for Java developers Devoxx France 2018Deepu K Sasidharan
 
Whitepages Practical Experience Converting from Ruby to Reactive
Whitepages Practical Experience Converting from Ruby to ReactiveWhitepages Practical Experience Converting from Ruby to Reactive
Whitepages Practical Experience Converting from Ruby to ReactiveDragos Manolescu
 
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Certification Program U...
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Certification Program U...OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Certification Program U...
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Certification Program U...OpenIDFoundation
 
Resume
ResumeResume
ResumeMina k
 
OpenID Certification Program Update - 2018-04-02
OpenID Certification Program Update - 2018-04-02OpenID Certification Program Update - 2018-04-02
OpenID Certification Program Update - 2018-04-02MikeLeszcz
 

What's hot (17)

OpenIDM - Flexible Provisioning Platform - April 28 Webinar
OpenIDM - Flexible Provisioning Platform - April 28 WebinarOpenIDM - Flexible Provisioning Platform - April 28 Webinar
OpenIDM - Flexible Provisioning Platform - April 28 Webinar
 
OpenID Foundation RISC WG Update - 2017-10-16
OpenID Foundation RISC WG Update - 2017-10-16OpenID Foundation RISC WG Update - 2017-10-16
OpenID Foundation RISC WG Update - 2017-10-16
 
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
 
angular-wakanda ngParis meetup 15 at 42
angular-wakanda ngParis meetup 15 at 42angular-wakanda ngParis meetup 15 at 42
angular-wakanda ngParis meetup 15 at 42
 
Characerizing and Validating QoS in the Emerging IoT Network
Characerizing and Validating QoS in the Emerging IoT NetworkCharacerizing and Validating QoS in the Emerging IoT Network
Characerizing and Validating QoS in the Emerging IoT Network
 
Vs java (1)
Vs java (1)Vs java (1)
Vs java (1)
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013
 
OpenID Foundation Connect Working Group Update - October 22, 2018
OpenID Foundation Connect Working Group Update - October 22, 2018OpenID Foundation Connect Working Group Update - October 22, 2018
OpenID Foundation Connect Working Group Update - October 22, 2018
 
OpenID Foundation Workshop at EIC 2018 - OpenID Certification Update
OpenID Foundation Workshop at EIC 2018 - OpenID Certification UpdateOpenID Foundation Workshop at EIC 2018 - OpenID Certification Update
OpenID Foundation Workshop at EIC 2018 - OpenID Certification Update
 
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Connect Working Group U...
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Connect Working Group U...OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Connect Working Group U...
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Connect Working Group U...
 
OIDF Workshop 4/29/2019 -- OpenID Certification Update
OIDF Workshop 4/29/2019 -- OpenID Certification UpdateOIDF Workshop 4/29/2019 -- OpenID Certification Update
OIDF Workshop 4/29/2019 -- OpenID Certification Update
 
ServerlessConf: Serverless for the Enterprise - Rafal Gancarz
ServerlessConf: Serverless for the Enterprise - Rafal GancarzServerlessConf: Serverless for the Enterprise - Rafal Gancarz
ServerlessConf: Serverless for the Enterprise - Rafal Gancarz
 
Front-end for Java developers Devoxx France 2018
Front-end for Java developers Devoxx France 2018Front-end for Java developers Devoxx France 2018
Front-end for Java developers Devoxx France 2018
 
Whitepages Practical Experience Converting from Ruby to Reactive
Whitepages Practical Experience Converting from Ruby to ReactiveWhitepages Practical Experience Converting from Ruby to Reactive
Whitepages Practical Experience Converting from Ruby to Reactive
 
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Certification Program U...
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Certification Program U...OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Certification Program U...
OIDF Workshop at Verizon Media -- 9/30/2019 -- OpenID Certification Program U...
 
Resume
ResumeResume
Resume
 
OpenID Certification Program Update - 2018-04-02
OpenID Certification Program Update - 2018-04-02OpenID Certification Program Update - 2018-04-02
OpenID Certification Program Update - 2018-04-02
 

Similar to There is REST and then there is "REST"

RESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel MardjanRESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel MardjanJexia
 
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...chbornet
 
Creating a custom API for a headless Drupal
Creating a custom API for a headless DrupalCreating a custom API for a headless Drupal
Creating a custom API for a headless DrupalExove
 
GraphQL is actually rest
GraphQL is actually restGraphQL is actually rest
GraphQL is actually restJakub Riedl
 
Introduction to Backend Engineering
Introduction to Backend EngineeringIntroduction to Backend Engineering
Introduction to Backend EngineeringUdayYadav90
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraLINAGORA
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIRasan Samarasinghe
 
Simple Web Services with PHP
Simple Web Services with PHPSimple Web Services with PHP
Simple Web Services with PHPJohn Paul Ada
 
APIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidadAPIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidadSoftware Guru
 
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...Radovan Semancik
 
RESTful with Drupal - in-s and out-s
RESTful with Drupal - in-s and out-sRESTful with Drupal - in-s and out-s
RESTful with Drupal - in-s and out-sKalin Chernev
 
Introduction to REST and Jersey
Introduction to REST and JerseyIntroduction to REST and Jersey
Introduction to REST and JerseyChris Winters
 
Applications of the REST Principle
Applications of the REST PrincipleApplications of the REST Principle
Applications of the REST Principleelliando dias
 
ReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... YawnReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... Yawnozten
 

Similar to There is REST and then there is "REST" (20)

RESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel MardjanRESTful applications: The why and how by Maikel Mardjan
RESTful applications: The why and how by Maikel Mardjan
 
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
JHipster Conf 2018 : Connect your JHipster apps to the world of APIs with Ope...
 
Creating a custom API for a headless Drupal
Creating a custom API for a headless DrupalCreating a custom API for a headless Drupal
Creating a custom API for a headless Drupal
 
GraphQL is actually rest
GraphQL is actually restGraphQL is actually rest
GraphQL is actually rest
 
Introduction to Backend Engineering
Introduction to Backend EngineeringIntroduction to Backend Engineering
Introduction to Backend Engineering
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - Linagora
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST API
 
Simple Web Services with PHP
Simple Web Services with PHPSimple Web Services with PHP
Simple Web Services with PHP
 
APIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidadAPIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidad
 
SGCE 2015 REST APIs
SGCE 2015 REST APIsSGCE 2015 REST APIs
SGCE 2015 REST APIs
 
JSON all the way
JSON all the wayJSON all the way
JSON all the way
 
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...
How To Maintain Million Lines Of Open Source Code And Remain Sane or The Stor...
 
RESTful with Drupal - in-s and out-s
RESTful with Drupal - in-s and out-sRESTful with Drupal - in-s and out-s
RESTful with Drupal - in-s and out-s
 
Introduction to REST and Jersey
Introduction to REST and JerseyIntroduction to REST and Jersey
Introduction to REST and Jersey
 
SOAP vs REST
SOAP vs RESTSOAP vs REST
SOAP vs REST
 
Applications of the REST Principle
Applications of the REST PrincipleApplications of the REST Principle
Applications of the REST Principle
 
Dust.js
Dust.jsDust.js
Dust.js
 
Nodejs
NodejsNodejs
Nodejs
 
ReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... YawnReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... Yawn
 

Recently uploaded

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
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-learnAmarnathKambale
 
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...Jittipong Loespradit
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%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 Stilfonteinmasabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%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 masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
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 AidPhilip Schwarz
 

Recently uploaded (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
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
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
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...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%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
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%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
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
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
 

There is REST and then there is "REST"

  • 1. There is REST and then there is “REST” Radovan Semančík November 2017
  • 2. Who Am I? Ing. Radovan Semančík, PhD. Software Architect at Evolveum Architect of Evolveum midPoint Apache Foundation committer Contributor to ConnId and Apache Directory API
  • 3. What is REST? Server JavaScript in browser Mobile application Enterprise application CLI tool Desktop client … Client HTTP JSON request Web application Enterprise application “Cloud” application Whatever as a Service “Serverless” server ... JSON response
  • 4. What is REST? Server JavaScript in browser Mobile application Enterprise application CLI tool Desktop client … Client HTTP JSON request JSON response Web application Enterprise application “Cloud” application Whatever as a Service “Serverless” server ... This is simple, easy to understand … and wrong
  • 5. Who Are You? I know everything about REST already Whatever. I do not need to know REST This may be interesting
  • 6. Back to 1990s ... ● 1990: WWW invented • Tim Berners-Lee ● 1996: HTTP 1.0 ● 1997: HTTP 1.1 ● 2000: Representational State Transfer • Roy Fielding ● 2002: WWW Architecture
  • 8. REST (according to Fielding) ● Architectural style • Not “architecture”, not “protocol”, not “API” ● Retro-architecture (HTTP 1.1) ● Transfer of resource representations • HTML page is a representation, HTTP is transfer protocol ● Architectural constraints • Client-server, Stateless, Cache, Uniform interface, Layered system, Code on demand
  • 9. Representational State Transfer Source: Fielding R.: Architectural Styles and the Design of Network-based Software Architectures, 2000
  • 10. So, what exactly is wrong? ServerClient HTTP JSON request JSON response
  • 11. JSON? Not really ... ServerClient HTTP request response
  • 12. Request-response … kind of ... ServerClient HTTP URL resource representation Operations (verbs): ● GET ● PUT ● DELETE ● POST ● ...
  • 13. REST is not RPC ● Objects (resources) addressed by URL ● Fixed operation set (verbs) • GET, HEAD, PUT, DELETE, POST, OPTIONS, TRACE, CONNECT ● Stateless • Sessions are evil ● Hypertext • Thou shalt not construct your URLs
  • 14. Theory and Practice ● Theory: REST is architectural style for hypertext applications ● Practice: we really need RCP ● REST is not good for RPC … but REST is popular, we want it … ● Result: RESTful APIs
  • 15. RESTful APIs ● Not really REST • Not hypertext • Mostly resource-based, but still some RPC ● Not really API • Application Programming Interface • Problematic interface definition (Swagger/OpenAPI?) • Security? Reliability? Transactions? ● Read: “HTTP-based service”
  • 16. Reinvented Wheel … again ● 1976: RFC 707 ● 1981: Xerox Courier ● 1991: CORBA ● 1993: DCE/RPC → DCOM ● 1995: SunRPC ● 1998: SOAP ● 200x: “RESTful” API
  • 17. Pure REST ● It is possible to implement pure REST service … but it is going to be real pain (very likely) • Careful design and implementation • Unnecessary complexity • Too many network round-trips • Expect poor performance ● Hypertext is not suitable for everything
  • 18. What do we do? ● Keep the parts that fit • Resources, URLs, representations • GET, DELETE, POST, … ● Ditch the parts that do not fit • Hypertext ● Compromises • Statelessness, caching, security, consistency, ... ● Interface definition • Swagger/OpenAPI
  • 19. Practical “REST” ● Try to stick to resources and representations • URL represents object (resource) ● GET as safe operation ● Use POST for RPC when needed • But do not abuse ● Define the interface • URL formats and meaning, data types, inputs/outputs, ...
  • 20. Practical case study: midPoint ● MidPoint: comprehensive identity management and governance system • Identity management, provisioning, role-based access control, audit, workflow, entitlement management, password management, policy management, segregation of duties, … ● 100% open source ● Started in 2011 ● 700k lines of (mostly) Java code
  • 21. (things are a bit complex in this part) MidPoint Services midPoint Self-service application IDE User Developer Custom client Enterprise integration Mobile application
  • 22. MidPoint “REST” service ● Development started in 2013 ● Existing data model and operations • Object-based: User, Role, Organizational unit, Account, Task, Security policy, ... • CRUD … but there are exceptions ● “RESTful” part and RPC part ● Kept as close to REST ideas as was practical
  • 23. RESTful Operations: object http://…./rest/users/02c15378­c48b­11e7­b010­1ff8606bae23 prefix type object identifier (OID) Verbs: ● GET: read ● POST: modify ● DELETE: delete ● PUT: create (not recommended)
  • 24. How does object look like? <user oid="02c15378­c48b­11e7­b010­1ff8606bae23">     <name>jack</name>     <description>Where's the rum?</description>     <fullName>Jack Sparrow</fullName>     <givenName>Jack</givenName>     <familyName>Sparrow</familyName>     <emailAddress>jack.sparrow@evolveum.com</emailAddress>     <locality>Caribbean</locality>     <activation>      <administrativeStatus>enabled</administrativeStatus>     </activation> </user> {     "name" : "jack",     "fullName" : "Jack Sparrow",     "givenName" : "Jack",      "familyName" : "Sparrow",     … XML JSON
  • 25. RESTful Operations: collection http://…./rest/users prefix type Verbs: ● GET: list objects, search (theoretically) ● POST: create new object ● DELETE: not supported ● PUT: not supported
  • 26. Search ● Query language <q:equal>     <q:path>name</q:path>     <q:value>jack</q:value> </q:equal> ● Search with POST: convenience ● Deviation from REST • Dedicated “search” resource for POST instead of GET • Should return list of URLs, but returns objects (to save round trips) http://…./rest/users/search
  • 27. HTTP verbs ● GET is safe ● POST used for many things ● DELETE deletes ● PUT is not very useful ● PATCH for modification • But POST works as well ● Typical “REST” API
  • 28. Error Codes ● 1xx: Information. Stay tuned. ● 2xx: Success. All done. ● 3xx: Redirection or “in progress” (we will get to that) ● 4xx: Client error (e.g. bad request) ● 5xx: Server error (e.g. bug in server code)
  • 29. Trivial, isn’t it? Now let’s have a look at the interesting stuff.
  • 30. Asynchronous Operations ● Operations that take a looooong time (days) ● Cannot return success (2xx) ● Solution: redirects (3xx)
  • 31. Asynchronous Operations midPointclient Modify user POST …/users/12345 Redirect 302: …/tasks/87654 Start operation: create new task Task 87654 Check task GET …/tasks/87654 200: <task>...</task>
  • 32. RPC Operations: object-related http://…/rest/tasks/c68d7770­c493­11e7­bce6­9bec1fc3b57c/suspend prefix type object identifier (OID) Verbs: ● GET: not applicable ● POST: execute the operation ● DELETE: not applicable ● PUT: not applicable op
  • 33. Object-related RPC operations ● Deviation from pure REST • Should be modeled as resource changes or separate resources … but that is a pain ● Error handling
  • 34. RPC Operations: global http://…/rest/notifyChange prefix Verbs: ● GET: not applicable ● POST: execute the operation ● DELETE: not applicable ● PUT: not applicable operation
  • 35. Global RPC operations ● Complex input and output data structures ● Huge deviation from pure REST ● It was necessary to keep the interface simple and efficient
  • 36. Next: really hard problems ...
  • 37. Security ● REST is stateless • Cookie-based sessions are out ● HTTP Basic authentication • Oh, really? ● OAuth2 / OpenID Connect • “best” practice for REST APIs ● JSON Web Tokens (JWT) • SAML tokens reinvented
  • 38. Interface Definition ● Swagger / OpenAPI • WSDL reinvented (CORBA IDL reinvented) • JSON-oriented • Still quite limited, but at least something ● REST purists hate it • Because this goes directly against hypertext principles
  • 39. Stub and Skeleton Client app t1.suspend() Interface definition stub Server suspend() {   … } skeleton HTTP POST generate code generate code Does not really works in “RESTful” APIs (yet)
  • 40. Transactions and Consistency ● Transactions (ACID) • Forget it ● Consistency • Cannot forget it, but it is tricky • Optimistic locking / MVCC is best bet • ETag (RFC7232) is a standard mechanism • But a lot of proprietary mechanisms is used instead
  • 41. Conclusion ● REST is no good for RPC … but we are going to use it anyway ● And it is practical … with some tweaks and compromises ● Future?