0
1

More than 3 years have passed since last update.

[Rails] Microsoft TeamsのタブにRedmineを表示する

Posted at

TeamsのタブにRedmineを表示したい

Teamsには、任意のWebサイトをタブに表示する機能があります。

image.png

けど、できない

RailsアプリはデフォルトでX-Frame-Options: SAMEORIGINヘッダを出力するようになっているので、iframeを使っているTeamのタブには表示されません。

HTTPヘッダを変更する

Railsアプリの出力するHTTPヘッダは、/usr/lib/ruby/vendor_ruby/action_dispatch/railtie.rbに設定されています。

config.action_dispatch.default_headers = {
  'X-Frame-Options' => 'SAMEORIGIN',
  'X-XSS-Protection' => '1; mode=block',
  'X-Content-Type-Options' => 'nosniff'
}

これを書き換えるのは乱暴ですので、Redmineの設定で上書きします。

/usr/share/redmine/config/additional_environment.rb ファイルを作成します。

config.action_dispatch.default_headers = {
  'Content-Security-Policy' => 'frame-src https://teams.microsoft.com/',
  'X-XSS-Protection' => '1; mode=block',
  'X-Content-Type-Options' => 'nosniff'
}

X-Frame-Optionsの代わりに、Content-Security-Policyを設定しました。

Teams全体からiframe使えちゃいますが、ないよりはマシかなぁ的な。

Apacheを再起動

設定を有効にします。

systemctl restart apache2

環境

  • Redmine 3.4.4
  • Ruby 2.5.1
  • Ubuntu 18.04

リンク

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1