# 세션\["omniauth.state"\] 누락으로 인한 "Authentication failure! csrf\_detected: OmniAuth::Strategies::OAuth2::CallbackError" 오류

**URL:** https://meta.discourse.org/t/authentication-failure-csrf-detected-omniauth-callbackerror-error-due-to-missing-session-omniauth-state/153222
**Category:** SSO
**Tags:** unsupported-install
**Created:** [5월 29, 2020, 12:32오후 UTC](https://meta.discourse.org/t/authentication-failure-csrf-detected-omniauth-callbackerror-error-due-to-missing-session-omniauth-state/153222 "2020-05-29T12:32:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Arvind\_Hebbal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arvind_hebbal/32/143497_2.png) [@Arvind\_Hebbal](https://meta.discourse.org/u/Arvind_Hebbal)
#### Post date: [5월 29, 2020, 12:32오후 UTC](https://meta.discourse.org/t/authentication-failure-csrf-detected-omniauth-callbackerror-error-due-to-missing-session-omniauth-state/153222/1 "2020-05-29T12:32:09Z")

</div>

안녕하세요,

프로덕션 모드에서 Discourse 포럼을 배포하려고 합니다. 자체 OAuth 제공자를 사용하므로, 이를 위해 discourse-oauth2-basic 플러그인을 활용하고 있습니다.

자체 OAuth 제공자로 로그인할 때 다음과 같은 오류가 발생합니다:

“Authentication failure! csrf\_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf\_detected | CSRF detected”

디버깅을 진행한 결과, 리다이렉트가 발생한 후 세션에서 "omniauth.state"가 누락되어 /auth/oauth2\_callback에서 state 필드를 검증하지 못하는 것으로 확인되었습니다. 도움이 필요하여 문의드립니다.

참고: 해당 설정은 개발 모드에서는 정상적으로 작동합니다.

감사합니다.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [5월 29, 2020, 12:36오후 UTC](https://meta.discourse.org/t/authentication-failure-csrf-detected-omniauth-callbackerror-error-due-to-missing-session-omniauth-state/153222/2 "2020-05-29T12:36:55Z")

</div>

인증이 같은 브라우저에서 시작되고 종료되나요? 기본 `same site cookies` 설정 값을 변경해 보셨나요?

---

<div class="post-metadata">

### Author: ![Arvind\_Hebbal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arvind_hebbal/32/143497_2.png) [@Arvind\_Hebbal](https://meta.discourse.org/u/Arvind_Hebbal)
#### Post date: [5월 29, 2020, 2:05오후 UTC](https://meta.discourse.org/t/authentication-failure-csrf-detected-omniauth-callbackerror-error-due-to-missing-session-omniauth-state/153222/3 "2020-05-29T14:05:59Z")

</div>

네, @david 인증은 동일한 브라우저에서 시작되고 종료됩니다. same\_site\_cookies 값은 변경하지 않았습니다. 기본값인 "Lax"로 설정되어 있습니다.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [5월 29, 2020, 2:08오후 UTC](https://meta.discourse.org/t/authentication-failure-csrf-detected-omniauth-callbackerror-error-due-to-missing-session-omniauth-state/153222/4 "2020-05-29T14:08:13Z")

</div>

저희의 표준 [설치 가이드](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md)를 따르고 계신가요?

불행히도 사이트의 현황을 확인할 수 없다면 여기서 도움을 드리기 매우 어렵습니다. 링크를 공유해 주실 수 있나요?

---

<div class="post-metadata">

### Author: ![Arvind\_Hebbal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arvind_hebbal/32/143497_2.png) [@Arvind\_Hebbal](https://meta.discourse.org/u/Arvind_Hebbal)
#### Post date: [5월 29, 2020, 2:48오후 UTC](https://meta.discourse.org/t/authentication-failure-csrf-detected-omniauth-callbackerror-error-due-to-missing-session-omniauth-state/153222/5 "2020-05-29T14:48:16Z")

</div>

안녕하세요 @david. 저희는 Docker 컨테이너를 사용하여 Discourse를 배포(hoisting)하고 있습니다. 현재 사용 중인 Dockerfile은 [discourse\_docker/image/base at master · discourse/discourse\_docker · GitHub](https://github.com/discourse/discourse_docker/tree/master/image/base) 입니다. Docker 컨테이너 내에서 Discourse를 시작하는 스크립트가 없으므로, Discourse를 사전 컴파일하고 시작하는 작은 시작 스크립트를 추가했습니다.  
RAILS\_ENV=production bundle exec rake db:migrate  
RAILS\_ENV=production bundle exec rake assets:precompile  
RAILS\_ENV=production bundle exec rails server --binding=0.0.0.0

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [5월 29, 2020, 2:51오후 UTC](https://meta.discourse.org/t/authentication-failure-csrf-detected-omniauth-callbackerror-error-due-to-missing-session-omniauth-state/153222/6 "2020-05-29T14:51:35Z")

</div>

불행히도 커스텀 설치에 대한 커뮤니티 지원을 제공하기가 매우 어렵습니다. [공식 가이드](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md)를 사용하여 Discourse를 설정해 보시기 바랍니다. 그렇게 할 수 없다면, #Marketplace 채널에서 유료로 도움을 주실 수 있는 분이 있을 수도 있습니다.
