LoginSignup
9
7

More than 1 year has passed since last update.

Redmineに2段階認証プラグインを導入する(v4.2以前)

Last updated at Posted at 2020-02-21

はじめに

  • Redmine4.2からワンタイムパスワードによる二要素認証機能が実装されているようです
  • 影響なければ素直にRedmineをVUPしましょう
  • この記事はなんらかの理由でRedmineがVUPできない方向けです

概要

  • サービスを利用する上で認証は大事ですよね? ID/PW認証は破られるものです
  • 今回Redmineのセキュリティを高める為に2段階認証プラグインを導入しました
  • プラグインの導入手順とかをまとめています

実行環境

  • EC2(AmazonLinux)
  • Redmine 4.1.0
  • ruby 2.7.0
  • Rails 5.2.4.1
  • gem 3.1.2
  • mysql 5.7.29

実施したこと

  1. プラグインのインストール
  2. 送信元Gmailアカウントの設定
  3. Redmineサーバの設定
  4. Redmine利用ユーザの設定

手順

1. プラグインのインストール

一般的なRedmineプラグインインストールの手順です
Railsのバージョンによりつまずきます

cd /path/to/redmine/plugin
git clone https://github.com/matsukei/redmine_out_of_band_auth.git
cd /path/to/redmine
bundle install
bundle exec rake redmine:plugins:migrate NAME=redmine_out_of_band_auth RAILS_ENV=production

ここでエラー。

StandardError: An error has occurred, all later migrations canceled:
Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class CreateAuthSourceOutOfBands < ActiveRecord::Migration[4.2]

~~略~~
vim /path/to/redmine/plugins/redmine_out_of_band_auth/db/migrate/001_create_auth_source_out_of_bands.rb

前: class CreateAuthSourceOutOfBands < ActiveRecord::Migration
後: class CreateAuthSourceOutOfBands < ActiveRecord::Migration[4.2]
  • もう一度実行して解消。
bundle exec rake redmine:plugins:migrate NAME=redmine_out_of_band_auth RAILS_ENV=production
2. メール送信用Googleアカウントの設定
  • ワンタイムパスワードをユーザに送るためのGoogleアカウントを作成(既存で持っているものでもOKです)
  • 他のアプリからGoogleのサービスを利用する場合、アカウントのパスワードではなくアプリ用のパスワードを作成して利用する必要があります
  • Googleでアカウント作成後、「アカウント管理」→「セキュリティ」から2段階認証設定をする
  • アプリパスワードから、Redmineメール送信用のアプリパスワードを作成する(名前は適当でOK)
  • :bomb: 16桁のパスワードは作成時しか確認できないためどこかにメモること
3. Redmineサーバの設定

configファイルに記載してRedmineを再起動します

vim /path/to/redmine/config/configuration.yml
  • 以下を記載します
default:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      enable_starttls_auto: true
      address: "smtp.gmail.com"
      port: 587
      domain: "smtp.gmail.com"
      authentication: :plain
      user_name: "作成したGoogleアカウントのメールアドレス"
      password: "作成したアプリパスワード"
  • Redmineを再起動します。問題なくアクセスできればOKです
service httpd restart
4. Redmine利用ユーザの設定
  • メール通知を設定し、そもそもRedmineでメール通知ができるかを確認します
  • ユーザのメール認証を有効にします

Redmineに管理者ユーザでログイン
「管理」→「設定」→「メール通知」から、送信元メールアドレスにメール送信用Googleアカウントのアドレスを記載
スクリーンショット 2020-02-21 12.16.32.png
右下の「テストメール送信」からログインしたユーザのアドレスにテストメールが送信されれば、メール通知の設定はOK
「534-5.7.14 ~~~~」のようなエラーが出たら、アプリパスワードの設定ミスを疑ってください

「管理」→「ユーザ」→「メール通知」から、利用ユーザのアドレスとアウトオブバンド認証を有効にする
スクリーンショット 2020-02-21 12.25.12.png
実際にログインし、以下の画面が出てログインできれば設定完了です。
スクリーンショット 2020-02-21 12.36.03.png
スクリーンショット 2020-02-21 12.37.19.png

おわりに

  • Redmineのインストール手順は今後できたらまとめます
  • Rubyの知識なしにとりあえず入れてみたのでbundle?gem?な状態です。少し勉強します

ありがとうございました。

9
7
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
9
7