2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails AdminのBasic認証

Posted at

rails_adminにアクセスする際にBasic認証をさせる方法

  1. アクセスする際に入力していただくuser, password設定

    # in config/secrets.yml
    

development:
... ... ...
user: radmin
password: [my_dev_password]
production:
... ... ...
user: radmin
password: [myProdPassword]
```

  1. 認証確認追加

in config/initializers/reails_admin.rb

config.authorize_with do
authenticate_or_request_with_http_basic('Login required') do |username, password|
username == Rails.application.secrets.user &&
password == Rails.application.secrets.password
end
end
```

  1. Rails再起動

  2. RailsAdmin URLにアクセスするとuser, password入力画面が表示される
    設定されたuser, passwordを入力したらRails Admin画面に移動する

2
3
0

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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?