github / github/codespaces-rails

AuthenticityToken Missmatch on CRUD after Port Forwarding

オープン
#37 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
Ruby
スター
148
フォーク
121
平均マージ
4日 12時間
マージ済み PR(30日)
2

説明

I am encountering forgery protection issue when I try to do regular CRUD operations that connected to postgres like normal, so everytime I did POST action, the console throws message below:

```
ActionController::InvalidAuthenticityToken (HTTP Origin header (http://localhost:3000) didn't match request.base_url (https://{space-name}-{space-id}-3000.app.github.dev)
```

So far, [this answer (22965)](https://github.com/rails/rails/issues/22965#issuecomment-172983268) can solve the problem, which suggest to add:

```ruby
config.action_controller.forgery_protection_origin_check = false
```
to _development.rb_, or put

```ruby
skip_forgery_protection
```
on _application_controller.rb_

I still feel uncomfortable with this approach since I can't do the rails standards, I've been doing this just fine in another IDE like **Gitpod** or **AWS Cloud9**, but it's just different here. I'm trying figuring out on the VM level try to modify nginx config until I realize that codespaces service might run inside a container LOL. I still think that this because I'm not sure how port forwarding works in this service, but if that's the reason, why I can still access the app only with GET requests?

Some help/ guidance from official team would be nice!

cc @joshaber @samruddhikhandale @bdmac

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、ポートフォワーディングされた Codespaces アプリで POST の失敗を再現し、報告で言及されている development.rb と application_controller.rb のオプションを調べます。転送されたリクエストの origin と request.base_url を比較し、nginx またはコンテナのポートフォワーディング設定を確認します。設定の不一致を特定し、偽造防止機能を無効化せずに標準に準拠した修正を文書化できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rails, ruby
領域
backend, infrastructure, security
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。