[deploy] Add Twitter and GitHub keys to SiteConfig (#9899)
* Add Twitter and GitHub keys to SiteConfig * Change docs * Add notice about not taking affect right away
This commit is contained in:
parent
21ebe6d0cd
commit
36ccfd55dd
10 changed files with 84 additions and 31 deletions
17
.env_sample
17
.env_sample
|
|
@ -32,23 +32,6 @@ export ELASTICSEARCH_URL="http://localhost:9200"
|
|||
# SSL config
|
||||
export FORCE_SSL_IN_RAILS="not applicable in dev"
|
||||
|
||||
################################################
|
||||
############## 3rd Party Services ##############
|
||||
################################################
|
||||
|
||||
# It's best if you have the following configured
|
||||
# for more development experience
|
||||
|
||||
# GitHub
|
||||
# (https://developer.github.com/v3/guides/basics-of-authentication/)
|
||||
export GITHUB_KEY=""
|
||||
export GITHUB_SECRET=""
|
||||
|
||||
# Twitter
|
||||
# (https://developer.twitter.com/en/docs/basics/authentication/oauth-2-0/application-only)
|
||||
export TWITTER_KEY=""
|
||||
export TWITTER_SECRET=""
|
||||
|
||||
################################################
|
||||
######### Optional 3rd Party Services ##########
|
||||
################################################
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ module Admin
|
|||
default_font
|
||||
sponsor_headline
|
||||
public
|
||||
twitter_key
|
||||
twitter_secret
|
||||
github_key
|
||||
github_secret
|
||||
]
|
||||
|
||||
allowed_params = allowed_params |
|
||||
|
|
|
|||
|
|
@ -87,6 +87,14 @@ module Constants
|
|||
description: "Determines which default feed the users sees (rich content, more minimal, etc.)",
|
||||
placeholder: "basic, rich, or compact"
|
||||
},
|
||||
github_key: {
|
||||
description: "The \"Client ID\" portion of the GitHub Oauth Apps portal",
|
||||
placeholder: ""
|
||||
},
|
||||
github_secret: {
|
||||
description: "The \"Client Secret\" portion of the GitHub Oauth Apps portal",
|
||||
placeholder: ""
|
||||
},
|
||||
ga_view_id: {
|
||||
description: "Google Analytics Reporting API v4 - View ID",
|
||||
placeholder: ""
|
||||
|
|
@ -228,6 +236,14 @@ module Constants
|
|||
twitter_hashtag: {
|
||||
description: "Used as the twitter hashtag of the community",
|
||||
placeholder: "#DEVCommunity"
|
||||
},
|
||||
twitter_key: {
|
||||
description: "The \"API key\" portion of consumer keys in the Twitter developer portal.",
|
||||
placeholder: ""
|
||||
},
|
||||
twitter_secret: {
|
||||
description: "The \"API secret key\" portion of consumer keys in the Twitter developer portal.",
|
||||
placeholder: ""
|
||||
}
|
||||
# Dynamic values ommitted: configurable_rate_limits and social_media_handles
|
||||
}.freeze
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ class SiteConfig < RailsSettings::Base
|
|||
|
||||
# Authentication
|
||||
field :authentication_providers, type: :array, default: Authentication::Providers.available
|
||||
field :twitter_key, type: :string, default: ApplicationConfig["TWITTER_KEY"]
|
||||
field :twitter_secret, type: :string, default: ApplicationConfig["TWITTER_SECRET"]
|
||||
field :github_key, type: :string, default: ApplicationConfig["GITHUB_KEY"]
|
||||
field :github_secret, type: :string, default: ApplicationConfig["GITHUB_SECRET"]
|
||||
|
||||
# Campaign
|
||||
field :campaign_hero_html_variant_name, type: :string, default: ""
|
||||
|
|
|
|||
|
|
@ -130,9 +130,41 @@
|
|||
class: "form-control selectpicker" %>
|
||||
<div class="alert alert-info"><%= Constants::SiteConfig::DETAILS[:authentication_providers][:description] %></div>
|
||||
</div>
|
||||
<h4>Notice: Changing authentication keys will not take affect until devops restarts the app (about once per day). This will soon be instant.</h4>
|
||||
<div class="form-group">
|
||||
<%= admin_config_label :twitter_key %>
|
||||
<%= f.text_field :twitter_key,
|
||||
class: "form-control",
|
||||
value: SiteConfig.twitter_key,
|
||||
placeholder: Constants::SiteConfig::DETAILS[:twitter_key][:placeholder] %>
|
||||
<div class="alert alert-info"><%= Constants::SiteConfig::DETAILS[:twitter_key][:description] %></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= admin_config_label :twitter_secret %>
|
||||
<%= f.text_field :twitter_secret,
|
||||
class: "form-control",
|
||||
value: SiteConfig.twitter_secret,
|
||||
placeholder: Constants::SiteConfig::DETAILS[:twitter_secret][:placeholder] %>
|
||||
<div class="alert alert-info"><%= Constants::SiteConfig::DETAILS[:twitter_secret][:description] %></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= admin_config_label :github_key %>
|
||||
<%= f.text_field :github_key,
|
||||
class: "form-control",
|
||||
value: SiteConfig.github_key,
|
||||
placeholder: Constants::SiteConfig::DETAILS[:github_key][:placeholder] %>
|
||||
<div class="alert alert-info"><%= Constants::SiteConfig::DETAILS[:github_key][:description] %></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= admin_config_label :github_secret %>
|
||||
<%= f.text_field :github_secret,
|
||||
class: "form-control",
|
||||
value: SiteConfig.github_secret,
|
||||
placeholder: Constants::SiteConfig::DETAILS[:github_secret][:placeholder] %>
|
||||
<div class="alert alert-info"><%= Constants::SiteConfig::DETAILS[:github_secret][:description] %></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-3">
|
||||
<%= render partial: "card_header",
|
||||
locals: {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
# Use this hook to configure devise mailer, warden hooks and so forth.
|
||||
# Many of these configuration options can be set straight in your model.
|
||||
TWITTER_OMNIAUTH_SETUP = lambda do |env|
|
||||
env["omniauth.strategy"].options[:consumer_key] = SiteConfig.twitter_key
|
||||
env["omniauth.strategy"].options[:consumer_secret] = SiteConfig.twitter_secret
|
||||
end
|
||||
|
||||
GITHUB_OMNIUATH_SETUP = lambda do |env|
|
||||
env["omniauth.strategy"].options[:client_id] = SiteConfig.github_key
|
||||
env["omniauth.strategy"].options[:client_secret] = SiteConfig.github_secret
|
||||
env["omniauth.strategy"].options[:scope] = "user:email"
|
||||
end
|
||||
|
||||
Devise.setup do |config|
|
||||
# The secret key used by Devise. Devise uses this key to generate
|
||||
# random tokens. Changing this key will render invalid all existing
|
||||
|
|
@ -283,9 +292,10 @@ Devise.setup do |config|
|
|||
# ==> OmniAuth
|
||||
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
||||
# up on your models and hooks.
|
||||
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
||||
config.omniauth :github, ApplicationConfig["GITHUB_KEY"], ApplicationConfig["GITHUB_SECRET"], scope: "user:email"
|
||||
config.omniauth :twitter, ApplicationConfig["TWITTER_KEY"], ApplicationConfig["TWITTER_SECRET"]
|
||||
|
||||
# Fun fact, if this is reordered to have Twitter first, it doesn't work for some reason.
|
||||
config.omniauth :github, setup: GITHUB_OMNIUATH_SETUP
|
||||
config.omniauth :twitter, setup: TWITTER_OMNIAUTH_SETUP
|
||||
|
||||
# ==> Warden configuration
|
||||
# If you want to use other strategies, that are not supported by Devise, or
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ Then, add each key you need to the `.env` file. For example, if you're setting
|
|||
up GitHub authentication:
|
||||
|
||||
```shell
|
||||
export GITHUB_KEY="SOME_REAL_SECURE_KEY_HERE"
|
||||
export GITHUB_SECRET="ANOTHER_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_API_KEY="SOME_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_API_SECRET="ANOTHER_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_CLOUD_NAME="A_CLOUDINARY_NAME"
|
||||
```
|
||||
|
||||
(Don't worry, your `.env` file is ignored by git)
|
||||
|
|
|
|||
|
|
@ -73,8 +73,9 @@ with Podman. You can install it by following these
|
|||
enter/replace. i.e.:
|
||||
|
||||
```shell
|
||||
export GITHUB_KEY="SOME_REAL_SECURE_KEY_HERE"
|
||||
export GITHUB_SECRET="ANOTHER_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_API_KEY="SOME_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_API_SECRET="ANOTHER_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_CLOUD_NAME="A_CLOUDINARY_NAME"
|
||||
```
|
||||
|
||||
- You do not need "real" keys for basic development. Some features require
|
||||
|
|
|
|||
|
|
@ -103,8 +103,9 @@ NOTE: Make sure to download **the OSS version**, `elasticsearch-oss`.
|
|||
enter/replace. i.e.:
|
||||
|
||||
```shell
|
||||
export GITHUB_KEY="SOME_REAL_SECURE_KEY_HERE"
|
||||
export GITHUB_SECRET="ANOTHER_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_API_KEY="SOME_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_API_SECRET="ANOTHER_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_CLOUD_NAME="A_CLOUDINARY_NAME"
|
||||
```
|
||||
|
||||
- If you are missing `ENV` variables on bootup, the
|
||||
|
|
|
|||
|
|
@ -223,8 +223,9 @@ your local Elasticsearch installation, for example:
|
|||
enter/replace. i.e.:
|
||||
|
||||
```shell
|
||||
export GITHUB_KEY="SOME_REAL_SECURE_KEY_HERE"
|
||||
export GITHUB_SECRET="ANOTHER_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_API_KEY="SOME_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_API_SECRET="ANOTHER_REAL_SECURE_KEY_HERE"
|
||||
export CLOUDINARY_CLOUD_NAME="A_CLOUDINARY_NAME"
|
||||
```
|
||||
|
||||
- If you are missing `ENV` variables on bootup, the
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue