Not logged in : Login

About: VirtTipsAndTricksGuideCORSSetup     Goto   Sponge   NotDistinct   Permalink

An Entity of Type : atom:Entry, within Data Space : ods.openlinksw.com associated with source document(s)

AttributesValues
type
Date Created
Date Modified
label
  • VirtTipsAndTricksGuideCORSSetup
maker
Title
  • VirtTipsAndTricksGuideCORSSetup
isDescribedUsing
has creator
attachment
  • http://vos.openlinksw.com/wiki/main/VOS/VirtTipsAndTricksGuideCORSSetup/oc1.png
  • http://vos.openlinksw.com/wiki/main/VOS/VirtTipsAndTricksGuideCORSSetup/oc2.png
  • http://vos.openlinksw.com/wiki/main/VOS/VirtTipsAndTricksGuideCORSSetup/oc3.png
  • http://vos.openlinksw.com/wiki/main/VOS/VirtTipsAndTricksGuideCORSSetup/oc4.png
  • http://vos.openlinksw.com/wiki/main/VOS/VirtTipsAndTricksGuideCORSSetup/oc5.png
content
  • %META:TOPICPARENT{name="VirtTipsAndTricksGuide"}% ---+ Setting up server-side Cross-Origin Resource Sharing (CORS) with Virtuoso User agents (e.g., Web browsers) have traditionally restricted scripts within web pages by a Same Origin Policy, which allowed scripts to make requests only to resources within the same domain from which the scripts themselves originated. This restriction is meant to protect the user and their computer from "Trojan horse websites" which may appear to be safe, but which then make unsafe HTTP requests to other, invisible sites. This restriction also protects the second website from potential "Denial of Service" and other attacks, whether accidental or intentional. This policy has the unfortunate side-effect of also preventing client-side Web applications served from one website ("Origin") from retrieving data from another website ("Origin"). [[http://www.w3.org/TR/cors/][Cross-Origin Resource Sharing (CORS)]] is a mechanism intended to enable safer client-side cross-origin requests, primarily focused on data. %TOC% ---++How does CORS work? Authentication and session-management information methods are extended in several ways. * Enforcement by User Agent * A server providing a resource can include an Access-Control-Allow-Origin HTTP response header, with a value of the request's triggering script's site of origin (that is, the site which provided the script which made the request for the resource), to indicate whether access to the resource's contents may be allowed. The user agent validates that the value in this header matches the actual origin of the script which made the request. * User agents can use a "pre-flight request" to discover whether a cross-origin resource is prepared to accept requests from a given script origin, using a complex method (which we will not detail here). Again, the response is validated by the user agent. * Enforcement by Server-side Application * Server-side applications can refer to the Origin HTTP request header to discover whether the user agent deemed it a cross-origin request. Here, the server-side application enforces limitations (e.g., returning nothing, partial results, or full results) on the cross-origin requests that they are willing to service at all. ---++ CORS Setup for Virtuoso servers With Virtuoso 6 and later (specific earliest versions as noted below), CORS support may be configured at the server-level or enabled through application logic (scripting, PL, etc.). When working with older versions of Virtuoso, CORS support cannot be configured at the server-level, but it may be enabled within application logic (scripting, PL, etc.). ---+++ Application-level CORS Setup Any Virtuoso PL (VSP)-based application can implement CORS checking through well-known HTTP functions [[http://docs.openlinksw.com/virtuoso/fn_http_request_header.html][http_request_header()]] and [[http://docs.openlinksw.com/virtuoso/fn_http_header.html][http_header()]]. This method will work with any version of Virtuoso. For instance -- http://host.org\r\n'); } ELSE { RETURN; } -- Additional code here --- ?> Applications running in other hosted environments (Perl, Python, PHP, ASP.NET, etc.) may also use their specific scripting options to add and/or check relevent headers. ---+++ Server-level CORS Setup Note: These instance/server-level configuration instructions require [[VOSNews][Virtuoso Open Source (VOS) 6.1.3 or later]], or [[http://download.openlinksw.com/virtwiz/][Virtuoso Commercial Edition 6.2.3129 or later]]. 1 In the Virtuoso Conductor, go to Web Application Server -> Virtual Directories & Directories. %BR%%BR%%BR%%BR% 1 Expand the default Interface store. %BR%%BR%%BR%%BR% 1 Click New Directory. 1 Specify the desired Virtual Directory Type, or choose an existing virtual directory to use as a template. %BR%%BR%%BR%%BR% 1 Click Next. 1 Specify the Directory Path value. %BR%%BR%%BR%%BR% 1 Set the CORS options. %BR%%BR%%BR%%BR% * Cross-Origin Resource Sharing: Contains a single wildcard asterisk, i.e., "*", or a space-delimited list of HTTP server URIs, e.g., "http://example.com:8080 http://blah.example.com http://foo.example.com". Scripts originating on the listed HTTP servers are authorized to retrieve the specified resource(s); the wildcard means scripts from any HTTP server will be authorized. For this example, enter the following single URI: http://demo.openlinksw.com * Reject Unintended CORS check-box: When ticked (and the application does not overwrite headers), unmatched Origins will be rejected by sending an empty response. For this example, tick this box. 1 Click Save changes. ---++ Example Usage with cURL ---+++ cURL Example 1 1 Suppose the example setup above is performed, and http://demo.openlinksw.com/ is in the CORS list. 1 In this case, the request below will return an empty response: $ curl -i http://demo.openlinksw.com/mytest/test.vsp HTTP/1.1 200 OK Server: Virtuoso/06.02.3129 (Win32) i686-generic-win-32 VDB Connection: Keep-Alive Content-Type: text/html; charset=ISO-8859-1 Date: Thu, 28 Oct 2010 09:27:54 GMT Accept-Ranges: bytes Content-Length: 0 ---+++ cURL Example 2 1 Suppose the example setup above is performed, and http://demo.openlinksw.com/ is in the CORS list. 1 Also, suppose the curl command includes a proper Origin value, e.g., -H "Origin: . ">http://demo.openlinksw.com". 1 In this case, the request below will return a response including the retrieved content, etc. $ curl -i -H "Origin: http://demo.openlinksw.com" http://demo.openlinksw.com/mytest/test.vsp HTTP/1.1 200 OK Server: Virtuoso/06.02.3129 (Win32) i686-generic-win-32 VDB Connection: Keep-Alive Content-Type: text/html; charset=ISO-8859-1 Date: Thu, 28 Oct 2010 09:40:21 GMT Access-Control-Allow-Origin: http://demo.openlinksw.com Accept-Ranges: bytes Content-Length: 7 ---+++ cURL Example 3 1 Suppose the Example Setup above is performed, but reject is off (i.e., "Reject Unintended CORS" check-box is not ticked). 1 In this case, the request below will return a response that lacks Access-Control-Allow-Origin: $ curl -i http://demo.openlinksw.com/mytest/test.vsp HTTP/1.1 200 OK Server: Virtuoso/06.02.3129 (Win32) i686-generic-win-32 VDB Connection: Keep-Alive Content-Type: text/html; charset=ISO-8859-1 Date: Thu, 28 Oct 2010 09:45:01 GMT Accept-Ranges: bytes Content-Length: 7 ---++Related * [[VirtTipsAndTricksCORsEnableSPARQLURLs][Cross-Origin Resource Sharing (CORS) to enable a Virtuoso SPARQL Endpoint]] * [[https://wiki.mozilla.org/Security/Origin][Origin header proposal for CSRF and click-jacking mitigation]] * [[http://arunranga.com/examples/access-control/][CORS In Action]] * [[http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/][Cross-domain Ajax with Cross-Origin Resource Sharing]] * [[http://code.google.com/p/html5security/wiki/CrossOriginRequestSecurity][Guide to Secure Implementation of Cross Origin Requests in HTML5]] * [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]]
id
  • 58709df51e604103f3b22cba66fe309c
link
has container
http://rdfs.org/si...ices#has_services
atom:title
  • VirtTipsAndTricksGuideCORSSetup
links to
atom:source
atom:author
atom:published
  • 2017-06-13T05:41:46Z
atom:updated
  • 2017-06-13T05:41:46Z
topic
is made of
is container of of
is link of
is http://rdfs.org/si...vices#services_of of
is creator of of
is atom:entry of
is atom:contains of
Faceted Search & Find service v1.17_git132 as of May 12 2023


Alternative Linked Data Documents: iSPARQL | ODE     Content Formats:   [cxml] [csv]     RDF   [text] [turtle] [ld+json] [rdf+json] [rdf+xml]     ODATA   [atom+xml] [odata+json]     Microdata   [microdata+json] [html]    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 08.03.3332 as of Sep 11 2024, on Linux (x86_64-generic-linux-glibc25), Single-Server Edition (15 GB total memory, 1 GB memory in use)
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2024 OpenLink Software