Class CrossOriginHandler

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
All Implemented Interfaces:
Handler, Handler.Container, Handler.Singleton, Request.Handler, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle, org.eclipse.jetty.util.thread.Invocable

@ManagedObject public class CrossOriginHandler extends Handler.Wrapper

Implementation of the CORS protocol defined by the fetch standard.

This Handler should be present in the Handler tree to prevent cross site request forgery attacks.

A typical case is a web page containing a script downloaded from the origin server at domain.com, where the script makes requests to the cross server at cross.domain.com. The cross server at cross.domain.com has the CrossOriginHandler installed and will see requests such as:


 GET / HTTP/1.1
 Host: cross.domain.com
 Origin: http://domain.com
 

The cross server at cross.domain.com must decide whether these cross-origin requests are allowed or not, by configuring the CrossOriginHandler allowed origins to contain only the origin server with origin http://domain.com.

The cross server must also decide whether cross-origin requests are allowed to contain credentials (cookies and authentication headers) or not, by configuring setAllowCredentials(boolean).

By default, no origin is allowed, and credentials are not allowed.