Skip to content

Commit 0eb5485

Browse files
fix(stt): honor satellite_stt profile permission for transcription/summary (#353)
1 parent d9296c6 commit 0eb5485

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

root/usr/lib/node/nethcti-server/plugins/authorization/authorization.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,35 @@ function authorizeRecordingUser(username) {
429429
}
430430
}
431431

432+
/**
433+
* Returns true if the specified user has the Speech-To-Text authorization.
434+
*
435+
* @method authorizeSttUser
436+
* @param {string} username The username
437+
* @return {boolean} True if the user has the Speech-To-Text authorization.
438+
*/
439+
function authorizeSttUser(username) {
440+
try {
441+
// check parameter
442+
if (typeof username !== 'string') {
443+
throw new Error('wrong parameters: ' + JSON.stringify(arguments));
444+
}
445+
446+
var profid = getUserProfileId(username);
447+
448+
return (
449+
profiles[profid] !== undefined &&
450+
profiles[profid].macro_permissions.nethvoice_cti.value === true &&
451+
profiles[profid].macro_permissions.nethvoice_cti.permissions.satellite_stt.value === true
452+
);
453+
454+
} catch (err) {
455+
logger.log.error(IDLOG, err.stack);
456+
// in the case of exception it returns false for security reasons
457+
return false;
458+
}
459+
}
460+
432461
/**
433462
* Returns true if the specified user has the authorization to view the lost calls of the queues.
434463
*
@@ -2189,6 +2218,7 @@ exports.authorizeAdminCdrUser = authorizeAdminCdrUser;
21892218
exports.getUserAuthorizations = getUserAuthorizations;
21902219
exports.authorizeAdminPhoneUser = authorizeAdminPhoneUser;
21912220
exports.authorizeRecordingUser = authorizeRecordingUser;
2221+
exports.authorizeSttUser = authorizeSttUser;
21922222
exports.authorizePhonebookUser = authorizePhonebookUser;
21932223
exports.authorizeStreamingUser = authorizeStreamingUser;
21942224
exports.authorizeRemoteSiteUser = authorizeRemoteSiteUser;

root/usr/lib/node/nethcti-server/plugins/com_user_rest/plugins_rest/user.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,13 @@ function setCompUtil(comp) {
728728
logger.log.info(IDLOG, "Proxy fqdn missing");
729729
}
730730

731+
// Speech-To-Text features depend both on the module-level switch
732+
// (SATELLITE_* env vars) and on the user's "satellite_stt" profile permission.
733+
var hasSttPermission = compAuthorization.authorizeSttUser(username);
734+
731735
// Add call transcriptions status
732736
var call_transcription_enabled = process.env.SATELLITE_CALL_TRANSCRIPTION_ENABLED;
733-
if (call_transcription_enabled && call_transcription_enabled == 'True') {
737+
if (hasSttPermission && call_transcription_enabled && call_transcription_enabled == 'True') {
734738
result.call_transcription_enabled = true;
735739
} else {
736740
logger.log.info(IDLOG, "call_transcription_enabled missing");
@@ -746,7 +750,7 @@ function setCompUtil(comp) {
746750

747751
// Add call summary status
748752
var call_summary_enabled = process.env.SATELLITE_CALL_SUMMARY_ENABLED;
749-
if (call_summary_enabled && call_summary_enabled == 'True') {
753+
if (hasSttPermission && call_summary_enabled && call_summary_enabled == 'True') {
750754
result.call_summary_enabled = true;
751755
} else {
752756
logger.log.info(IDLOG, "call_summary_enabled missing");

0 commit comments

Comments
 (0)