feat: Ability to specify the authentication type for imap server (#12306)
# Pull Request Template ## Description This PR adds IMAP authentication mechanism selection to Chatwoot's email inbox configuration. Users can now choose between 'plain', 'login', and 'cram-md5' authentication methods when configuring IMAP settings, providing flexibility for different email providers that require specific authentication types. https://github.com/chatwoot/chatwoot/issues/8867 The implementation includes: - Frontend dropdown with numeric keys (1, 2, 3) matching SMTP auth style - Backend API validation for allowed authentication mechanisms - Consistent 'cram-md5' format throughout the codebase - Updated IMAP service to handle different auth types properly This feature maintains consistency with existing SMTP authentication options and follows the established UI/UX patterns in the application. ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Breaking change (fix or feature that would cause existing functionality not to work as expected) - [ ] This change requires a documentation update ## How Has This Been Tested? ### Manual Testing: - Tested in Docker environment - Verified IMAP auth dropdown appears in inbox settings - Confirmed all three auth mechanisms (plain, login, cram-md5) can be selected and saved - Tested API validation by attempting to save invalid auth mechanisms ### Automated Testing: - Updated existing IMAP service tests to use consistent lowercase values - Updated API controller tests for authentication parameter handling - All tests pass locally with the new changes ### Test Configuration: - Tested with both new and existing inbox configurations ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] Any dependent changes have been merged and published in downstream modules ## Additional Notes - This feature is backward compatible and doesn't break existing IMAP configurations - The 'cram-md5' format is used consistently throughout (UI, API, storage, services) - Net::IMAP compatibility is maintained by converting to 'CRAM-MD5' internally - Follows the same pattern established by SMTP authentication configuration --------- Co-authored-by: João Santos <joao.santos@madigital.eu> Co-authored-by: Sony Mathew <sony@chatwoot.com>
This commit is contained in:
co-authored by
João Santos
Sony Mathew
parent
9c1d1c4070
commit
202403873d
@@ -1011,7 +1011,8 @@
|
||||
"LABEL": "Password",
|
||||
"PLACE_HOLDER": "Password"
|
||||
},
|
||||
"ENABLE_SSL": "Enable SSL"
|
||||
"ENABLE_SSL": "Enable SSL",
|
||||
"AUTH_MECHANISM": "Authentication"
|
||||
},
|
||||
"MICROSOFT": {
|
||||
"TITLE": "Microsoft",
|
||||
|
||||
@@ -5,11 +5,13 @@ import SettingsFieldSection from 'dashboard/components-next/Settings/SettingsFie
|
||||
import { useVuelidate } from '@vuelidate/core';
|
||||
import { required, minLength } from '@vuelidate/validators';
|
||||
import NextButton from 'dashboard/components-next/button/Button.vue';
|
||||
import SingleSelectDropdown from './components/SingleSelectDropdown.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
SettingsFieldSection,
|
||||
NextButton,
|
||||
SingleSelectDropdown,
|
||||
},
|
||||
props: {
|
||||
inbox: {
|
||||
@@ -28,6 +30,12 @@ export default {
|
||||
login: '',
|
||||
password: '',
|
||||
isSSLEnabled: true,
|
||||
authMechanism: 'plain',
|
||||
authMechanisms: [
|
||||
{ key: 1, value: 'plain' },
|
||||
{ key: 2, value: 'login' },
|
||||
{ key: 3, value: 'cram-md5' },
|
||||
],
|
||||
};
|
||||
},
|
||||
validations: {
|
||||
@@ -56,6 +64,7 @@ export default {
|
||||
imap_login,
|
||||
imap_password,
|
||||
imap_enable_ssl,
|
||||
imap_authentication,
|
||||
} = this.inbox;
|
||||
this.isIMAPEnabled = imap_enabled;
|
||||
this.address = imap_address;
|
||||
@@ -63,6 +72,7 @@ export default {
|
||||
this.login = imap_login;
|
||||
this.password = imap_password;
|
||||
this.isSSLEnabled = imap_enable_ssl;
|
||||
this.authMechanism = imap_authentication || 'plain';
|
||||
},
|
||||
async updateInbox() {
|
||||
try {
|
||||
@@ -77,6 +87,7 @@ export default {
|
||||
imap_login: this.login,
|
||||
imap_password: this.password,
|
||||
imap_enable_ssl: this.isSSLEnabled,
|
||||
imap_authentication: this.authMechanism,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -90,6 +101,9 @@ export default {
|
||||
useAlert(error.message);
|
||||
}
|
||||
},
|
||||
handleAuthMechanismChange(mode) {
|
||||
this.authMechanism = mode;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -155,6 +169,13 @@ export default {
|
||||
/>
|
||||
{{ $t('INBOX_MGMT.IMAP.ENABLE_SSL') }}
|
||||
</label>
|
||||
<SingleSelectDropdown
|
||||
class="w-full"
|
||||
:label="$t('INBOX_MGMT.IMAP.AUTH_MECHANISM')"
|
||||
:selected="authMechanism"
|
||||
:options="authMechanisms"
|
||||
:action="handleAuthMechanismChange"
|
||||
/>
|
||||
</div>
|
||||
<NextButton
|
||||
type="submit"
|
||||
|
||||
Reference in New Issue
Block a user