13 - Cross-Origin Resource Sharing Flashcards
(22 cards)
restricts how a document/script from one origin can interact with a resource from another origin
Same-Origin Policy
two web pages have the same origin if they have the same (3)
- protocol
- host/domain
- port
a page attempting to interact with a resource from a different origin is making a ____
Cross-Origin Request
Determine if the following requests are cross-origin requests:
a. http://localhost:3001 => http://localhost:3000
b. http://myapp.com => https://myapp.com
c. http://myapp.com => http://myapp.com/about
d. https://myapp.com => https://blog.myapp.com
e. http://myapp.com => http://myapp.com:81
a. Cross-Origin
b. Cross-Origin
c. Same Origin
d. Cross-Origin
e. Cross-Origin
true/false
the website/web server restricts cross-origin HTTP requests
false, it is the browser that restricts such requests
what are the exceptions to cross-origin requests (4)
- embedded requests
- cross-origin writes
- images
- linked stylesheets
why restrict cross-origin access?
cross-origin requests are a vector for online attacks, they are a way to steak cookies and can give an attacker access to a user’s sensitive information
what do we do if we really need to access resources from another origin?
use cross-origin resource sharing
a system that allows resources to be accessed across different origins
Cross-Origin Resource Sharing (CORS)
are used by clients and servers to determine if the client can access the server’s resources
access-control headers
what access-control header specifies which origins are allowed access
access-control-allow-origin
what access-control header indicates if sending credentials are allowed
access-control-allow-credentials
what access-control header indicates which http methods are allowed to be used for incoming requests
access-control-allow-methods
what access-control header indicates which headers are allowed to be used for incoming requests
access-control-allow-headers
some cross-origin requests trigger a ____
preflight request
automatically issued by the browser before sending some kinds of cross-origin requests
preflight requests
it is a ‘preflight’ check to see if the actual request will be accepted and processed
preflight requests
all preflight requests are ____ requests with particular headers
OPTIONS HTTP
what are the 3 particular headers of preflight requests
- Access-Control-Request-Method
- Access-Control-Request-Headers
- origin
before the browser sends the actual request, it sends a/an ___ request to ask if the actual request will be allowed
OPTIONS
true/false
requests that will cause some sort of change in the server’s data will only trigger a preflight request if specified in the header
false, any request that will cause change in the server’s data will trigger a preflight request
___ requests don’t trigger a preflight and only look for the ____ header in the response
Simple, Access-Control-Allow-Origin