From ed562832a69ee676092b8b3d7a09f548b6365039 Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Tue, 4 Mar 2025 16:51:40 +0530 Subject: [PATCH] feat: add ui element for secrets in superadmin (#11000) - add secret type for installation_config in the super admin console - hide tokens by default on the UI Before ---- image After ---- image --------- Co-authored-by: Shivam Mishra --- .../administrate/components/_buttons.scss | 10 ++-- .../super_admin/app_configs/show.html.erb | 59 +++++++++++++++++-- config/installation_config.yml | 14 +++++ 3 files changed, 73 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/administrate/components/_buttons.scss b/app/assets/stylesheets/administrate/components/_buttons.scss index 7b2f62045..a0c3699ba 100644 --- a/app/assets/stylesheets/administrate/components/_buttons.scss +++ b/app/assets/stylesheets/administrate/components/_buttons.scss @@ -1,8 +1,8 @@ -button, -input[type="button"], -input[type="reset"], -input[type="submit"], -.button { +button:not(.reset-base), +input[type='button']:not(.reset-base), +input[type='reset']:not(.reset-base), +input[type='submit']:not(.reset-base), +.button:not(.reset-base) { appearance: none; background-color: $color-woot; border: 0; diff --git a/app/views/super_admin/app_configs/show.html.erb b/app/views/super_admin/app_configs/show.html.erb index 1754808e5..6f95a6418 100644 --- a/app/views/super_admin/app_configs/show.html.erb +++ b/app/views/super_admin/app_configs/show.html.erb @@ -1,11 +1,19 @@ <% content_for(:title) do %> Configure Settings - <%= @config.titleize %> <% end %> + + + +
<%= form_with url: super_admin_app_config_url(config: @config) , method: :post do |form| %> <% @allowed_configs.each do |key| %> @@ -15,18 +23,36 @@
<% if @installation_configs[key]&.dig('type') == 'boolean' %> - <%= form.select "app_config[#{key}]", - [["True", true], ["False", false]], + <%= form.select "app_config[#{key}]", + [["True", true], ["False", false]], { selected: ActiveModel::Type::Boolean.new.cast(@app_config[key]) }, - class: "mt-2 border border-slate-100 p-1 rounded-md" + class: "mt-2 border border-slate-100 p-1 rounded-md" %> <% elsif @installation_configs[key]&.dig('type') == 'code' %> - <%= form.text_area "app_config[#{key}]", - value: @app_config[key], + <%= form.text_area "app_config[#{key}]", + value: @app_config[key], rows: 12, wrap: 'off', class: "mt-2 border font-mono text-xs border-slate-100 p-1 rounded-md overflow-scroll" %> + <% elsif @installation_configs[key]&.dig('type') == 'secret' %> +
+ <%= form.password_field "app_config[#{key}]", + id: "app_config_#{key}", + value: @app_config[key], + class: "mt-2 border border-slate-100 p-1.5 pr-8 rounded-md w-full" + %> + +
<% else %> <%= form.text_field "app_config[#{key}]", value: @app_config[key] %> <% end %> @@ -43,3 +69,26 @@
<% end %>
+ +<% content_for :javascript do %> + +<% end %> diff --git a/config/installation_config.yml b/config/installation_config.yml index 70c07ce60..d5924ebe0 100644 --- a/config/installation_config.yml +++ b/config/installation_config.yml @@ -103,13 +103,16 @@ display_title: 'Facebook Verify Token' description: 'The verify token used for Facebook Messenger Webhook' locked: false + type: secret - name: FB_APP_SECRET display_title: 'Facebook App Secret' locked: false + type: secret - name: IG_VERIFY_TOKEN display_title: 'Instagram Verify Token' description: 'The verify token used for Instagram Webhook' locked: false + type: secret - name: FACEBOOK_API_VERSION display_title: 'Facebook API Version' description: 'Configure this if you want to use a different Facebook API version. Make sure its prefixed with `v`' @@ -131,6 +134,7 @@ - name: AZURE_APP_SECRET display_title: 'Azure App Secret' locked: false + type: secret # End of Microsoft Email Channel Config # MARK: Captain Config @@ -138,6 +142,7 @@ display_title: 'OpenAI API Key' description: 'The API key used to authenticate requests to OpenAI services for Captain AI.' locked: false + type: secret - name: CAPTAIN_OPEN_AI_MODEL display_title: 'OpenAI Model' description: 'The OpenAI model configured for use in Captain AI. Default: gpt-4o-mini' @@ -146,6 +151,7 @@ display_title: 'FireCrawl API Key (optional)' description: 'The FireCrawl API key for the Captain AI service' locked: false + type: secret - name: CAPTAIN_CLOUD_PLAN_LIMITS display_title: 'Captain Cloud Plan Limits' description: 'The limits for the Captain AI service for different plans' @@ -160,11 +166,13 @@ display_title: 'Inbox Token' description: 'The Chatwoot Inbox Token for Contact Support in Cloud' locked: false + type: secret - name: CHATWOOT_INBOX_HMAC_KEY value: display_title: 'Inbox HMAC Key' description: 'The Chatwoot Inbox HMAC Key for Contact Support in Cloud' locked: false + type: secret - name: CHATWOOT_CLOUD_PLANS display_title: 'Cloud Plans' value: @@ -180,10 +188,12 @@ value: display_title: 'Analytics Token' description: 'The June.so analytics token for Chatwoot cloud' + type: secret - name: CLEARBIT_API_KEY value: display_title: 'Clearbit API Key' description: 'This API key is used for onboarding the users, to pre-fill account data.' + type: secret - name: DASHBOARD_SCRIPTS value: display_title: 'Dashboard Scripts' @@ -206,12 +216,14 @@ - name: CHATWOOT_SUPPORT_WEBSITE_TOKEN value: description: 'The Chatwoot website token, used to identify the Chatwoot inbox and display the "Contact Support" option on the billing page' + type: secret - name: CHATWOOT_SUPPORT_SCRIPT_URL value: description: 'The Chatwoot script base URL, to display the "Contact Support" option on the billing page' - name: CHATWOOT_SUPPORT_IDENTIFIER_HASH value: description: 'The Chatwoot identifier hash, to validate the contact in the live chat window.' + type: secret - name: ACCOUNT_SECURITY_NOTIFICATION_WEBHOOK_URL display_title: Webhook URL to post security analysis value: @@ -245,6 +257,7 @@ display_title: 'Firebase Credentials' value: locked: false + type: secret description: 'Contents on your firebase credentials json file' ## ------ End of Configs added for FCM v1 notifications ------ ## @@ -259,4 +272,5 @@ value: locked: false description: 'Linear client secret' + type: secret ## ------ End of Configs added for Linear ------ ##