From 88eb8a6cc463879b02efc57a281264afe878590e Mon Sep 17 00:00:00 2001 From: David Gil Date: Mon, 24 Aug 2015 17:14:45 +0200 Subject: [PATCH] adds omniauth and omniauth-twitter gems and initializer with references to secrets --- Gemfile | 5 +++++ Gemfile.lock | 13 +++++++++++++ config/deploy/shared/secrets.yml.erb | 5 ++++- config/initializers/omniauth.rb | 4 ++++ config/secrets.yml.example | 8 +++++++- 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 config/initializers/omniauth.rb diff --git a/Gemfile b/Gemfile index f1b251db4..95ce82135 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,11 @@ gem 'turbolinks' gem 'devise' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' +gem 'omniauth' +gem 'omniauth-twitter' +# gem 'omniauth-facebook' +# gem 'omniauth-google-oauth2' + gem 'kaminari' gem 'acts_as_commentable_with_threading' gem 'acts-as-taggable-on' diff --git a/Gemfile.lock b/Gemfile.lock index deed6bc4f..d1a5ece7b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -150,6 +150,7 @@ GEM activesupport (>= 4.1.0) groupdate (2.4.0) activesupport (>= 3) + hashie (3.4.2) highline (1.7.3) http-cookie (1.0.2) domain_name (~> 0.5) @@ -195,6 +196,16 @@ GEM netrc (0.10.3) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) + oauth (0.4.7) + omniauth (1.2.2) + hashie (>= 1.2, < 4) + rack (~> 1.0) + omniauth-oauth (1.1.0) + oauth + omniauth (~> 1.0) + omniauth-twitter (1.2.1) + json (~> 1.3) + omniauth-oauth (~> 1.1) orm_adapter (0.5.0) paranoia (2.1.3) activerecord (~> 4.0) @@ -362,6 +373,8 @@ DEPENDENCIES kaminari launchy letter_opener_web (~> 1.3.0) + omniauth + omniauth-twitter paranoia pg poltergeist diff --git a/config/deploy/shared/secrets.yml.erb b/config/deploy/shared/secrets.yml.erb index a1cc29fb8..9a6582afb 100644 --- a/config/deploy/shared/secrets.yml.erb +++ b/config/deploy/shared/secrets.yml.erb @@ -2,4 +2,7 @@ recaptcha_public_key: <%= ENV["MADRID_RECAPTCHA_PUBLIC_KEY"] %> recaptcha_private_key: <%= ENV["MADRID_RECAPTCHA_PRIVATE_KEY"] %> secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> - server_name: <%= fetch(:server_name) %> \ No newline at end of file + twitter_key: <%= ENV["TWITTER_KEY"] %> + twitter_secret: <%= ENV["TWITTER_SECRET"] %> + server_name: <%= fetch(:server_name) %> + diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb new file mode 100644 index 000000000..42e97b02f --- /dev/null +++ b/config/initializers/omniauth.rb @@ -0,0 +1,4 @@ +Rails.application.config.middleware.use OmniAuth::Builder do + provider :developer unless Rails.env.production? + provider :twitter, Rails.application.secrets.twitter_key, Rails.application.secrets.twitter_secret +end diff --git a/config/secrets.yml.example b/config/secrets.yml.example index f4ad98027..72c7a6d64 100644 --- a/config/secrets.yml.example +++ b/config/secrets.yml.example @@ -14,12 +14,18 @@ default: &default development: secret_key_base: 56792feef405a59b18ea7db57b4777e855103882b926413d4afdfb8c0ea8aa86ea6649da4e729c5f5ae324c0ab9338f789174cf48c544173bc18fdc3b14262e4 + twitter_key: AAAA + twitter_secret: BBBB <<: *default test: secret_key_base: 4d5adf961ddd27aef19622d6c0b3234d555f9ee003f022b1f829c92bbe33aaee907be7feb67bd54c14a1a32512fa968565ad405971fbc41bd0797af73c26a796 + twitter_key: AAAA + twitter_secret: BBBB <<: *default production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> - <<: *default \ No newline at end of file + twitter_key: <%= ENV["TWITTER_KEY"] %> + twitter_secret: <%= ENV["TWITTER_SECRET"] %> + <<: *default