Cross-origin
교차 출처
For example, YouTube video sharing is a cross-source.
예를 들어, 유튜브 영상 공유하기는 교차 출처에 해당된다.
Because it will request the video data of the YouTube server from the shared location.
공유된 위치에서 유튜브 서버의 영상 자료를 요청하게되기 때문.
Conversely, viewing YouTube videos on YouTube sites is the Same-origin.
반대로, 유튜브 사이트에서 유튜브 영상을 보는 것은 동일 출처에 해당한다.
CORS(Cross-Origin Resource Sharing)
교차 출처 자원 공유
Mechanism used to verify the safety of a resource request from a other domain not original domain(Cross-origin).
원래의 도메인이 아닌 다른 도메인(교차 출처)의 자원 요청 시, 안전성을 확인하기 위해, 사용되는 메커니즘.
If CORS is enabled, data from other domains can be retrieved.
CORS가 허용(enabled)된 경우, 타 도메인의 자료를 불러올 수 있다.
You can import data (cross-origin) from other domains without restriction by using <img>, <src> tags, etc. However, there is a case importing from only the same domain(Same-origin).
<img>, <src> 태그 등을 이용하면 제한 없이 타 도메인의 자료(교차 출처, Cross-Origin)를 가져올 수 있지만, 보안 등의 이유로 동일 도메인의 자료(동일 출처, Same-Origin)만 허용된 경우가 있다.
When applied to a Same-Origin policy for security reasons, CORS must be allowed to use cross-origin data.
보안 등의 이유로 동일 출처 정책(Same-Origin policy)에 적용받는 경우 CORS가 허용되어야만 교차 출처의 자료를 사용할 수 있다.
A representative example: XMLHttpRequest.
대표적 예시: XMLHttpRequest.
XMLHttpRequest can only use data from the same domain because the same origin policy applied.
XMLHttpRequest는 동일 출처 정책(Same-Origin policy)이 적용되어 동일한 도메인의 자료만 사용할 수 있다.
However, if CORS is enabled on a server, it can use the requested data even if the server is a different domain.
하지만 CORS가 허용(enabled)된 서버가 있다면, 그 서버가 다른 도메인이어도 요청한 자료를 사용할 수 있다.
There are three types of CORS, and the method is determined according to the content of the request message(header).
CORS는 크게 3가지 유형으로 구분되며, 요청 메시지(헤더)의 내용에 따라 그 방식이 결정된다.
1. Simple request
Adding a header entry "Origin" to the request message for recording which domain sent the request.
1. 간단한 요청(simple)
요청 메시지에 "Origin" 이라는 헤더 항목을 추가하여 어느 도메인에서 발송된 요청인지 기록하는 방식.
The "ACAO" header field in the response message confirms whether CORS is allowed.
응답 메시지에 "ACAO" 헤더 항목을 통해 CORS 허용 여부를 확인할 수 있다.
For example, if the response message contains the ACAO header entry "Access-Control-Allow-Origin: http://a.com", only "a.com" is allowed in CORS.
예를 들어, 응답 메시지에 "Access-Control-Allow-Origin: http://a.com"이란 ACAO 헤더 항목이 포함되었다면 "a.com"만 CORS가 허용된다.
2. Preflight request.
It is the method of sending a preflight to verify that a response to a cross-origin request is possible.
2. 사전 요청(preflight)
교차 출처 요청에 대한 응답이 가능한지를 확인하기 위해, 사전 요청(preflight)을 보내어 확인하는 방식.
3. Credential request.
A method of transmitting authentication information on request.
3. 인증 요청(Credential)
요청 시 인증 정보를 담아 전송하는 방식.
Only authenticated domains are allowed in CORS.
인증된 도메인만이 CORS가 허용된다.