Add identity providers for agents and client contacts: Admin, Identity Providers under Integrations adds Microsoft 365, Google Workspace and Nextcloud (OIDC Identity Provider app) sign-in buttons and IMAP mail-password sign-in, each for agents, client contacts or both and for the email domains listed; no account is created by signing in; Microsoft, Google and Nextcloud stand in for ITFlow two-step sign-in while IMAP still asks for the code; a provider can be required, turning off password sign-in on its domains with passkeys and administrator passwords still working; credentials stay locked after a provider or mail password sign-in until the ITFlow password is typed; the client portal Microsoft Entra single sign-on moves to a Microsoft 365 provider keeping its redirect address; database 4.2.5 adds identity_providers and drops the old Entra settings; 26.12.3 changelog entries

This commit is contained in:
johnnyq
2026-11-29 20:13:10 -05:00
parent 626f472990
commit fffa5680db
32 changed files with 1671 additions and 340 deletions

View File

@@ -0,0 +1,62 @@
<?php
/*
* ITFlow - Database update to version 4.2.5 (from 4.2.4)
* Included by admin/database_updates.php - do not access directly
*
* Identity providers (functions/identity_provider.php, Admin > Identity Providers): agents and
* client contacts signing in with Microsoft 365, Google Workspace, Nextcloud or their mail
* password (IMAP). identity_providers - each one's kind and name, whether it is on, who it signs
* in (agents, contacts) and on which email domains, whether it is required, its app's ID and
* secret, its tenant (Microsoft), address (Nextcloud, or the IMAP server with its port, security
* and username style), the path it sends people back to, and when it was last used.
*
* The Microsoft Entra app the client portal signed in with (settings.config_azure_client_id and
* config_azure_client_secret) becomes the first provider, for client contacts on any domain, still
* sending them back to /client/login_microsoft.php - the address registered with it - and the two
* settings go. Contacts set to sign in with Microsoft keep that (users.user_auth_method azure),
* now meaning through an identity provider, without a password. Re-runnable.
*/
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
mysqli_query($mysqli, "CREATE TABLE IF NOT EXISTS `identity_providers` (
`identity_provider_id` int(11) NOT NULL AUTO_INCREMENT,
`identity_provider_kind` varchar(20) NOT NULL,
`identity_provider_name` varchar(100) NOT NULL,
`identity_provider_enabled` tinyint(1) NOT NULL DEFAULT 1,
`identity_provider_agents` tinyint(1) NOT NULL DEFAULT 0,
`identity_provider_contacts` tinyint(1) NOT NULL DEFAULT 0,
`identity_provider_domains` varchar(1000) NOT NULL DEFAULT '',
`identity_provider_required` tinyint(1) NOT NULL DEFAULT 0,
`identity_provider_client_id` varchar(255) NOT NULL DEFAULT '',
`identity_provider_client_secret` varchar(1000) NOT NULL DEFAULT '',
`identity_provider_tenant` varchar(100) NOT NULL DEFAULT '',
`identity_provider_url` varchar(500) NOT NULL DEFAULT '',
`identity_provider_port` int(11) NOT NULL DEFAULT 0,
`identity_provider_security` varchar(10) NOT NULL DEFAULT '',
`identity_provider_username` varchar(10) NOT NULL DEFAULT '',
`identity_provider_redirect_path` varchar(100) NOT NULL DEFAULT '/login_provider.php',
`identity_provider_used_at` datetime DEFAULT NULL,
`identity_provider_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`identity_provider_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
PRIMARY KEY (`identity_provider_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci");
// The client portal's Microsoft Entra app, as the first provider - once
$itflow_azure_column = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'settings' AND COLUMN_NAME = 'config_azure_client_id' LIMIT 1");
if ($itflow_azure_column && mysqli_num_rows($itflow_azure_column) > 0) {
$itflow_azure = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT config_azure_client_id, config_azure_client_secret FROM settings WHERE company_id = 1"));
$itflow_azure_id = trim((string) ($itflow_azure['config_azure_client_id'] ?? ''));
$itflow_azure_secret = trim((string) ($itflow_azure['config_azure_client_secret'] ?? ''));
$itflow_providers = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM identity_providers"))[0] ?? 0);
if ($itflow_azure_id !== '' && $itflow_providers === 0) {
mysqli_query($mysqli, "INSERT INTO identity_providers SET identity_provider_kind = 'microsoft', identity_provider_name = 'Microsoft 365',
identity_provider_enabled = 1, identity_provider_agents = 0, identity_provider_contacts = 1,
identity_provider_client_id = '" . mysqli_real_escape_string($mysqli, $itflow_azure_id) . "',
identity_provider_client_secret = '" . mysqli_real_escape_string($mysqli, $itflow_azure_secret) . "',
identity_provider_redirect_path = '/client/login_microsoft.php'");
}
mysqli_query($mysqli, "ALTER TABLE `settings` DROP COLUMN `config_azure_client_id`, DROP COLUMN `config_azure_client_secret`");
}

View File

@@ -1,56 +1,205 @@
<?php
/*
* Admin > Settings > Single sign-on - client contacts signing in to the
* portal with their Microsoft 365 account (client/login_microsoft.php),
* through an app registered in Microsoft Entra. The secret is never put back
* into the page: left empty it stays as saved. Saved by
* edit_identity_provider (admin/post/identity_provider.php).
* Admin > Identity Providers - the ways agents and client contacts sign in besides their ITFlow
* password (functions/identity_provider.php): Microsoft 365, Google Workspace and Nextcloud, each
* a button on the sign-in page, and IMAP, which checks the password typed there with a mail
* server. Each row says what it is, who it signs in and on which email domains, whether it is
* required, and when it was last used. New is a menu of the kinds; Add and Edit are one window
* (modals/identity_provider/identity_provider_edit.php); the rest are
* admin/post/identity_provider.php.
*/
// Default Column Sortby Filter
$sort = "identity_provider_name";
$order = "ASC";
require_once "includes/inc_all_admin.php";
$redirect_uri = 'https://' . preg_replace('#^https?://#', '', rtrim((string) $config_base_url, '/')) . '/client/login_microsoft.php';
$secret_saved = trim((string) $config_azure_client_secret) !== '';
// The table arrives with the 4.2.5 database update
if (!identityProvidersReady()) { ?>
<div class="alert alert-warning"><i class="fas fa-fw fa-exclamation-triangle me-2"></i>Identity Providers arrive with a database update - run it in <a href="update.php">Maintenance &gt; Update</a> first.</div>
<?php
require_once "../includes/footer.php";
exit;
}
echo settingsPageStart('identity');
$kinds = identityProviderKinds();
// Only these sort - an unknown column would take the page down
$sortable_columns = [
'identity_provider_name' => "identity_provider_name $order",
'identity_provider_kind' => "identity_provider_kind $order, identity_provider_name ASC",
'identity_provider_used_at' => "identity_provider_used_at IS NULL, identity_provider_used_at $order, identity_provider_name ASC",
];
if (!isset($sortable_columns[$sort])) {
$sort = 'identity_provider_name';
}
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM identity_providers
WHERE (identity_provider_name LIKE '%$q%' OR identity_provider_domains LIKE '%$q%' OR identity_provider_kind LIKE '%$q%' OR identity_provider_url LIKE '%$q%')
ORDER BY {$sortable_columns[$sort]}, identity_provider_id ASC
LIMIT $record_from, $record_to");
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$csrf = $_SESSION['csrf_token'];
$add_url = 'modals/identity_provider/identity_provider_edit.php?kind=';
?>
<form action="post.php" method="post" autocomplete="off" data-settings-form>
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<div class="card itflow-settings-card">
<div class="card-body">
<?php if (!$config_client_portal_enable) { ?>
<div class="alert alert-warning py-2 small"><i class="fas fa-exclamation-triangle me-2"></i>The client portal is off - turn it on in <a href="settings_module.php">Modules</a>.</div>
<?php } ?>
<?= settingsSectionStart('entra', 'Microsoft Entra', 'A contact with portal access signs in with their Microsoft 365 work account - its email has to be theirs in ITFlow. Register an app in Microsoft Entra for accounts in any organization\'s directory, with the redirect address below, and put its ID and a secret here.') ?>
<div class="itflow-settings-field" data-sso-state>
<span class="badge rounded-pill <?= $config_azure_client_id ? 'text-bg-success' : 'text-bg-secondary' ?>"><?= $config_azure_client_id ? 'Set up' : 'Not set up' ?></span>
<span class="small text-body-secondary ms-1"><?= $config_azure_client_id ? 'The portal\'s sign-in page offers Sign in with Microsoft.' : 'Contacts sign in with a password.' ?></span>
<div class="card">
<div class="card-header bg-dark py-2">
<h3 class="card-title mt-2"><i class="fas fa-fw fa-id-badge me-2"></i>Identity Providers</h3>
<div class="card-tools">
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"><i class="fas fa-plus"></i><span class="d-none d-lg-inline ms-2">New Identity Provider</span></button>
<div class="dropdown-menu dropdown-menu-end" data-identity-provider-new>
<?php foreach ($kinds as $key => $info) { ?>
<a class="dropdown-item ajax-modal py-2" href="#" data-modal-size="lg" data-modal-url="<?= $add_url . $key ?>">
<i class="<?= escapeHtml($info['icon']) ?> fa-fw text-secondary me-2"></i><?= escapeHtml($info['name']) ?>
<div class="small text-body-secondary text-wrap ms-4 ps-2" style="max-width: 20rem;"><?= escapeHtml($info['about']) ?></div>
</a>
<?php } ?>
</div>
<div class="itflow-settings-field" data-setting="redirect_uri">
<label class="form-label" for="settingsRedirectUri">Redirect address</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-link"></i></span>
<input type="text" class="form-control font-monospace" id="settingsRedirectUri" value="<?= escapeHtml($redirect_uri) ?>" readonly data-sso-redirect>
<button type="button" class="btn btn-outline-secondary clipboardjs" data-clipboard-target="#settingsRedirectUri" title="Copy"><i class="far fa-fw fa-copy"></i></button>
</div>
<div class="form-text">Under Authentication in the app registration, as a Web platform.</div>
</div>
<?= settingsInput('config_azure_client_id', $config_azure_client_id, ['icon' => 'fa-fingerprint', 'maxlength' => 200, 'placeholder' => 'e721e3b6-01d6-50e8-7f22-c84d951a52e7',
'help' => 'From the app\'s Overview. Empty turns signing in with Microsoft off, and forgets the secret.']) ?>
<?= settingsInput('config_azure_client_secret', '', ['icon' => 'fa-key', 'type' => 'password', 'maxlength' => 200, 'autocomplete' => 'new-password',
'placeholder' => $secret_saved ? 'Saved - type a new one to replace it' : 'From Certificates & secrets',
'help' => 'Its Value, not its ID. A secret runs out - put the new one here before it does.']) ?>
<?= settingsSectionEnd() ?>
<?= settingsSaveBar('edit_identity_provider') ?>
</div>
</div>
</div>
</form>
<?php if (!$config_client_portal_enable) { ?>
<div class="card-header py-2 small text-body-secondary">
<i class="fas fa-fw fa-info-circle me-1"></i>The client portal is off in <a class="text-reset" href="settings_module.php">Modules</a>, so identity providers sign in agents only.
</div>
<?php } ?>
<div class="card-header py-3">
<form autocomplete="off">
<div class="row g-2 align-items-center">
<div class="col-lg-5 col-md-6">
<div class="input-group">
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(escapeHtml($q)); } ?>" placeholder="Search identity providers..." title="Name, kind, email domain or address">
<button class="btn btn-dark" title="Search"><i class="fas fa-search"></i></button>
</div>
</div>
</div>
</form>
</div>
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light text-nowrap <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
<tr>
<th class="ps-3"><?= sortLink('identity_provider_name', 'Identity provider') ?></th>
<th class="d-none d-lg-table-cell"><?= sortLink('identity_provider_kind', 'Kind') ?></th>
<th class="d-none d-md-table-cell">Signs in</th>
<th class="d-none d-md-table-cell">Email domains</th>
<th class="d-none d-sm-table-cell"><?= sortLink('identity_provider_used_at', 'Last used') ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php while ($row = mysqli_fetch_assoc($sql)) {
$identity_provider_id = intval($row['identity_provider_id']);
$name = (string) $row['identity_provider_name'];
$kind = identityProviderKind($row);
$on = intval($row['identity_provider_enabled']) === 1;
$edit_url = "modals/identity_provider/identity_provider_edit.php?id=$identity_provider_id";
$domains = identityProviderDomains($row);
$agents = intval($row['identity_provider_agents']) === 1;
$contacts = intval($row['identity_provider_contacts']) === 1;
$required = $kind && $kind['oauth'] && intval($row['identity_provider_required']) === 1 && $domains;
if ($row['identity_provider_kind'] === 'imap') {
$where = $row['identity_provider_url'] . ':' . intval($row['identity_provider_port']);
} elseif ($row['identity_provider_kind'] === 'nextcloud') {
$where = (string) parse_url(identityProviderNextcloudUrl($row), PHP_URL_HOST);
} elseif ($row['identity_provider_kind'] === 'microsoft') {
$where = trim((string) $row['identity_provider_tenant']) !== '' ? 'Tenant ' . $row['identity_provider_tenant'] : 'Any organization';
} else {
$where = '';
}
$who = array_filter([$agents ? 'Agents' : '', $contacts ? 'Client contacts' : '']);
?>
<tr data-identity-provider-id="<?= $identity_provider_id ?>" class="<?= $on ? '' : 'text-body-secondary' ?>">
<td class="ps-3">
<div class="d-flex align-items-center gap-3">
<span class="d-none d-sm-inline-flex itflow-asset-icon itflow-asset-tone-other" aria-hidden="true"><i class="<?= escapeHtml($kind['icon'] ?? 'fas fa-id-badge') ?>"></i></span>
<div class="min-w-0">
<?php if ($kind) { ?>
<a class="fw-semibold text-body ajax-modal" href="#" data-modal-size="lg" data-modal-url="<?= $edit_url ?>"><?= escapeHtml($name) ?></a>
<?php } else { ?>
<span class="fw-semibold"><?= escapeHtml($name) ?></span>
<span class="badge rounded-pill text-bg-warning ms-1" title="This ITFlow doesn't know its kind (<?= escapeHtml($row['identity_provider_kind']) ?>) - it signs no one in">Unknown kind</span>
<?php } ?>
<?php if ($kind && !$on) { ?>
<span class="badge rounded-pill text-bg-secondary ms-1" data-identity-provider-state="off" title="It signs no one in<?= $kind['oauth'] ? ', and has no button on the sign-in page' : '' ?>">Off</span>
<?php } ?>
<?php if ($required) { ?>
<span class="badge rounded-pill bg-warning-subtle text-warning-emphasis border border-warning-subtle fw-normal ms-1" data-identity-provider-required title="Accounts on its email domains can't sign in with a password - an administrator still can">Required</span>
<?php } ?>
<div class="small text-body-secondary text-truncate"><span class="d-lg-none"><?= escapeHtml($kind['name'] ?? $row['identity_provider_kind']) ?><?= $where !== '' ? ' &middot; ' : '' ?></span><?= escapeHtml($where) ?></div>
<div class="d-md-none small text-body-secondary"><?= escapeHtml($who ? implode(' and ', $who) : 'No one') ?> &middot; <?= escapeHtml($domains ? implode(', ', $domains) : 'Any email domain') ?></div>
</div>
</div>
</td>
<td class="d-none d-lg-table-cell small"><?= escapeHtml($kind['name'] ?? $row['identity_provider_kind']) ?></td>
<td class="d-none d-md-table-cell small">
<?php if (!$who) { ?>
<span class="text-body-secondary">No one</span>
<?php } ?>
<?php if ($agents) { ?>
<span class="badge rounded-pill text-bg-light border fw-normal"><i class="fas fa-user-tie me-1"></i>Agents</span>
<?php } ?>
<?php if ($contacts) { ?>
<span class="badge rounded-pill text-bg-light border fw-normal" <?= $config_client_portal_enable ? '' : 'title="Not while the client portal is off"' ?>><i class="fas fa-user-friends me-1"></i>Client contacts<?= $config_client_portal_enable ? '' : ' - portal off' ?></span>
<?php } ?>
</td>
<td class="d-none d-md-table-cell small"><?= $domains ? escapeHtml(implode(', ', $domains)) : '<span class="text-body-secondary">Any email domain</span>' ?></td>
<td class="d-none d-sm-table-cell small" data-identity-provider-used="<?= $row['identity_provider_used_at'] ? 'yes' : 'never' ?>">
<?php if ($row['identity_provider_used_at']) { ?>
<span class="text-nowrap" title="<?= formatDateTime($row['identity_provider_used_at']) ?>"><i class="fas fa-fw fa-check-circle text-success me-1"></i><?= escapeHtml(timeAgo($row['identity_provider_used_at'])) ?></span>
<?php } else { ?>
<span class="text-body-secondary">Not yet</span>
<?php } ?>
</td>
<td class="text-end pe-3">
<div class="dropdown dropstart">
<button class="btn btn-sm btn-light" title="More actions" type="button" data-bs-toggle="dropdown"><i class="fas fa-fw fa-ellipsis-v"></i></button>
<div class="dropdown-menu">
<?php if ($kind) { ?>
<a class="dropdown-item ajax-modal" href="#" data-modal-size="lg" data-modal-url="<?= $edit_url ?>"><i class="fas fa-fw fa-edit text-secondary me-2"></i>Edit</a>
<?php if ($on) { ?>
<a class="dropdown-item confirm-link" href="post.php?turn_identity_provider_off=<?= $identity_provider_id ?>&amp;csrf_token=<?= $csrf ?>"
data-confirm-title="Turn <?= escapeHtml($name) ?> off?" data-confirm-button="Turn off"
data-confirm-text="No one signs in with it until it is on again<?= $required ? ' - the accounts on its email domains sign in with their password meanwhile' : '' ?>.">
<i class="fas fa-fw fa-toggle-off text-secondary me-2"></i>Turn Off
</a>
<?php } else { ?>
<a class="dropdown-item" href="post.php?turn_identity_provider_on=<?= $identity_provider_id ?>&amp;csrf_token=<?= $csrf ?>"><i class="fas fa-fw fa-toggle-on text-secondary me-2"></i>Turn On</a>
<?php } ?>
<div class="dropdown-divider"></div>
<?php } ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?delete_identity_provider=<?= $identity_provider_id ?>&amp;csrf_token=<?= $csrf ?>"
data-confirm-title="Delete <?= escapeHtml($name) ?>?" data-confirm-button="Delete"
data-confirm-text="No one signs in with it any more. Their accounts stay - a contact set to sign in only through an identity provider needs another one, or a password.">
<i class="fas fa-fw fa-trash me-2"></i>Delete
</a>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php
$empty_state = [
'thing' => 'identity providers',
'icon' => 'fa-id-badge',
'text' => 'Let agents and client contacts sign in with their Microsoft 365, Google Workspace or Nextcloud account, or with their mail password through an IMAP server - picked by the domain of their email address. No one new is added: the account has to be in ITFlow already.',
'actions' => array_map(function ($key, $info) use ($add_url) {
return ['label' => $info['name'], 'icon' => 'fa-plus', 'modal' => $add_url . $key, 'size' => 'lg'];
}, array_keys($kinds), $kinds),
];
?>
<?php require_once "../includes/filter_footer.php"; ?>
</div>
<?php
require_once "../includes/footer.php";

View File

@@ -163,6 +163,12 @@
<p>Phone Systems</p>
</a>
</li>
<li class="nav-item">
<a href="/admin/identity_providers.php" class="nav-link <?= (basename($_SERVER['PHP_SELF']) == 'identity_providers.php' ? 'active' : '') ?>">
<i class="nav-icon fas fa-id-badge"></i>
<p>Identity Providers</p>
</a>
</li>
<li class="nav-item">
<a href="/admin/custom_links.php" class="nav-link <?= (basename($_SERVER['PHP_SELF']) == 'custom_links.php' ? 'active' : '') ?>">
<i class="nav-icon fas fa-external-link-alt"></i>

View File

@@ -0,0 +1,229 @@
<?php
/*
* Admin > Identity Providers - one identity provider's window: Add (?kind=, no id) or Edit (?id=).
* Which kind it is is picked from the New menu and stays. How to set it up on the provider's side
* is at the top, with the redirect address to register there. The secret is never put back into
* the page - left empty, it stays as saved. Saved by save_identity_provider
* (admin/post/identity_provider.php).
*/
require_once '../../includes/modal_header.php';
if (!identityProvidersReady()) {
echo json_encode(['error' => 'Identity providers arrive with a database update - run it in Maintenance > Update first.']);
exit;
}
$identity_provider_id = intval($_GET['id'] ?? 0);
$row = $identity_provider_id ? identityProviderRow($identity_provider_id) : null;
if ($identity_provider_id && !$row) {
echo json_encode(['error' => 'That identity provider no longer exists.']);
exit;
}
$kinds = identityProviderKinds();
$kind_key = $row ? (string) $row['identity_provider_kind'] : (string) ($_GET['kind'] ?? '');
if (!isset($kinds[$kind_key])) {
echo json_encode(['error' => $row ? 'This ITFlow doesn\'t know that identity provider\'s kind.' : 'Pick which kind of identity provider to add.']);
exit;
}
$kind = $kinds[$kind_key];
$fields = $kind['fields'];
$value = function ($column, $default = '') use ($row) {
return $row ? (string) ($row["identity_provider_$column"] ?? $default) : $default;
};
$secret_saved = $row && trim((string) $row['identity_provider_client_secret']) !== '';
$redirect_uri = identityProviderRedirectUri($row ?: []);
$form_id = 'identityProvider' . ($identity_provider_id ?: 'New');
$security = $value('security', 'ssl');
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="<?= escapeHtml($kind['icon']) ?> fa-fw me-2"></i><?= $row ? '<strong>' . escapeHtml($row['identity_provider_name']) . '</strong>' : 'New ' . escapeHtml($kind['name']) . ' Identity Provider' ?></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form action="post.php" method="post" autocomplete="off" data-identity-provider-form="<?= escapeHtml($kind_key) ?>">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<input type="hidden" name="identity_provider_id" value="<?= $identity_provider_id ?>">
<input type="hidden" name="kind" value="<?= escapeHtml($kind_key) ?>">
<div class="modal-body">
<div class="alert alert-light border small mb-3" data-identity-provider-setup>
<div class="fw-semibold mb-1"><i class="fas fa-fw fa-info-circle me-1"></i>Setting it up</div>
<?php if ($kind_key === 'microsoft') { ?>
In the Microsoft Entra admin center, under App registrations, make a New registration for accounts in any organizational directory (or only yours), with a Web redirect address of the one below. Copy its Application (client) ID here, then under Certificates &amp; secrets make a client secret and copy its Value. The Microsoft Graph User.Read permission it starts with is all it needs.
<?php } elseif ($kind_key === 'google') { ?>
In the Google Cloud console, under APIs &amp; Services &gt; Credentials, create an OAuth client ID for a Web application, with an authorized redirect address of the one below, and copy its Client ID and Client secret here. Make its OAuth consent screen Internal to keep it to your own Google Workspace.
<?php } elseif ($kind_key === 'nextcloud') { ?>
Install the OIDC Identity Provider app (oidc) on your Nextcloud. In its Administration settings, under OpenID Connect, add a client with the redirect address below, of the Confidential type, and copy its client identifier and secret here.
<div class="mt-1"><i class="fas fa-fw fa-exclamation-triangle text-warning me-1"></i>ITFlow goes by the email address Nextcloud gives - make sure its users can't change their own, or one of them could sign in here as another.</div>
<?php } else { ?>
Nothing is set up on the mail server: the password typed on the sign-in page is tried there, in place of the ITFlow password, and the ITFlow two-step code is still asked for. An agent with an administrator role can still use their ITFlow password, for when the mail server is down. Use a server that takes TLS, and list only domains whose mailboxes are on it.
<?php } ?>
<?php if ($kind['oauth']) { ?>
<div class="input-group input-group-sm mt-2">
<span class="input-group-text"><i class="fas fa-fw fa-link"></i></span>
<input type="text" class="form-control font-monospace" id="<?= $form_id ?>Redirect" value="<?= escapeHtml($redirect_uri) ?>" readonly aria-label="Redirect address" data-identity-provider-redirect>
<button type="button" class="btn btn-outline-secondary clipboardjs" data-clipboard-target="#<?= $form_id ?>Redirect" title="Copy"><i class="far fa-fw fa-copy"></i></button>
</div>
<?php } ?>
</div>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="enabled" value="1" id="<?= $form_id ?>Enabled" <?= !$row || intval($row['identity_provider_enabled']) ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Enabled">On<?= $kind['oauth'] ? ' - its button is on the sign-in page' : ' - it checks the passwords on its email domains' ?></label>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Name">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-tag"></i></span>
<input type="text" class="form-control" name="name" id="<?= $form_id ?>Name" maxlength="100" required value="<?= escapeHtml($value('name', $kind['name'])) ?>" placeholder="What you call it">
</div>
<div class="form-text"><?= $kind['oauth'] ? 'Its button on the sign-in page says &quot;Sign in with&quot; and this name.' : 'What the audit log calls it.' ?></div>
</div>
<div class="itflow-form-section">Who it signs in</div>
<div class="mb-3">
<div class="d-flex flex-wrap gap-4">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="agents" value="1" id="<?= $form_id ?>Agents" <?= $value('agents', '1') === '1' ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Agents"><i class="fas fa-fw fa-user-tie text-secondary me-1"></i>Agents</label>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="contacts" value="1" id="<?= $form_id ?>Contacts" <?= $value('contacts', '0') === '1' ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Contacts"><i class="fas fa-fw fa-user-friends text-secondary me-1"></i>Client contacts</label>
</div>
</div>
<div class="form-text">
Only accounts already in ITFlow - an agent, or a contact with portal access - with the same email address. No one new is added.
<?php if (!$config_client_portal_enable) { ?>The client portal is off, so it signs in agents only until it is on.<?php } ?>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Domains">Email domains<?= $kind['domains_optional'] ? '' : ' <strong class="text-danger">*</strong>' ?></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-at"></i></span>
<input type="text" class="form-control" name="domains" id="<?= $form_id ?>Domains" maxlength="1000" spellcheck="false" <?= $kind['domains_optional'] ? '' : 'required' ?> value="<?= escapeHtml($value('domains')) ?>" placeholder="example.com, example.org">
</div>
<div class="form-text">
<?php if ($kind['domains_optional']) { ?>
The accounts it signs in are the ones on these domains. Empty, it signs in any <?= escapeHtml($kind['name']) ?> account whose address is in ITFlow - <?= escapeHtml($kind_key === 'microsoft' ? 'Microsoft' : 'Google') ?> vouches for it.
<?php } else { ?>
The accounts it signs in are the ones on these domains - <?= $kind_key === 'imap' ? 'list only domains whose mailboxes are all on this server.' : 'a Nextcloud\'s users can set their own email address, so list only domains whose people are all on yours.' ?>
<?php } ?>
</div>
</div>
<?php if ($kind['oauth']) { ?>
<div class="mb-3">
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="required" value="1" id="<?= $form_id ?>Required" <?= $value('required', '0') === '1' ? 'checked' : '' ?>>
<label class="form-check-label" for="<?= $form_id ?>Required">Required - the accounts on its email domains can't sign in with a password</label>
</div>
<div class="form-text ps-5">Passkeys still work, and an agent with an administrator role keeps their password, to get back in when it is down. Needs email domains.</div>
</div>
<?php } ?>
<div class="itflow-form-section"><?= $kind['oauth'] ? 'The app' : 'The mail server' ?></div>
<?php if ($kind_key === 'nextcloud') { ?>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Url">Address <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-globe"></i></span>
<input type="url" class="form-control" name="url" id="<?= $form_id ?>Url" maxlength="500" spellcheck="false" required value="<?= escapeHtml($value('url')) ?>" placeholder="https://cloud.example.com">
</div>
<div class="form-text">Where your Nextcloud is. ITFlow asks it for its OpenID Connect settings when you save.</div>
</div>
<?php } ?>
<?php if (in_array('client_id', $fields, true)) { ?>
<div class="row g-3 mb-3">
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>ClientId"><?= $kind_key === 'microsoft' ? 'Application (client) ID' : 'Client ID' ?> <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-fingerprint"></i></span>
<input type="text" class="form-control font-monospace" name="client_id" id="<?= $form_id ?>ClientId" maxlength="255" spellcheck="false" required value="<?= escapeHtml($value('client_id')) ?>"
placeholder="<?= $kind_key === 'microsoft' ? 'e721e3b6-01d6-50e8-7f22-c84d951a52e7' : ($kind_key === 'google' ? '…apps.googleusercontent.com' : 'From its client') ?>">
</div>
</div>
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>Secret">Client secret <?= $secret_saved ? '' : '<strong class="text-danger">*</strong>' ?></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-key"></i></span>
<input type="password" class="form-control" name="client_secret" id="<?= $form_id ?>Secret" maxlength="1000" autocomplete="new-password" <?= $secret_saved ? '' : 'required' ?>
placeholder="<?= $secret_saved ? 'Saved - type a new one to replace it' : ($kind_key === 'microsoft' ? 'Its Value, not its ID' : 'From its client') ?>">
</div>
<?php if ($kind_key === 'microsoft') { ?><div class="form-text">A secret runs out - put the new one here before it does.</div><?php } ?>
</div>
</div>
<?php } ?>
<?php if (in_array('tenant', $fields, true)) { ?>
<div class="mb-3">
<label class="form-label" for="<?= $form_id ?>Tenant">Directory (tenant) ID</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-building"></i></span>
<input type="text" class="form-control font-monospace" name="tenant" id="<?= $form_id ?>Tenant" maxlength="100" spellcheck="false" value="<?= escapeHtml($value('tenant')) ?>" placeholder="Any organization">
</div>
<div class="form-text">Only for an app registered for your directory alone - its ID, from the app's Overview. Empty takes work accounts from any organization; personal Microsoft accounts never sign in.</div>
</div>
<?php } ?>
<?php if ($kind_key === 'imap') { ?>
<div class="row g-3 mb-3">
<div class="col-md-8">
<label class="form-label" for="<?= $form_id ?>Host">Server <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-server"></i></span>
<input type="text" class="form-control" name="url" id="<?= $form_id ?>Host" maxlength="255" spellcheck="false" required value="<?= escapeHtml($value('url')) ?>" placeholder="mail.example.com">
</div>
</div>
<div class="col-md-4">
<label class="form-label" for="<?= $form_id ?>Port">Port</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-plug"></i></span>
<input type="number" class="form-control" name="port" id="<?= $form_id ?>Port" min="1" max="65535" value="<?= $row ? intval($row['identity_provider_port']) : '' ?>" placeholder="993">
</div>
</div>
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>Security">Security</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-lock"></i></span>
<select class="form-select select2" name="security" id="<?= $form_id ?>Security">
<?php foreach (['ssl' => 'SSL/TLS', 'starttls' => 'STARTTLS', 'none' => 'None - the password goes unencrypted'] as $option => $label) { ?>
<option value="<?= $option ?>" <?= $security === $option ? 'selected' : '' ?><?= selectOptionData(['icon' => $option === 'none' ? 'fas fa-lock-open' : 'fas fa-lock']) ?>><?= escapeHtml($label) ?></option>
<?php } ?>
</select>
</div>
<div class="form-text">Empty port is 993 for SSL/TLS, 143 otherwise. Its certificate has to be a valid one.</div>
</div>
<div class="col-md-6">
<label class="form-label" for="<?= $form_id ?>Username">It is signed in to with</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-user"></i></span>
<select class="form-select select2" name="username" id="<?= $form_id ?>Username">
<option value="email" <?= $value('username', 'email') !== 'local' ? 'selected' : '' ?><?= selectOptionData(['icon' => 'fas fa-at', 'description' => 'name@example.com']) ?>>The whole email address</option>
<option value="local" <?= $value('username') === 'local' ? 'selected' : '' ?><?= selectOptionData(['icon' => 'fas fa-user', 'description' => 'name']) ?>>The part before the @</option>
</select>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="modal-footer">
<button type="submit" name="save_identity_provider" class="btn btn-primary fw-bold"><i class="fas fa-check me-2"></i><?= $row ? 'Save' : 'Create' ?></button>
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@@ -2,8 +2,8 @@
/*
* Turn on portal access - for a portal user whose access was turned off
* (Admin > Users > Client portal). How they sign in - a password, or their
* Microsoft 365 account when that is set up - and whether to email them the
* (Admin > Users > Client portal). How they sign in - a password, or only
* through an identity provider when one is on for contacts - and whether to email them the
* invite: a link to set their password, never a password.
*/
@@ -22,7 +22,7 @@ if (!$portal_user) { ?>
<?php } else {
$user_id = intval($portal_user['user_id']);
$name = escapeHtml($portal_user['contact_name']);
$methods = portalSignInMethods();
$methods = portalSignInMethods($portal_user['user_email']);
$archived = !empty($portal_user['client_archived_at']) || !empty($portal_user['contact_archived_at']);
$mail_ready = portalMailReady() && filter_var($portal_user['user_email'], FILTER_VALIDATE_EMAIL);
?>
@@ -52,7 +52,7 @@ if (!$portal_user) { ?>
<span class="input-group-text"><i class="fas fa-fw fa-sign-in-alt"></i></span>
<select class="form-select select2" name="method">
<?php foreach ($methods as $method => $label) { ?>
<option value="<?= $method ?>"<?= selectOptionData(['icon' => $method === 'azure' ? 'fab fa-microsoft' : 'fas fa-key']) ?>><?= escapeHtml($label) ?></option>
<option value="<?= $method ?>"<?= selectOptionData(['icon' => $method === 'azure' ? 'fas fa-id-badge' : 'fas fa-key']) ?>><?= escapeHtml($label) ?></option>
<?php } ?>
</select>
</div>
@@ -62,7 +62,7 @@ if (!$portal_user) { ?>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" name="send_email" value="1" id="portalUserAccessEmail<?= $user_id ?>" <?= $mail_ready ? 'checked' : 'disabled' ?>>
<label class="form-check-label" for="portalUserAccessEmail<?= $user_id ?>">Email them how to sign in</label>
<div class="form-text mt-0"><?= $mail_ready ? 'A link to set a password, or for Microsoft 365 the sign-in page.' : 'Outgoing mail is not set up, or their address is not one mail can go to.' ?></div>
<div class="form-text mt-0"><?= $mail_ready ? 'A link to set a password, or for an identity provider the sign-in page.' : 'Outgoing mail is not set up, or their address is not one mail can go to.' ?></div>
</div>
<?php } ?>
</div>

View File

@@ -1,37 +1,87 @@
<?php
/*
* Admin > Settings > Single sign-on (admin/identity_providers.php):
* edit_identity_provider saves the Microsoft Entra app the client portal
* signs in with. A secret left empty stays as saved; an empty app ID turns
* it off and forgets the secret. An ID that isn't one, or an app with no
* secret, comes back to the page saying so - nothing is saved.
* Admin > Identity Providers (functions/identity_provider.php) - Add and Edit, turning one off and
* on, and Delete. What changed is in the audit log - never the secret.
*/
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
if (isset($_POST['edit_identity_provider'])) {
if (isset($_POST['save_identity_provider'])) {
validateCSRFToken();
$before = settingsCurrent(['config_azure_client_id', 'config_azure_client_secret']);
$client_id = trim((string) ($_POST['config_azure_client_id'] ?? $before['config_azure_client_id']));
$secret = trim((string) ($_POST['config_azure_client_secret'] ?? ''));
$after = ['config_azure_client_id' => $client_id, 'config_azure_client_secret' => $client_id === '' ? '' : ($secret !== '' ? $secret : (string) $before['config_azure_client_secret'])];
$errors = [];
if ($client_id !== '' && !preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i', $client_id)) {
$errors['config_azure_client_id'] = 'The Application (client) ID - 32 letters and numbers in five groups, as e721e3b6-01d6-50e8-7f22-c84d951a52e7.';
} elseif ($client_id !== '' && $after['config_azure_client_secret'] === '') {
$errors['config_azure_client_secret'] = 'And a secret for it, from Certificates & secrets.';
if (!identityProvidersReady()) {
flashAlert('Identity providers arrive with a database update - run it first.', 'error');
redirect('update.php');
}
$identity_provider_id = intval($_POST['identity_provider_id'] ?? 0);
$before = $identity_provider_id ? identityProviderRow($identity_provider_id) : null;
if ($identity_provider_id && !$before) {
flashAlert('That identity provider no longer exists.', 'error');
redirect('identity_providers.php');
}
[$after, $errors] = identityProviderCheck($_POST, $before);
if ($errors) {
settingsRefuse('identity', $errors);
flashAlert('Not saved - ' . escapeHtml(reset($errors)), 'error');
redirect();
}
settingsSave('identity', $before, $after);
$name = $after['identity_provider_name'];
$kind = identityProviderKinds()[$after['identity_provider_kind']];
if ($before) {
$lines = identityProviderChangeLines($before, $after);
if (!$lines) {
flashAlert('Nothing changed on <strong>' . escapeHtml($name) . '</strong>', 'info');
redirect();
}
identityProviderWrite($after, $identity_provider_id);
logAudit("Identity Provider", "Edit", "$session_name changed identity provider " . escapeSql($before['identity_provider_name'] . ': ' . implode('; ', $lines)), 0, $identity_provider_id);
flashAlert('<strong>' . escapeHtml($name) . '</strong> saved');
redirect();
}
$identity_provider_id = identityProviderWrite($after);
logAudit("Identity Provider", "Create", "$session_name added identity provider " . escapeSql($name . ($name !== $kind['name'] ? " ({$kind['name']})" : '') . ($after['identity_provider_domains'] !== '' ? ' for ' . $after['identity_provider_domains'] : '')), 0, $identity_provider_id);
flashAlert('<strong>' . escapeHtml($name) . '</strong> created' . ($kind['oauth'] ? ' - its button is on the sign-in page' : ''));
redirect('identity_providers.php');
}
// Turn it off - no one signs in with it - or on again
if (isset($_GET['turn_identity_provider_off']) || isset($_GET['turn_identity_provider_on'])) {
validateCSRFToken();
$on = isset($_GET['turn_identity_provider_on']);
$provider = identityProviderRow($on ? $_GET['turn_identity_provider_on'] : $_GET['turn_identity_provider_off']);
if (!$provider) {
flashAlert('That identity provider no longer exists.', 'error');
redirect('identity_providers.php');
}
$identity_provider_id = intval($provider['identity_provider_id']);
mysqli_query($mysqli, "UPDATE identity_providers SET identity_provider_enabled = " . ($on ? 1 : 0) . " WHERE identity_provider_id = $identity_provider_id");
logAudit("Identity Provider", "Edit", "$session_name turned identity provider " . escapeSql($provider['identity_provider_name']) . ($on ? ' on' : ' off'), 0, $identity_provider_id);
flashAlert('<strong>' . escapeHtml($provider['identity_provider_name']) . '</strong> turned ' . ($on ? 'on' : 'off - no one signs in with it'), $on ? 'success' : 'error');
redirect();
}
if (isset($_GET['delete_identity_provider'])) {
validateCSRFToken();
$provider = identityProviderRow($_GET['delete_identity_provider']);
if (!$provider) {
flashAlert('That identity provider no longer exists.', 'error');
redirect('identity_providers.php');
}
$identity_provider_id = intval($provider['identity_provider_id']);
mysqli_query($mysqli, "DELETE FROM identity_providers WHERE identity_provider_id = $identity_provider_id");
logAudit("Identity Provider", "Delete", "$session_name deleted identity provider " . escapeSql($provider['identity_provider_name']), 0, $identity_provider_id);
flashAlert('<strong>' . escapeHtml($provider['identity_provider_name']) . '</strong> deleted', 'error');
redirect('identity_providers.php');
}

View File

@@ -54,7 +54,6 @@ $summaries = [
'notification' => 'Domain alerts ' . $on_off($config_enable_alert_domain_expire) . ' · ticket emails to clients ' . $on_off($config_ticket_client_general_notifications),
'security' => 'Login key ' . $on_off($config_login_key_required) . ' · devices remembered ' . $days($config_login_remember_me_expire),
'client_portal' => 'Two-step sign-in ' . ($config_client_portal_require_mfa ? 'required' : 'optional'),
'identity' => 'Microsoft Entra ' . ($config_azure_client_id ? 'set up' : 'not set up'),
'module' => $modules_on ? escapeHtml(implode(', ', $modules_on)) : 'None in use',
'telemetry' => $config_telemetry ? 'Nightly report on' : 'Off',
];

View File

@@ -39,8 +39,8 @@ $signup_clients = $signup_ready ? portalSignupClients() : [];
<div class="alert alert-warning py-2 small"><i class="fas fa-exclamation-triangle me-2"></i>The client portal is off - turn it on in <a href="settings_module.php">Modules</a>.</div>
<?php } ?>
<?= settingsSectionStart('sign-in', 'Signing in', 'A contact with portal access signs in on the same page as your agents - with a password, or their Microsoft 365 account when <a href="identity_providers.php">Single sign-on</a> is set up' . (empty($config_azure_client_id) ? ' (it isn\'t yet)' : '') . '.') ?>
<?= settingsSwitch('config_client_portal_require_mfa', $config_client_portal_require_mfa, ['id' => 'requireMfa', 'help' => 'Contacts who sign in with a password are asked for a code from an authenticator app too. Anyone without it set up is taken to set it up before anything else. Microsoft 365 sign-ins are left to Microsoft.']) ?>
<?= settingsSectionStart('sign-in', 'Signing in', 'A contact with portal access signs in on the same page as your agents - with a password, or their Microsoft 365, Google or Nextcloud account or mail password when an <a href="identity_providers.php">identity provider</a> signs in contacts' . (identityProviderNamesForContacts() || array_filter(identityProvidersOn(), function ($p) { return $p['identity_provider_kind'] === 'imap' && intval($p['identity_provider_contacts']) === 1; }) ? '' : ' (none does yet)') . '.') ?>
<?= settingsSwitch('config_client_portal_require_mfa', $config_client_portal_require_mfa, ['id' => 'requireMfa', 'help' => 'Contacts who sign in with a password are asked for a code from an authenticator app too. Anyone without it set up is taken to set it up before anything else. A sign-in through an identity provider is left to it, but a mail password (IMAP) is asked for a code too.']) ?>
<?= settingsSectionEnd() ?>
<?php if ($signup_ready) { ?>

View File

@@ -75,7 +75,7 @@ $portal_never_sql = "NOT EXISTS (SELECT 1 FROM logs WHERE log_user_id = users.us
$portal_accesses = [
'' => ['label' => 'Can sign in', 'icon' => 'fas fa-check-circle', 'where' => PORTAL_USER_ON_SQL],
'local' => ['label' => 'Password', 'icon' => 'fas fa-key', 'where' => PORTAL_USER_ON_SQL . " AND user_auth_method = 'local'"],
'azure' => ['label' => 'Microsoft 365', 'icon' => 'fab fa-microsoft', 'where' => PORTAL_USER_ON_SQL . " AND user_auth_method = 'azure'"],
'azure' => ['label' => 'Identity provider', 'icon' => 'fas fa-id-badge', 'where' => PORTAL_USER_ON_SQL . " AND user_auth_method = 'azure'"],
'nomfa' => ['label' => 'No two-step', 'icon' => 'fas fa-unlock', 'where' => PORTAL_USER_ON_SQL . " AND user_auth_method = 'local' AND (user_token IS NULL OR user_token = '')"],
'never' => ['label' => 'Never signed in', 'icon' => 'fas fa-user-clock', 'where' => PORTAL_USER_ON_SQL . " AND $portal_never_sql"],
'off' => ['label' => 'Access off', 'icon' => 'fas fa-ban', 'where' => 'NOT (' . PORTAL_USER_ON_SQL . ')'],
@@ -446,8 +446,8 @@ $csrf = $_SESSION['csrf_token'];
$login = $portal_logins[$user_id] ?? null;
$remember_count = $portal_remembered[$user_id] ?? 0;
$sign_in_pills = $is_on
? '<span class="badge rounded-pill bg-success-subtle text-success-emphasis fw-normal" title="' . ($is_local ? 'Signs in with a password' : 'Signs in with their Microsoft 365 account') . '"><i class="'
. ($is_local ? 'fas fa-key' : 'fab fa-microsoft') . ' me-1"></i>' . ($is_local ? 'Password' : 'Microsoft 365') . '</span>' . ($is_local ? ' ' . $portal_two_step($row) : '')
? '<span class="badge rounded-pill bg-success-subtle text-success-emphasis fw-normal" title="' . ($is_local ? 'Signs in with a password' : 'Signs in only with ' . escapeHtml(identityProviderContactsWording())) . '"><i class="'
. ($is_local ? 'fas fa-key' : 'fas fa-id-badge') . ' me-1"></i>' . ($is_local ? 'Password' : 'Identity provider') . '</span>' . ($is_local ? ' ' . $portal_two_step($row) : '')
: '<span class="badge rounded-pill bg-secondary-subtle text-secondary-emphasis fw-normal" title="' . escapeHtml($off_why) . '"><i class="fas fa-ban me-1"></i>Access off</span>';
?>
<tr class="itflow-ticket-row" data-portal-user="<?= $user_id ?>">