简体   繁体   English

我在 bin/secrets 中有一个 api 密钥。 heroku怎么能找到呢?

[英]i have an api key in the bin/secrets. How can heroku find it?

I just recently worked with an api and with security in mind, have it placed in the bin/rails secrets file.我最近刚使用 api 并考虑到安全性,将其放在bin/rails secrets文件中。 I have it listed below like我在下面列出了它

development:
  google_api_key: abcd1234
production:
  google_api_key: abcd1234

However when I push everything to heroku, I get application errors.但是,当我将所有内容推送到 heroku 时,出现应用程序错误。 When I look at the logs I see.当我查看日志时,我看到了。

2020-08-04T22:34:28.529917+00:00 app[web.1]: /app/config/environment.rb:5:in `<top (required)>'
2020-08-04T22:34:28.529918+00:00 app[web.1]: config.ru:3:in `require_relative'
2020-08-04T22:34:28.529918+00:00 app[web.1]: config.ru:3:in `block in <main>'
2020-08-04T22:34:29.113486+00:00 heroku[web.1]: Process exited with status 1
2020-08-04T22:34:29.152963+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-04T22:34:29.605524+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=downtown-inventory-app.herokuapp.com request_id=1a1f61ec-458d-46c7-ada0-38ff05280586 fwd="107.77.206.194" dyno= connect= service= status=503 bytes= protocol=https
2020-08-04T22:34:30.628910+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=downtown-inventory-app.herokuapp.com request_id=d65ed41c-368e-451b-b70f-480b160e4c45 fwd="107.77.206.194" dyno= connect= service= status=503 bytes= protocol=https
2020-08-04T22:37:15.442465+00:00 app[api]: Set RAILS_MASTER_KEY config vars by user email@gmail.com
2020-08-04T22:37:15.442465+00:00 app[api]: Release v77 created by user email@gmail.com
2020-08-04T22:37:15.616389+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-04T22:37:20.612387+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2020-08-04T22:37:22.765114+00:00 app[web.1]: Puma starting in single mode...
2020-08-04T22:37:22.765140+00:00 app[web.1]: * Version 3.12.6 (ruby 2.5.8-p224), codename: Llamas in Pajamas
2020-08-04T22:37:22.765143+00:00 app[web.1]: * Min threads: 5, max threads: 5
2020-08-04T22:37:22.765147+00:00 app[web.1]: * Environment: production
2020-08-04T22:37:26.041214+00:00 app[web.1]: ! Unable to load application: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
2020-08-04T22:37:26.041370+00:00 app[web.1]: bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.5.0/bin/puma)
2020-08-04T22:37:26.041449+00:00 app[web.1]: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
2020-08-04T22:37:26.041494+00:00 app[web.1]: /app/config/environment.rb:5:in `<top (required)>'

I feel like the most important errors in the logs are我觉得日志中最重要的错误是

Unable to load application: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage

and

ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage

I also see /app/config/environment.rb:5 in the logs which is我还在日志中看到/app/config/environment.rb:5

# Load the Rails application.
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!

I'm (praying) that someone else would have any ideas on what I can do here?我(祈祷)其他人会对我在这里能做什么有任何想法? I'm pretty new at working with deploying applications to heroku and so i'm not super sure what to do here.我在将应用程序部署到 heroku 方面非常陌生,所以我不太确定在这里做什么。

You have to set these keys on heroku:您必须在 heroku 上设置这些键:

heroku config:set GITHUB_USERNAME=joesmith

In this case GITHUB_USERNAME ist the set variable and you have to use that in your code so heroku knows what it should insert.在这种情况下, GITHUB_USERNAME 是设置变量,您必须在代码中使用它,以便 heroku 知道它应该插入什么。

heroku docs: "Configuration and Config Vars" heroku 文档:“配置和配置变量”

ruby guides: "How To Use Environment Variables in Ruby" ruby 指南:“如何在 Ruby 中使用环境变量”


I also found this guide: 我还找到了这个指南:

arkency blog: "How to safely store API keys in Rails apps" arkency 博客:“如何在 Rails 应用程序中安全地存储 API 密钥”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Rails Secrets 存储 Google API 凭据? - How can I store Google API Credentials using Rails Secrets? 尝试隐藏 AWS 和 JWT 密钥/机密时,无法使 Rails 5.2 凭证起作用。 没有获得 Nil 的方法 - Can't get Rails 5.2 credentials to work while trying to hide AWS and JWT keys/secrets. Getting no method for Nil 如何在Heroku上找到内存泄漏? - How can I find a memory leak on Heroku? jQuery文件上传器和turbolinks在heroku上不起作用,已经尝试了我可以在SO上找到的所有修复程序 - jQuery file uploader and turbolinks not working on heroku, have tried every fix I can find on SO 如何查找和消除在Heroku上运行的隐藏进程? - How can I find and eliminate hidden processes running on Heroku? 我如何设置秘密 - How do I set secrets 在Heroku上托管时,如何拥有多个架构和多个子域? - How can I have multiple schemas and multiple subdomains when hosting on Heroku? 如何使我的舞台和制作具有相同的数据? (Heroku的) - How can I make my staging and production have the same data? (Heroku) Ruby on Rails,从secrets.yml检索API密钥 - Ruby on Rails, retrieving API key from secrets.yml Heroku 错误:“key must be 16 bytes”但是我输入的key是16 bytes - Heroku error: "key must be 16 bytes" but the key I have inputted is 16 bytes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM