248 lines
14 KiB
Plaintext
248 lines
14 KiB
Plaintext
<? --[[
|
||
* Pi-hole: A black hole for Internet advertisements
|
||
* (c) 2023 Pi-hole, LLC (https://pi-hole.net)
|
||
* Network-wide ad blocking via your own hardware.
|
||
*
|
||
* This file is copyright under the latest version of the EUPL.
|
||
* Please see LICENSE file for your rights under this license.
|
||
--]]
|
||
|
||
mg.include('scripts/lua/header_authenticated.lp','r')
|
||
|
||
-- Page title and level selector
|
||
PageTitle = i18n('settings.api.title')
|
||
mg.include('scripts/lua/settings_header.lp','r')
|
||
?>
|
||
<div class="row">
|
||
<div class="col-md-6">
|
||
<div class="box box-warning">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title" data-configkeys="webserver.interface.theme webserver.interface.boxed"><?= i18n('settings.api.theme_settings') ?></h3>
|
||
</div>
|
||
<div class="box-body">
|
||
<div class="row">
|
||
<div class="col-lg-12">
|
||
<div class="row form-group">
|
||
<div class="col-sm-3">
|
||
<label for="webserver.interface.theme"><?= i18n('settings.api.theme') ?></label>
|
||
</div>
|
||
<div class="col-sm-9">
|
||
<select id="webserver.interface.theme" data-key="webserver.interface.theme" class="form-control" placeholder="">
|
||
<option disabled selected><?= i18n('shared.loading') ?></option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-lg-12">
|
||
<div class="row form-group">
|
||
<div class="col-sm-12">
|
||
<div>
|
||
<input type="checkbox" id="webserver.interface.boxed" data-key="webserver.interface.boxed">
|
||
<label for="webserver.interface.boxed"><strong><?= i18n('settings.api.use_boxed_layout') ?></strong></label>
|
||
<p class="help-block"><?= i18n('settings.api.boxed_layout_help') ?></p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="col-md-6 settings-level-expert d-none">
|
||
<div class="box box-warning">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title" data-configkeys="webserver.api.prettyJSON webserver.api.allow_destructive"><?= i18n('settings.api.advanced_settings') ?></h3>
|
||
</div>
|
||
<div class="box-body">
|
||
<div class="row">
|
||
<div class="col-lg-12">
|
||
<div>
|
||
<input type="checkbox" id="webserver.api.prettyJSON" data-key="webserver.api.prettyJSON">
|
||
<label for="webserver.api.prettyJSON"><strong><?= i18n('settings.api.prettify_api_output') ?></strong></label>
|
||
<p class="help-block"><?= i18n('settings.api.pretty_json_help') ?></p>
|
||
</div>
|
||
</div>
|
||
<div class="col-lg-12">
|
||
<div>
|
||
<input type="checkbox" id="webserver.api.allow_destructive" data-key="webserver.api.allow_destructive">
|
||
<label for="webserver.api.allow_destructive"><strong><?= i18n('settings.api.allow_destructive_actions') ?></strong></label>
|
||
<p class="help-block"><?= i18n('settings.api.allow_destructive_help') ?></p>
|
||
</div>
|
||
</div>
|
||
<div class="col-lg-12 pt-3">
|
||
<button type="button" id="button-enable-totp" class="btn btn-success hidden" data-toggle="modal" data-target="#modal-totp"><?= i18n('settings.api.enable_2fa') ?></button>
|
||
<button type="button" id="button-disable-totp" class="btn btn-danger hidden" data-toggle="modal" data-target="#modal-totp-disable"><?= i18n('settings.api.disable_2fa') ?></button>
|
||
<button type="button" id="button-apppw" class="btn btn-default pull-right" data-toggle="modal" data-target="#modal-apppw"><?= i18n('settings.api.configure_app_password') ?></button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="row">
|
||
<div class="col-md-12 settings-level-expert d-none">
|
||
<div class="box box-warning">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title" data-configkeys="webserver.api.excludeDomains webserver.api.excludeClients"><?= i18n('settings.api.exclusions') ?></h3>
|
||
</div>
|
||
<div class="box-body">
|
||
<div class="row">
|
||
<div class="col-md-6">
|
||
<p><strong><?= i18n('settings.api.exclude_domains_title') ?></strong></p>
|
||
<textarea class="form-control field-sizing-content" rows="4" id="webserver.api.excludeDomains" data-key="webserver.api.excludeDomains" placeholder="<?= i18n('settings.api.exclude_domains_placeholder') ?>" style="resize: vertical;"></textarea>
|
||
<p class="help-block"><?= i18n('settings.api.exclude_domains_help') ?></p>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<p><strong><?= i18n('settings.api.exclude_clients_title') ?></strong></p>
|
||
<textarea class="form-control field-sizing-content" rows="4" id="webserver.api.excludeClients" data-key="webserver.api.excludeClients" placeholder="<?= i18n('settings.api.exclude_clients_placeholder') ?>" style="resize: vertical;"></textarea>
|
||
<p class="help-block"><?= i18n('settings.api.exclude_clients_help') ?></p>
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<p><strong><?= i18n('shared.important') ?></strong>:<br><?= i18n('settings.api.regex_info_description') ?></p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- TODO: Why is this commented out?
|
||
<div class="col-md-6">
|
||
<div class="box box-warning">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title">Query Log</h3>
|
||
</div>
|
||
<div class="box-body">
|
||
<div class="row">
|
||
<div class="col-lg-12">
|
||
<div>
|
||
<input type="checkbox" name="querylog-permitted" id="querylog-permitted" <? if queryLog == 'permittedonly' or queryLog == 'all' then ?>checked<? end ?>>
|
||
<label for="querylog-permitted"><strong>Show permitted domain entries</strong></label>
|
||
<p class="help-block"><span class="text-red">This will show all permitted domain entries in the query log.</span></p>
|
||
</div>
|
||
<div>
|
||
<input type="checkbox" name="querylog-blocked" id="querylog-blocked" <? if queryLog == 'blockedonly' or queryLog == 'all' then ?>checked<? end ?>>
|
||
<label for="querylog-blocked"><strong>Show blocked domain entries</strong></label>
|
||
<p class="help-block"><span class="text-red">This will show all blocked domain entries in the query log.</span></p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>-->
|
||
|
||
<div class="col-md-12 settings-level-expert d-none">
|
||
<div class="box box-warning">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title"><?= i18n('settings.api.active_sessions') ?></h3>
|
||
</div>
|
||
<div class="box-body">
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<table id="APISessionsTable" class="table table-striped table-bordered nowrap" width="100%">
|
||
<thead>
|
||
<tr>
|
||
<td></td>
|
||
<th title="<?= i18n('settings.api.id_title') ?>"><?= i18n('shared.id') ?></th>
|
||
<th title="<?= i18n('settings.api.session_valid_title') ?>"><?= i18n('settings.api.session_valid') ?></th>
|
||
<th title="<?= i18n('settings.api.session_tls_title') ?>"><?= i18n('settings.api.session_tls') ?></th>
|
||
<th title="<?= i18n('settings.api.session_app_password_title') ?>"><i class="fas fa-robot"></i></th>
|
||
<th title="<?= i18n('settings.api.session_cli_password_title') ?>"><i class="fas fa-terminal"></i></th>
|
||
<th title="<?= i18n('settings.api.session_login_at_title') ?>"><?= i18n('settings.api.session_login_at') ?></th>
|
||
<th title="<?= i18n('settings.api.session_valid_until_title') ?>"><?= i18n('settings.api.session_valid_until') ?></th>
|
||
<th title="<?= i18n('settings.api.session_client_ip_title') ?>"><?= i18n('settings.api.session_client_ip') ?></th>
|
||
<th title="<?= i18n('settings.api.session_user_agent_title') ?>"><?= i18n('settings.api.session_user_agent') ?></th>
|
||
<td></td>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-lg-12 save-button-container">
|
||
<button type="button" class="btn btn-primary save-button"><i class="fa-solid fa-fw fa-floppy-disk"></i> <?= i18n('settings.save_apply') ?></button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="modal fade" id="modal-totp" style="display: none;">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="<?= i18n('shared.close') ?>">
|
||
<span aria-hidden="true">×</span></button>
|
||
<h4 class="modal-title"><?= i18n('settings.api.enable_two_factor_authentication') ?></h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<p><?= i18n('settings.api.use_authenticator_app_instruction') ?></p>
|
||
<p><?= i18n('settings.api.scan_qr_code_instruction') ?></p>
|
||
<div class="text-center">
|
||
<i id="qrcode-spinner" class="fas fa-spinner fa-pulse fa-5x"></i>
|
||
</div>
|
||
<div class="text-center">
|
||
<canvas id="qrcode" class="qrcode" title="<?= i18n('settings.api.qr_code') ?>" hidden="true"></canvas>
|
||
</div>
|
||
<p class="text-center"><code id="totp_secret"></code></p>
|
||
<p><?= i18n('settings.api.enter_2fa_code_instruction') ?></p>
|
||
<div class="row">
|
||
<div class="col-md-6 col-md-offset-3">
|
||
<div id="totp_div" class="has-feedback has-error">
|
||
<div class="pwd-field form-group">
|
||
<input type="text" size="6" maxlength="6" class="form-control totp_token" id="totp_code" placeholder="">
|
||
</div>
|
||
<i class="fa-solid fa-clock-rotate-left pwd-field form-control-feedback"></i>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<p><?= i18n('settings.api.important_lost_token_warning') ?></p>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?= i18n('shared.close') ?></button>
|
||
<button type="button" id="totp_submit" class="btn btn-default" disabled><?= i18n('settings.api.enable_2fa') ?></button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="modal fade" id="modal-apppw" style="display: none;">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="<?= i18n('shared.close') ?>">
|
||
<span aria-hidden="true">×</span></button>
|
||
<h4 class="modal-title"><?= i18n('settings.api.configure_app_password') ?></h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<p><?= i18n('settings.api.app_password_intro') ?></p>
|
||
<p><?= i18n('settings.api.app_password_description') ?></p>
|
||
<div class="text-center">
|
||
<i id="password-spinner" class="fas fa-spinner fa-pulse fa-5x"></i>
|
||
</div>
|
||
<p id="password_display" class="text-center hidden">🔐<br><strong><?= i18n('settings.api.your_new_app_password_is') ?></strong><br><code class="password_background m-5" id="password_code"></code></p>
|
||
<p><?= i18n('settings.api.important_store_password_warning') ?></p>
|
||
<div class="callout callout-warning" style="display: none;" id="existing_apppw_warning">
|
||
<h4><?= i18n('settings.api.existing_app_password_warning_title') ?></h4><?= i18n('settings.api.existing_app_password_warning_description') ?>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" id="apppw_clear" class="btn btn-danger pull-left"><?= i18n('settings.api.remove_current_app_password') ?></button>
|
||
<button type="button" id="apppw_submit" class="btn btn-success"><?= i18n('settings.api.enable_new_app_password') ?></button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script src="<?=pihole.fileversion('vendor/bootstrap-toggle/bootstrap-toggle.min.js')?>"></script>
|
||
<script src="<?=pihole.fileversion('vendor/jquery-confirm/jquery.confirm.min.js')?>"></script>
|
||
<script src="<?=pihole.fileversion('vendor/qrious/qrious.min.js')?>"></script>
|
||
<script src="<?=pihole.fileversion('scripts/js/settings-api.js')?>"></script>
|
||
<script src="<?=pihole.fileversion('scripts/js/settings.js')?>"></script>
|
||
|
||
<? mg.include('scripts/lua/footer.lp','r')?>
|