SlideShare a Scribd company logo
1 of 24
CORS
6 Nov 2013 / 14 Nov 2013
Jared Ottley / Alfresco Software

#SummitNow
CORS
6 Nov 2013 / 14 Nov 2013
Jared Ottley / Alfresco Software

#SummitNow
3

What is CORS?
Cross-Origin Resource Sharing
• Cross Domain AJAX Calls
• Implemented in Browser and Server

#SummitNow
#SummitNow
4

What Browsers Support CORS?

4.0+

3.5+

12.0+

4.0+

Partial
8&9
10+
#SummitNow
#SummitNow
5

How Does CORS Work?
Nothing to implement in your javascript.
The Browser & the Server do the heavy
lifting.

#SummitNow
#SummitNow
6

How Does CORS Work?

OPTIONS

Browser
API Request

#SummitNow
#SummitNow
7

Example Code
$.ajax ({
type: ”HTTP METHOD”, url: “Place to go to”,
dataType: 'json’, async: false,
data: '{}',
beforeSend: function (xhr){
xhr.setRequestHeader('Authorization', setAuthTokenHere() },
success: function (response){
//do something
},
failure: function (response) {
//do something
}
});
#SummitNow
#SummitNow
8

What About the Server Side?
Alfresco does not ship with CORS support.

Alfresco uses CORS as part of “Alfresco for
Salesforce” to talk to Alfresco Cloud.

#SummitNow
#SummitNow
9

How to Enable CORS in
Alfresco

Add the following jars to WEB-INF/lib
cors-filter
java-property-utils
Both can be found at
http://software.dzhuvinov.com/cors-filter.html

#SummitNow
#SummitNow
10

How to Enable CORS in
Alfresco
Modify WEB-INF/web.xml

<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/service/*</url-pattern>
</filter-mapping>

#SummitNow
#SummitNow
11

How to Enable CORS in
Alfresco

What services will be called by your app?
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/service/*</url-pattern>
<url-pattern>/cmisatom/*</url-pattern>
<url-pattern>/cmisbrowser/*</url-pattern>
</filter-mapping>

#SummitNow
#SummitNow
12

How to Enable CORS in
Alfresco
OPTIONS

Browser

Authentication

API Request

#SummitNow
#SummitNow
13

How to Enable CORS in
Alfresco

Filter can be placed anywhere in web.xml

However…
Filter mapping MUST be before
authentication filters

#SummitNow
#SummitNow
14

How to Enable CORS in
Alfresco

Place after Global Localization Filter but
before CMIS security context cleaning filter.
• This is true for 4.2…but may not be true
for other versions of Alfresco.
• By rule BEFORE any
security/authentication filters

#SummitNow
#SummitNow
15

Filter Configuration
By default the CORS Filter will apply a "public access"
CORS policy, allowing all cross-site requests through
(including credentials/cookies). Leaving the CORS
Filter at this setting would actually be fine for most
situations as CORS is not about adding server
security; its primary intent is to protect the browser the legitimate JavaScript apps running in it and the
user's confidential data, such as cookies.

#SummitNow
#SummitNow
16

Filter Configuration (cont.)
cors.configurationFile properties file
Setting the location using
• System Property (-D)
• init-param
Or
Individual init-param

#SummitNow
#SummitNow
17

Filter Configuration (cont.)
Do not change the following defaults:
• cors.allowGenericHttpRequests {true|false} defaults to
true
• cors.supportsCredentials {true|false} defaults to true.
cors.maxAge {int} defaults to -1 (unspecified)
• How long should pre-flight requests be cached.
• Recommended value is 3600 (1 hour)

#SummitNow
#SummitNow
18

Filter Configuration (cont.)
cors.allowOrigin {"*"|origin-list} defaults to *
• Which calling domains are allowed?
• ex: http://alfresco.com https://www.alfresco.com
• Returns 403 if the domain is not allowed

#SummitNow
#SummitNow
19

Filter Configuration (cont.)
cors.allowSubdomains {true|false} defaults
to false
• Your application may run in a hosted
service where the subdomain is
dynamically assigned ex.
salesforce.com
• ex. https://na14.salesforce.com
#SummitNow
#SummitNow
20

Filter Configuration (cont.)
cors.supportedMethods {method-list}
defaults to "GET, POST, HEAD, OPTIONS”
cors.supportedHeaders {"*"|header-list}
defaults to *
• origin, authorization, accept

#SummitNow
#SummitNow
21

Filter Configuration (cont.)
cors.exposedHeaders {header-list} defaults
to empty list
• Response headers limited to: CacheControl, Content-Language, ContentType, Expires, Last-Modified Pragma
• Add additional headers to be exposed

#SummitNow
#SummitNow
22

Demo

#SummitNow
#SummitNow
23

CORS
Resources
http://software.dzhuvinov.com/cors-filter.html
https://bitbucket.org/thetransactioncompany/cors-filter
http://www.w3.org/TR/cors/
http://en.wikipedia.org/wiki/Cross-origin_resource_sharing

#SummitNow
#SummitNow
24

CORS
Resources
http://software.dzhuvinov.com/cors-filter.html
https://bitbucket.org/thetransactioncompany/cors-filter
http://www.w3.org/TR/cors/
http://en.wikipedia.org/wiki/Cross-origin_resource_sharing

#SummitNow
#SummitNow

More Related Content

What's hot

Content Management With Apache Jackrabbit
Content Management With Apache JackrabbitContent Management With Apache Jackrabbit
Content Management With Apache Jackrabbit
Jukka Zitting
 
Alfresco search services: Now and Then
Alfresco search services: Now and ThenAlfresco search services: Now and Then
Alfresco search services: Now and Then
Angel Borroy López
 
Alfresco Share - Recycle Bin Ideas
Alfresco Share - Recycle Bin IdeasAlfresco Share - Recycle Bin Ideas
Alfresco Share - Recycle Bin Ideas
AlfrescoUE
 

What's hot (20)

Testing in airflow
Testing in airflowTesting in airflow
Testing in airflow
 
Content Management With Apache Jackrabbit
Content Management With Apache JackrabbitContent Management With Apache Jackrabbit
Content Management With Apache Jackrabbit
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
 
Inside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source DatabaseInside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source Database
 
Simplified Android Development with Simple-Stack
Simplified Android Development with Simple-StackSimplified Android Development with Simple-Stack
Simplified Android Development with Simple-Stack
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JS
 
Windows container security
Windows container securityWindows container security
Windows container security
 
JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdf
 
Alfresco search services: Now and Then
Alfresco search services: Now and ThenAlfresco search services: Now and Then
Alfresco search services: Now and Then
 
Alfresco Share - Recycle Bin Ideas
Alfresco Share - Recycle Bin IdeasAlfresco Share - Recycle Bin Ideas
Alfresco Share - Recycle Bin Ideas
 
MongodB Internals
MongodB InternalsMongodB Internals
MongodB Internals
 
Malicious Payloads vs Deep Visibility: A PowerShell Story
Malicious Payloads vs Deep Visibility: A PowerShell StoryMalicious Payloads vs Deep Visibility: A PowerShell Story
Malicious Payloads vs Deep Visibility: A PowerShell Story
 
Building highly scalable data pipelines with Apache Spark
Building highly scalable data pipelines with Apache SparkBuilding highly scalable data pipelines with Apache Spark
Building highly scalable data pipelines with Apache Spark
 
Osgi
OsgiOsgi
Osgi
 
Webinar: MongoDB Schema Design and Performance Implications
Webinar: MongoDB Schema Design and Performance ImplicationsWebinar: MongoDB Schema Design and Performance Implications
Webinar: MongoDB Schema Design and Performance Implications
 
InjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdf
InjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdfInjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdf
InjectionIII의 Hot Reload를 이용하여 앱 개발을 좀 더 편하게 하기.pdf
 
JSON-LD and MongoDB
JSON-LD and MongoDBJSON-LD and MongoDB
JSON-LD and MongoDB
 
Take Action with Forge Triggers
Take Action with Forge TriggersTake Action with Forge Triggers
Take Action with Forge Triggers
 
Event sourcing with reactor and spring statemachine
Event sourcing with reactor and spring statemachineEvent sourcing with reactor and spring statemachine
Event sourcing with reactor and spring statemachine
 
Spring boot 를 적용한 전사모니터링 시스템 backend 개발 사례
Spring boot 를 적용한 전사모니터링 시스템 backend 개발 사례Spring boot 를 적용한 전사모니터링 시스템 backend 개발 사례
Spring boot 를 적용한 전사모니터링 시스템 backend 개발 사례
 

Similar to CORS - Enable Alfresco for CORS

Mobile webapplication development
Mobile webapplication developmentMobile webapplication development
Mobile webapplication development
Ganesh Gembali
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
WSO2
 

Similar to CORS - Enable Alfresco for CORS (20)

Mobile webapplication development
Mobile webapplication developmentMobile webapplication development
Mobile webapplication development
 
Of CORS thats a thing how CORS in the cloud still kills security
Of CORS thats a thing how CORS in the cloud still kills securityOf CORS thats a thing how CORS in the cloud still kills security
Of CORS thats a thing how CORS in the cloud still kills security
 
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...
WebCamp: Developer Day: Web Security: Cookies, Domains and CORS - Юрий Чайков...
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
maxbox starter72 multilanguage coding
maxbox starter72 multilanguage codingmaxbox starter72 multilanguage coding
maxbox starter72 multilanguage coding
 
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
UEMB200: Next Generation of Endpoint Management Architecture and Discovery Se...
 
Scout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicagoScout xss csrf_security_presentation_chicago
Scout xss csrf_security_presentation_chicago
 
W3 conf hill-html5-security-realities
W3 conf hill-html5-security-realitiesW3 conf hill-html5-security-realities
W3 conf hill-html5-security-realities
 
Web program-peformance-optimization
Web program-peformance-optimizationWeb program-peformance-optimization
Web program-peformance-optimization
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Hard learned CSOM and REST tips
Hard learned CSOM and REST tipsHard learned CSOM and REST tips
Hard learned CSOM and REST tips
 
Edge of the Web
Edge of the WebEdge of the Web
Edge of the Web
 
Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)
 
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
 
Applciation footprinting, discovery and enumeration
Applciation footprinting, discovery and enumerationApplciation footprinting, discovery and enumeration
Applciation footprinting, discovery and enumeration
 
Standardized API Development using Node.js
Standardized API Development using Node.jsStandardized API Development using Node.js
Standardized API Development using Node.js
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
 
Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
 

More from Jared Ottley

More from Jared Ottley (6)

Developing for Glass & Alfresco
Developing for Glass & AlfrescoDeveloping for Glass & Alfresco
Developing for Glass & Alfresco
 
Alfresco Rumors: XMPP Enable Alfresco nodes (POC)
Alfresco Rumors: XMPP Enable Alfresco nodes (POC)Alfresco Rumors: XMPP Enable Alfresco nodes (POC)
Alfresco Rumors: XMPP Enable Alfresco nodes (POC)
 
Alfresco for Salesforce
Alfresco for SalesforceAlfresco for Salesforce
Alfresco for Salesforce
 
Alfresco Integrations - Alfresco Devcon 2012
Alfresco Integrations - Alfresco Devcon 2012Alfresco Integrations - Alfresco Devcon 2012
Alfresco Integrations - Alfresco Devcon 2012
 
Spring Social, Alfresco and Spring-Social-Alfresco
Spring Social, Alfresco and Spring-Social-AlfrescoSpring Social, Alfresco and Spring-Social-Alfresco
Spring Social, Alfresco and Spring-Social-Alfresco
 
Jive, dropbox and other integrations
Jive, dropbox and other integrationsJive, dropbox and other integrations
Jive, dropbox and other integrations
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

CORS - Enable Alfresco for CORS