forked from codebygina/mediumish-theme-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 72
5월 FE 블로그 포스팅 #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
SSUHYUNKIM
merged 3 commits into
GDSC-University-of-Seoul:master
from
Hyunsoo-ds:post/hyunsoo
Oct 31, 2023
Merged
5월 FE 블로그 포스팅 #287
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,127 @@ | ||||||
| --- | ||||||
| layout: post | ||||||
| title: "Same-Origin-Policy란 무엇일까?" | ||||||
| authors: [Hyunsoo-ds] | ||||||
| tags: ["web",'security'] | ||||||
| image: ../assets/images/post-what-is-same-origin-policy/thumbnail.png | ||||||
| featured: true | ||||||
| --- | ||||||
| # **시작** | ||||||
|
|
||||||
| 웹 사이트를 개발하며 외부 API를 이용하다 보면 다음과 같은 오류들을 마주하기도 합니다. | ||||||
|
|
||||||
| >``` Access to XMLHttpRequest at '...' from origin '..' has be blocked by CORS policy ``` | ||||||
|
|
||||||
| 이때 위의 오류코드에서 CORS는 Cross Origin Resource Sharing을 의미하는데 이 오류가 무슨 의미이고 왜 이런 오류가 발생하는 것일까요? | ||||||
|
|
||||||
| 이 오류가 발생하게 하는 규칙인 **SOP(Same-Origin-Policy)** 에 대해 제가 공부한 내용을 간단히 적어보고자 합니다. | ||||||
|
|
||||||
|
|
||||||
| # **SOP(Same-Origin-Policy)** | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| MDN 문서에 따르면 | ||||||
| >SOP는 한 Origin 에서 불러온 문서 또는 스크립트가 다른 Origin의 리소스와 상호작용할 수 있는 방법을 제한하는 보안 메커니즘이라고 합니다. | ||||||
|
|
||||||
| 쉽게 풀어 말하면 웹 브라우저에서 동작하는 문서 또는 스크립트가 로딩된 위치에 있는 리소스에만 접근할 수 있음을 의미합니다. | ||||||
|
|
||||||
| 그 전에 Origin이 무엇을 의미하는지 간단하게 알아 봅시다. | ||||||
|
|
||||||
| # **Origin** | ||||||
|
|
||||||
| 오리진은 브라우저가 가져온 정보의 출처를 의미합니다. 그리고 오리진은 크게 프로토콜(Protocol, Scheme), 포트(Port), 호스트(Host)로 구성됩니다. | ||||||
|
|
||||||
| 이 때 오리진의 구성요소가 모두 일치해야지 동일한 오리진으로 판정됩니다. | ||||||
|
|
||||||
| > ``` https://home.hyunsoo-uos.com:1001/homework.html ``` | ||||||
|
|
||||||
| 위의 주소를 예시로 오리진의 각각의 구성 요소들이 URL의 어떤 부분을 구성하는지 설명하겠습니다. | ||||||
|
|
||||||
| * ## **protocol** | ||||||
|
|
||||||
| * 위의 예시에서 'https'에 해당함 | ||||||
| * protocol 또는 scheme이라고도 하며 대표적인 scheme으로 http, https, mail 등이 있다. | ||||||
|
|
||||||
| * ## **host** | ||||||
|
|
||||||
| * 위의 예시에서 'home.hyunsoo-uos.com'에 해당함 | ||||||
| * 'mail.hyunsoo-uos.com'과 같이 도메인이 같더라도 다른 host일 수도 있다. | ||||||
|
|
||||||
| * ## **port** | ||||||
|
|
||||||
| * 위의 예시에서 ':1001' 해당함 | ||||||
|
||||||
| * 위의 예시에서 ':1001' 해당함 | |
| * 위의 예시에서 ':1001'에 해당함 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
통일성을 위해 오리진을 모두 영어로 바꾸거나, 뒷부분처럼 오리진(Origin)과 같은 방식으로 표기하면 더 좋을 것 같아요