From d83068016bbf230d4a6f767c9e57d254e1592f7c Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Wed, 17 Apr 2019 21:50:18 +0200 Subject: [PATCH] Allow turning keybase off instance-wide --- app/controllers/settings/identity_proofs_controller.rb | 5 +++++ .../well_known/keybase_proof_config_controller.rb | 8 ++++++++ app/models/form/admin_settings.rb | 2 ++ app/views/admin/dashboard/index.html.haml | 2 ++ app/views/admin/settings/edit.html.haml | 3 +++ config/locales/en.yml | 1 + config/settings.yml | 1 + 7 files changed, 22 insertions(+) diff --git a/app/controllers/settings/identity_proofs_controller.rb b/app/controllers/settings/identity_proofs_controller.rb index e22b4d9be..4d0938545 100644 --- a/app/controllers/settings/identity_proofs_controller.rb +++ b/app/controllers/settings/identity_proofs_controller.rb @@ -5,6 +5,7 @@ class Settings::IdentityProofsController < Settings::BaseController before_action :authenticate_user! before_action :check_required_params, only: :new + before_action :check_enabled, only: :new def index @proofs = AccountIdentityProof.where(account: current_account).order(provider: :asc, provider_username: :asc) @@ -41,6 +42,10 @@ class Settings::IdentityProofsController < Settings::BaseController private + def check_enabled + not_found unless Setting.enable_keybase + end + def check_required_params redirect_to settings_identity_proofs_path unless [:provider, :provider_username, :username, :token].all? { |k| params[k].present? } end diff --git a/app/controllers/well_known/keybase_proof_config_controller.rb b/app/controllers/well_known/keybase_proof_config_controller.rb index eb41e586f..c78683a8d 100644 --- a/app/controllers/well_known/keybase_proof_config_controller.rb +++ b/app/controllers/well_known/keybase_proof_config_controller.rb @@ -2,8 +2,16 @@ module WellKnown class KeybaseProofConfigController < ActionController::Base + before_action :check_enabled + def show render json: {}, serializer: ProofProvider::Keybase::ConfigSerializer end + + private + + def check_enabled + head 404 unless Setting.enable_keybase + end end end diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index 83d303c33..f81776346 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -27,6 +27,7 @@ class Form::AdminSettings custom_css profile_directory hide_followers_count + enable_keybase flavour_and_skin thumbnail hero @@ -43,6 +44,7 @@ class Form::AdminSettings preview_sensitive_media profile_directory hide_followers_count + enable_keybase ).freeze UPLOAD_KEYS = %i( diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index d448e3862..21bdcae04 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -49,6 +49,8 @@ = feature_hint(link_to(t('admin.dashboard.feature_profile_directory'), edit_admin_settings_path), @profile_directory) %li = feature_hint(link_to(t('admin.dashboard.feature_timeline_preview'), edit_admin_settings_path), @timeline_preview) + %li + = feature_hint(link_to(t('admin.dashboard.keybase'), edit_admin_settings_path), @timeline_preview) %li = feature_hint(link_to(t('admin.dashboard.feature_relay'), admin_relays_path), @relay_enabled) diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml index 475fb3a2f..8f7acde5f 100644 --- a/app/views/admin/settings/edit.html.haml +++ b/app/views/admin/settings/edit.html.haml @@ -69,6 +69,9 @@ .fields-group = f.input :hide_followers_count, as: :boolean, wrapper: :with_label, label: t('admin.settings.hide_followers_count.title'), hint: t('admin.settings.hide_followers_count.desc_html') + .fields-group + = f.input :enable_keybase, as: :boolean, wrapper: :with_label, label: t('admin.settings.enable_keybase.title'), hint: t('admin.settings.enable_keybase.desc_html') + %hr.spacer/ .fields-group diff --git a/config/locales/en.yml b/config/locales/en.yml index a2cd84fc5..09b0212a1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -252,6 +252,7 @@ en: feature_timeline_preview: Timeline preview features: Features hidden_service: Federation with hidden services + keybase: Keybase integration open_reports: open reports recent_users: Recent users search: Full-text search diff --git a/config/settings.yml b/config/settings.yml index 4aa52dbf2..f0bfa9b69 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -31,6 +31,7 @@ defaults: &defaults system_font_ui: false noindex: false hide_followers_count: false + enable_keybase: true flavour: 'glitch' skin: 'default' aggregate_reblogs: true