0
0

More than 3 years have passed since last update.

credentials.yml.encとmaster.key<備忘録>

Last updated at Posted at 2021-01-02

概念

credentials.yml.encとmaster.key

Rails5.2から登場したアプリの秘密情報を管理するための仕組み

master.key

credentials.yml.encに書かれた暗号化された秘密情報を、複合化するための秘密鍵が書かれたファイル

credentials.yml.enc

credentials.ymlを暗号化したファイル

credentials.yml

秘密情報が書かれたファイル

使用方法

秘密情報を編集する時

直接credentials.yml.encを編集するのではなく、以下のコマンドで編集する

EDITOR='vim' rails credentials:edit

なぜ直接credentials.yml.encを編集しないのか?

credentials.yml.encは暗号化されたファイルでありそれを編集する事はできないから。(.encは暗号化されたファイルという意味)

秘密情報を呼び出す時

Rails consoleを起動した後、下記のコマンドを打つ

Rails.application.credentials[:取得したい秘密情報]

参考

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