{"id":318290,"date":"2021-02-19T15:01:05","date_gmt":"2021-02-19T15:01:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=318290"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=318290","title":{"rendered":"\u041a\u0430\u043a \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0441 secrets \u043d\u0430 credentials (Ruby on Rails)"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u0421redentials \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 Ruby on Rails 5.2.0 \u2014 \u043d\u043e\u0432\u044b\u0439 \u0437\u043e\u043b\u043e\u0442\u043e\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442. \u0421\u0442\u0430\u0440\u044b\u0435 \u0434\u043e\u0431\u0440\u044b\u0435, \u043d\u043e \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b .env \u0443\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0434\u043e\u0440\u043e\u0433\u0443. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435:<\/p>\n<ul>\n<li>\u0437\u0430\u0447\u0435\u043c \u0438 \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043e\u0442 secrets \u043a credentials, <\/li>\n<li>\u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c API-\u043a\u043b\u044e\u0447\u0438 \u0432 Ruby, YML \u0438 js.erb,<\/li>\n<li>\u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/li>\n<\/ul>\n<p> <a name=\"habracut\"><\/a><br \/>  \u0415\u0449\u0435 3 \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 \u0414\u0430\u0432\u0438\u0434 \u0425\u0435\u0439\u043d\u0435\u043c\u0435\u0439\u0435\u0440 \u0425\u0430\u043d\u0441\u0441\u043e\u043d, \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 Ruby on Rails, \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0432 <a href=\"https:\/\/twitter.com\/dhh\">\u0441\u0432\u043e\u0435\u043c \u0442\u0432\u0438\u0442\u0442\u0435\u0440\u0435<\/a> \u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0440\u0435\u043b\u0438\u0437\u0430 Rails 5.2.0, \u043d\u043e \u043d\u043e\u0432\u044b\u043c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u043c \u0447\u0430\u0441\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u044f, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0433\u043d\u0430\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c. <br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zq\/2p\/_-\/zq2p_-pqxw697qsholobcyep-dg.png\" width=\"450\"><br \/>  \u041c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0440\u0435\u0432\u043e\u0436\u043d\u044b\u043c \u0437\u0432\u043e\u043d\u043e\u0447\u043a\u043e\u043c, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0436\u043e\u043d\u0433\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c API-\u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u043c\u0435\u043d\u044f\u044f\u0441\u044c \u0438\u043c\u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438 \u0438\u0437 \u0432\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0422\u043e\u0433\u0434\u0430 \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0435\u0449\u0435 \u0440\u0430\u0437 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c credentials \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 Ruby on Rails.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441redentials \u0432\u043c\u0435\u0441\u0442\u043e secrets?<\/h3>\n<p>  \u0412 \u0446\u0438\u043a\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043f\u043e \u043c\u0435\u0440\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 API-\u043a\u043b\u044e\u0447. \u041e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u043d\u0430\u0447\u043d\u0443\u0442 \u043e\u0445\u043e\u0442\u0443 \u0437\u0430 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c API-\u043a\u043b\u044e\u0447\u043e\u043c. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442!<\/p>\n<p>  \u0418\u043b\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, API-\u043a\u043b\u044e\u0447 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 dotenv. \u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0432\u0441\u0451 \u044d\u0442\u043e \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0438\u0434\u0435\u044f\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u0435\u0440\u043d\u043e?<\/p>\n<p>  \u0417\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043e\u0431 \u043e\u0431\u043c\u0435\u043d\u0435 API-\u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0432 \u0447\u0430\u0442\u0430\u0445 \u0432 Slack \u0438\u043b\u0438 \u043f\u043e \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u0435. \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430\u0440\u0443\u0448\u0430\u0442\u044c \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. <\/p>\n<p>  Credentials \u0432 Rails \u0440\u0435\u0448\u0430\u044e\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e: \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043a\u043b\u044e\u0447\u0435\u0439 \u043d\u0430 Github.<\/p>\n<p>  \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 Github? \u0414\u0430, \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 Github! \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: API-\u043a\u043b\u044e\u0447\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u044b.<\/p>\n<p>  \u0411\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0434\u0438\u043d \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439. \u0418 \u043e\u043d \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f! <\/p>\n<p>  \u041d\u043e\u0432\u044b\u0435 API-\u043a\u043b\u044e\u0447\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u0430\u0448\u0438\u043c\u0438 \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c\u0438 \u043a\u0430\u043a credentials, \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u0437 Github \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u0442\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0432\u0435\u0442\u043a\u0438 main (\u0440\u0430\u043d\u0435\u0435 \u043d\u043e\u0441\u0438\u043b\u0430 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 <a href=\"https:\/\/www.zdnet.com\/article\/github-to-replace-master-with-main-starting-next-month\/\">\u00ab\u0432\u0435\u0442\u043a\u0430 master\u00bb<\/a>).<\/p>\n<p>  \u041a\u043b\u044e\u0447 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435 config\/master.key.<\/p>\n<h3>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?<\/h3>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a <code>bin\/rails credentials:edit<\/code> \u0432 rails \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 config:<\/p>\n<ul>\n<li><code>credentials.yml.enc<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0441\u0435 \u0432\u0430\u0448\u0438 API-\u043a\u043b\u044e\u0447\u0438. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0432\u0434\u0440\u0443\u0433 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 .enc \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/li>\n<li><code>master.key<\/code> \u2014 \u044d\u0442\u043e \u043a\u043b\u044e\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 encrypted.file (1.) \u0423\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 master.key \u0432 \u0444\u0430\u0439\u043b <code>.gitignore.yml<\/code>.<\/li>\n<\/ul>\n<p>  \u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448 \u0444\u0430\u0439\u043b <code>Credentials.yml.enc<\/code> \u043d\u0430 Github, \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u0432 \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0445 \u0440\u0443\u043a\u0430\u0445. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c master.key \u0445\u0440\u0430\u043d\u0438\u043c \u043f\u0440\u0438 \u0441\u0435\u0431\u0435 \u0438 \u0431\u0435\u0440\u0435\u0436\u0435\u043c \u0442\u0430\u043a, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0430\u0448\u0430 \u0436\u0438\u0437\u043d\u044c!<\/p>\n<h3>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 credentials<\/h3>\n<p>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u0444\u0430\u0439\u043b credentials, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <code>EDITOR='code --wait' bin\/rails credentials:edit<\/code><\/p>\n<p>  \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0432\u0430\u043c\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 <code>code<\/code> (VS Code). \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  vim or vi = Vim<br \/>  atom = Atom<br \/>  subl or stt = Sublime<\/p>\n<p>  \u0424\u0430\u0439\u043b credentials \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u0438 \u0436\u0434\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0435 \u0438 \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u043a\u0440\u043e\u0435\u0442\u0435. \u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0438\u0442\u0435 \u043a\u043b\u044e\u0447\u0438 ENV, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435 .env, \u0432 \u0444\u0430\u0439\u043b credentials.yml.<\/p>\n<p>  \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u0442\u0430\u0440\u044b\u0439 \u0444\u0430\u0439\u043b <code>.ENV<\/code>:<\/p>\n<pre><code class=\"ruby\">STRIPE_PUBLISHABLE_KEY=pk_test_VG8LlUN82DcZS3cAOJVy0WyIR9Jwz0YZkq302MKc00t STRIPE_SECRET_KEY=sk_test_VG8LlUN82DcZS3cAOJVy0WyIR9Jwz0YZkq302MKc00tgAAYF STRIPE_WEBHOOK_SECRET_KEY=whsec_cZpB0VG8cZpB0VG8cZpB0VG8UrgA2gcZpB0VG8cZpB CLOUDINARY_URL=cloudinary:\/\/15031853100444:XOr3XQ-DcZ4dBoan80@DcZ4Boan800U GOOGLE_API_KEY=S3cAOJVy0WyS3cAOJVy0WyIR9AOJVy0WyIR92e<\/code><\/pre>\n<p>  \u043d\u0430 <code>credentials.yml<\/code>:<\/p>\n<pre><code class=\"ruby\">stripe:   publishable_key: pk_test_VG8LlUN82DcZS3cAOJVy0WyIR9Jwz0YZkq302MKc00tgAAYF   secret_key: sk_test_VG8LlUN82DcZS3cAOJVy0WyIR9Jwz0YZkq302MKc00tgAAYF   web_hook_secret_key: whsec_cZpB0VG8cZpB0VG8cZpB0VG8UrgA2gcZpB0VG8cZpB  google_api_key: S3cAOJVy0WyS3cAOJVy0WyIR9AOJVy0WyIR92e  cloudinary:   cloud_name: abcdefg   api_key: 12345678910   api_secret: abc315-VG8Ll8VG8Ll8L<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u041a\u043b\u044e\u0447 Cloudinary API \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u0435\u0439, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>  \u0412\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e! \u0414\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d, credentials \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435.<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>bin\/rails credentials:show<\/code>.<\/p>\n<p>  \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0430\u0448\u0438\u043c \u0441\u0442\u0430\u0440\u044b\u043c \u0434\u0440\u0443\u0433\u043e\u043c \u2014 \u0444\u0430\u0439\u043b\u043e\u043c .ENV. \u0423\u0434\u0430\u043b\u0438\u043c \u0435\u0433\u043e.<\/p>\n<p>  \u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Credentials \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a Ruby, YML \u0438 JavaScript<\/p>\n<p>  <b><a href=\"https:\/\/gist.github.com\/thomasvanholder\/8d35c94bbfe00fcb8922f93f9fd8d736#file-credentials_in_ruby-rb\">Ruby<\/a><\/b><\/p>\n<pre><code class=\"ruby\"># nested key Rails.application.credentials.stripe[:publishable_key]  # single key Rails.application.credentials.google_api_key<\/code><\/pre>\n<p>  <a href=\"https:\/\/gist.github.com\/thomasvanholder\/56e58acec38beface1ffcfae5f2f5f09#file-credentials_in_yml-yml\"><b>YML<\/b><\/a><\/p>\n<pre><code class=\"bash\">cloudinary:   service: Cloudinary   api_key: &lt;%= Rails.application.credentials.dig(:cloudinary, :api_key) %&gt;   api_secret: &lt;%= Rails.application.credentials.dig(:cloudinary, :api_secret) %&gt;<\/code><\/pre>\n<p>  \u0434\u043b\u044f Cloudinary \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b config\/cloudinary.yml<\/p>\n<p>  <a href=\"https:\/\/gist.github.com\/thomasvanholder\/b8188e3c940d4fc9dc5bb51d7e053861#file-credentials_in_javascript-js-erb\"><b>JavaScript<\/b><\/a><\/p>\n<pre><code class=\"javascript\">\/\/ ruby code only possible with js.erb format const abc = &quot;&lt;%= Rails.application.credentials.google_api_key %&gt;&quot;<\/code><\/pre>\n<p>  <a href=\"https:\/\/gist.github.com\/thomasvanholder\/2de9aea72cc7d48bc80f77a2764a60f5#file-credentials_in_html-html-erb\"><b>HTML<\/b><\/a><\/p>\n<pre><code class=\"xml\">&lt;!-- interpolate in script tag --&gt;  &lt;script src=&quot;https:\/\/maps.googleapis.com\/maps\/api\/js?key=&lt;%= &quot;#{Rails.application.credentials.google_api_key}&quot;%&gt;&quot;&lt;\/script<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041a\u0430\u043a \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439<\/h3>\n<p>  \u041f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u043a\u043b\u044e\u0447\u043e\u043c \u0432 <code>master.key<\/code> \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0447\u043b\u0435\u043d \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0444\u0430\u0439\u043b <code>master.key<\/code> \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 config \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043e\u0431\u0449\u0438\u0439 \u043a\u043b\u044e\u0447.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434<\/h3>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u0441\u0451 \u0431\u043e\u043b\u0435\u0435 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u0430\u043d\u044f\u0442\u0438\u0435\u043c \u0431\u0435\u0437 \u0441\u0443\u0435\u0442\u044b \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 API-\u043a\u043b\u044e\u0447\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f credentials, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439 \u043f\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c master key \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438 \u0438\u0437\u0431\u0430\u0432\u044c\u0442\u0435\u0441\u044c \u043e\u0442 \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/543294\/\"> https:\/\/habr.com\/ru\/company\/timeweb\/blog\/543294\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u0421redentials \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 Ruby on Rails 5.2.0 \u2014 \u043d\u043e\u0432\u044b\u0439 \u0437\u043e\u043b\u043e\u0442\u043e\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442. \u0421\u0442\u0430\u0440\u044b\u0435 \u0434\u043e\u0431\u0440\u044b\u0435, \u043d\u043e \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b .env \u0443\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0434\u043e\u0440\u043e\u0433\u0443. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435:<\/p>\n<ul>\n<li>\u0437\u0430\u0447\u0435\u043c \u0438 \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043e\u0442 secrets \u043a credentials, <\/li>\n<li>\u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c API-\u043a\u043b\u044e\u0447\u0438 \u0432 Ruby, YML \u0438 js.erb,<\/li>\n<li>\u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-318290","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/318290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=318290"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/318290\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=318290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=318290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=318290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}