Skip to content

Commit

Permalink
(#827) configure cors, cross domain cookie options
Browse files Browse the repository at this point in the history
  • Loading branch information
kimjson committed Sep 12, 2021
1 parent 39355d4 commit 5cdb0d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/session/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def user_login(request):
def login_callback(request):
state_before = request.session.get("sso_state", None)
state = request.GET.get("state", None)
# TODO: server host 를 유지한채로 행해지는 모든 리디렉트 응답에 대해 새로운 리액트 앱 호스트를 사용한다
if state_before is None or state_before != state:
return HttpResponseRedirect("/error/invalid-login")

Expand Down
13 changes: 13 additions & 0 deletions otlplus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@

ALLOWED_HOSTS = []

CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_ALL_ORIGINS = DEBUG
CORS_ALLOWED_ORIGINS = [
"https://otl.kaist.ac.kr",
]
CSRF_TRUSTED_ORIGINS = [
"localhost:3000" if DEBUG else "otl.kaist.ac.kr",
]

SESSION_COOKIE_SAMESITE = None

# Application definition

INSTALLED_APPS = (
Expand All @@ -44,9 +55,11 @@
"apps.review.appss.ReviewConfig",
"apps.subject.appss.SubjectConfig",
"apps.timetable.appss.TimetableConfig",
"corsheaders",
)

MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.locale.LocaleMiddleware",
Expand Down

0 comments on commit 5cdb0d4

Please sign in to comment.