feat: show HMAC and enforcement for identity validation for API inbox (#4807)

Display HMAC token in Settings of Inbox API and enable enforcement option. I have also adjusted the copy so that it can apply to all inbox types.

Fixes: #4804
This commit is contained in:
Simon
2022-07-07 02:47:39 +07:00
committed by GitHub
parent 3145492a26
commit 91d9584fcb
4 changed files with 27 additions and 3 deletions

View File

@@ -435,9 +435,9 @@
"INBOX_UPDATE_SUB_TEXT": "Update your inbox settings",
"AUTO_ASSIGNMENT_SUB_TEXT": "Enable or disable the automatic assignment of new conversations to the agents added to this inbox.",
"HMAC_VERIFICATION": "User Identity Validation",
"HMAC_DESCRIPTION": "Inorder to validate the user's identity, the SDK allows you to pass an `identifier_hash` for each user. You can generate HMAC using 'sha256' with the key shown here.",
"HMAC_DESCRIPTION": "In order to validate the user's identity, you can pass an `identifier_hash` for each user. You can generate a HMAC sha256 hash using the `identifier` with the key shown here.",
"HMAC_MANDATORY_VERIFICATION": "Enforce User Identity Validation",
"HMAC_MANDATORY_DESCRIPTION": "If enabled, Chatwoot SDKs setUser method will not work unless the `identifier_hash` is provided for each user.",
"HMAC_MANDATORY_DESCRIPTION": "If enabled, requests missing the `identifier_hash` will be rejected.",
"INBOX_IDENTIFIER": "Inbox Identifier",
"INBOX_IDENTIFIER_SUB_TEXT": "Use the `inbox_identifier` token shown here to authentication your API clients.",
"FORWARD_EMAIL_TITLE": "Forward to Email",

View File

@@ -55,6 +55,29 @@
>
<woot-code :script="inbox.inbox_identifier" />
</settings-section>
<settings-section
:title="$t('INBOX_MGMT.SETTINGS_POPUP.HMAC_VERIFICATION')"
:sub-title="$t('INBOX_MGMT.SETTINGS_POPUP.HMAC_DESCRIPTION')"
>
<woot-code :script="inbox.hmac_token" />
</settings-section>
<settings-section
:title="$t('INBOX_MGMT.SETTINGS_POPUP.HMAC_MANDATORY_VERIFICATION')"
:sub-title="$t('INBOX_MGMT.SETTINGS_POPUP.HMAC_MANDATORY_DESCRIPTION')"
>
<div class="enter-to-send--checkbox">
<input
id="hmacMandatory"
v-model="hmacMandatory"
type="checkbox"
@change="handleHmacFlag"
/>
<label for="hmacMandatory">
{{ $t('INBOX_MGMT.EDIT.ENABLE_HMAC.LABEL') }}
</label>
</div>
</settings-section>
</div>
<div v-else-if="isAnEmailChannel">
<div class="settings--content">

View File

@@ -22,7 +22,7 @@ class Channel::Api < ApplicationRecord
include Channelable
self.table_name = 'channel_api'
EDITABLE_ATTRS = [:webhook_url, { additional_attributes: {} }].freeze
EDITABLE_ATTRS = [:webhook_url, :hmac_mandatory, { additional_attributes: {} }].freeze
has_secure_token :identifier
has_secure_token :hmac_token

View File

@@ -76,6 +76,7 @@ end
## API Channel Attributes
if resource.api?
json.hmac_token resource.channel.try(:hmac_token)
json.webhook_url resource.channel.try(:webhook_url)
json.inbox_identifier resource.channel.try(:identifier)
json.additional_attributes resource.channel.try(:additional_attributes)