Slide 1

Slide 1 text

Don’t Commit Your Secrets How to keep your application 
 secrets safe ! Nicholas Henry

Slide 2

Slide 2 text

Your secrets are everywhere • Passwords • Credentials • API Keys • Database • Amazon S3 • Stripe • Mail Chimp Examples Synonyms

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

• Repository is shared among multiple parties • Increases your risk for a security exploitation Why is this a bad practice?

Slide 5

Slide 5 text

• application is open source • application requires a high level of governance e.g. financial, healthcare • application involves transient contractors
 e.g. agency • application located on multiple services
 e.g. CodeClimate When is this a bad practice?

Slide 6

Slide 6 text

When is this a bad practice? ALWAYS!

Slide 7

Slide 7 text

• Environment Variables • Configuration files Your options

Slide 8

Slide 8 text

Environment Variables # setting environment variable
 export STRIPE_API_KEY=07bfb7a5487dc6df" # retrieving from Ruby
 ENV[‘STRIPE_API_KEY’] # =>07bfb7a5487dc6df

Slide 9

Slide 9 text

1 # config/application.yml" 2 " 3 production:" 4 secret_key_base: 33619eed953400c0e58695" 5 stripe_api_key: 07bfb7a5487dc6df Configuration File

Slide 10

Slide 10 text

• Rails 4.1 application • Deploy to Heroku
 Platform as a Service (PaaS) • Configure Stripe with an API key
 Payment Gateway Demo

Slide 11

Slide 11 text

• configuration file / environments variables • config/secrets.yml" • Rails.application.secrets.your_api_key Rails helps us keep secrets safe

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Review 1 # config/secrets.yml" 2 " 3 production:" 4 secret_key_base: <%= ENV[‘SECRET_KEY_BASE’] %>" 5 stripe_api_key: <%= ENV[‘STRIPE_API_KEY’] %> 1 2 3 heroku config:add STRIPE_API_KEY=montreal.rb-prod 1 # config/initializers/stripe.rb" 2 " 3 Stripe.api_key = " 4 Rails.application.secrets.stripe_api_key

Slide 14

Slide 14 text

• Don’t commit your secrets • If you have committed your secrets: • setup your application to use environment variables or a configuration file • reset your API keys and other secrets Remember

Slide 15

Slide 15 text

nicholas@firsthand.ca @nicholasjhenry Nicholas Henry http://blog.firsthand.ca