mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 03:27:52 +00:00
feat: move Azure config to installation_config (#9481)
This PR has the following changes 1. Add `AZURE_APP_ID` and `AZURE_APP_SECRET` to installation config 2. Add Microsoft config to `super_admin/features.yml` 3. Replace usage of `ENV.fetch` with `GlobalConfigService.load` for fetch App ID and Secret
This commit is contained in:
@@ -2,7 +2,10 @@ module MicrosoftConcern
|
|||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
def microsoft_client
|
def microsoft_client
|
||||||
::OAuth2::Client.new(ENV.fetch('AZURE_APP_ID', nil), ENV.fetch('AZURE_APP_SECRET', nil),
|
app_id = GlobalConfigService.load('AZURE_APP_ID', nil)
|
||||||
|
app_secret = GlobalConfigService.load('AZURE_APP_SECRET', nil)
|
||||||
|
|
||||||
|
::OAuth2::Client.new(app_id, app_secret,
|
||||||
{
|
{
|
||||||
site: 'https://login.microsoftonline.com',
|
site: 'https://login.microsoftonline.com',
|
||||||
authorize_url: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
authorize_url: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class DashboardController < ActionController::Base
|
|||||||
FB_APP_ID: GlobalConfigService.load('FB_APP_ID', ''),
|
FB_APP_ID: GlobalConfigService.load('FB_APP_ID', ''),
|
||||||
FACEBOOK_API_VERSION: GlobalConfigService.load('FACEBOOK_API_VERSION', 'v17.0'),
|
FACEBOOK_API_VERSION: GlobalConfigService.load('FACEBOOK_API_VERSION', 'v17.0'),
|
||||||
IS_ENTERPRISE: ChatwootApp.enterprise?,
|
IS_ENTERPRISE: ChatwootApp.enterprise?,
|
||||||
AZURE_APP_ID: ENV.fetch('AZURE_APP_ID', ''),
|
AZURE_APP_ID: GlobalConfigService.load('AZURE_APP_ID', ''),
|
||||||
GIT_SHA: GIT_HASH
|
GIT_SHA: GIT_HASH
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ class MicrosoftController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def microsoft_indentity
|
def microsoft_indentity
|
||||||
@identity_json = ENV.fetch('AZURE_APP_ID', nil)
|
@identity_json = GlobalConfigService.load('AZURE_APP_ID', nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ class SuperAdmin::AppConfigsController < SuperAdmin::ApplicationController
|
|||||||
@allowed_configs = case @config
|
@allowed_configs = case @config
|
||||||
when 'facebook'
|
when 'facebook'
|
||||||
%w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET IG_VERIFY_TOKEN FACEBOOK_API_VERSION ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT]
|
%w[FB_APP_ID FB_VERIFY_TOKEN FB_APP_SECRET IG_VERIFY_TOKEN FACEBOOK_API_VERSION ENABLE_MESSENGER_CHANNEL_HUMAN_AGENT]
|
||||||
|
when 'microsoft'
|
||||||
|
%w[AZURE_APP_ID AZURE_APP_SECRET]
|
||||||
when 'email'
|
when 'email'
|
||||||
['MAILER_INBOUND_EMAIL_DOMAIN']
|
['MAILER_INBOUND_EMAIL_DOMAIN']
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class Microsoft::RefreshOauthTokenService
|
|||||||
|
|
||||||
# Builds the OAuth strategy for Microsoft Graph
|
# Builds the OAuth strategy for Microsoft Graph
|
||||||
def build_oauth_strategy
|
def build_oauth_strategy
|
||||||
::MicrosoftGraphAuth.new(nil, ENV.fetch('AZURE_APP_ID'), ENV.fetch('AZURE_APP_SECRET'))
|
::MicrosoftGraphAuth.new(nil, GlobalConfigService.load('AZURE_APP_ID', ''), GlobalConfigService.load('AZURE_APP_SECRET', ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Builds the token service using OAuth2
|
# Builds the token service using OAuth2
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
||||||
|
<symbol id="icon-microsoft" viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor" d="M2 3h9v9H2zm9 19H2v-9h9zM21 3v9h-9V3zm0 19h-9v-9h9z"/>
|
||||||
|
</symbol>
|
||||||
<symbol id="icon-cancel" viewBox="0 0 48 48">
|
<symbol id="icon-cancel" viewBox="0 0 48 48">
|
||||||
<path fill-rule="evenodd" d="M24 19.757l-8.485-8.485c-.784-.783-2.047-.782-2.827 0l-1.417 1.416c-.777.777-.78 2.046.002 2.827L19.757 24l-8.485 8.485c-.783.784-.782 2.047 0 2.827l1.416 1.417c.777.777 2.046.78 2.827-.002L24 28.243l8.485 8.485c.784.783 2.047.782 2.827 0l1.417-1.416c.777-.777.78-2.046-.002-2.827L28.243 24l8.485-8.485c.783-.784.782-2.047 0-2.827l-1.416-1.417c-.777-.777-2.046-.78-2.827.002L24 19.757zM24 47c12.703 0 23-10.297 23-23S36.703 1 24 1 1 11.297 1 24s10.297 23 23 23z" />
|
<path fill-rule="evenodd" d="M24 19.757l-8.485-8.485c-.784-.783-2.047-.782-2.827 0l-1.417 1.416c-.777.777-.78 2.046.002 2.827L19.757 24l-8.485 8.485c-.783.784-.782 2.047 0 2.827l1.416 1.417c.777.777 2.046.78 2.827-.002L24 28.243l8.485 8.485c.784.783 2.047.782 2.827 0l1.417-1.416c.777-.777.78-2.046-.002-2.827L28.243 24l8.485-8.485c.783-.784.782-2.047 0-2.827l-1.416-1.417c-.777-.777-2.046-.78-2.827.002L24 19.757zM24 47c12.703 0 23-10.297 23-23S36.703 1 24 1 1 11.297 1 24s10.297 23 23 23z" />
|
||||||
</symbol>
|
</symbol>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
@@ -123,6 +123,16 @@
|
|||||||
type: boolean
|
type: boolean
|
||||||
# ------- End of Facebook Channel Related Config ------- #
|
# ------- End of Facebook Channel Related Config ------- #
|
||||||
|
|
||||||
|
# MARK: Microsoft Email Channel Config
|
||||||
|
- name: AZURE_APP_ID
|
||||||
|
display_title: 'Azure App ID'
|
||||||
|
description: 'The App ID that will be used to authenticate with customer Microsoft accounts. Find more details on setting up Azure here: https://chwt.app/dev/ms'
|
||||||
|
locked: false
|
||||||
|
- name: AZURE_APP_SECRET
|
||||||
|
display_title: 'Azure App Secret'
|
||||||
|
locked: false
|
||||||
|
# End of Microsoft Email Channel Config
|
||||||
|
|
||||||
# ------- Chatwoot Internal Config for Cloud ----#
|
# ------- Chatwoot Internal Config for Cloud ----#
|
||||||
- name: CHATWOOT_INBOX_TOKEN
|
- name: CHATWOOT_INBOX_TOKEN
|
||||||
value:
|
value:
|
||||||
|
|||||||
@@ -66,3 +66,9 @@ help_center:
|
|||||||
description: 'Allow agents to create help center articles and publish them in a portal.'
|
description: 'Allow agents to create help center articles and publish them in a portal.'
|
||||||
enabled: true
|
enabled: true
|
||||||
icon: 'icon-book-2-line'
|
icon: 'icon-book-2-line'
|
||||||
|
microsoft:
|
||||||
|
name: 'Microsoft'
|
||||||
|
description: 'Configuration for setting up Microsoft Email'
|
||||||
|
enabled: true
|
||||||
|
icon: 'icon-microsoft'
|
||||||
|
config_key: 'microsoft'
|
||||||
|
|||||||
Reference in New Issue
Block a user