mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-05-21 10:50:10 +00:00
Compare commits
2 Commits
enh/noid/p
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ef61ade4d | ||
|
|
3d322e2fe2 |
15
php/public/click-handlers.js
Normal file
15
php/public/click-handlers.js
Normal file
@@ -0,0 +1,15 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.querySelectorAll('input[data-confirm]').forEach((element) => {
|
||||
element.addEventListener('click', (event) => {
|
||||
if (!confirm(element.dataset.confirm)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('[data-stop-event-propagation="true"]').forEach((element) => {
|
||||
element.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -55,6 +55,9 @@ $twig->addExtension(new \AIO\Twig\CsrfExtension($container->get(Guard::class)));
|
||||
// Auth Middleware
|
||||
$app->add(new \AIO\Middleware\AuthMiddleware($container->get(\AIO\Auth\AuthManager::class)));
|
||||
|
||||
// Security Headers Middleware
|
||||
$app->add(new \AIO\Middleware\SecurityHeadersMiddleware());
|
||||
|
||||
// API
|
||||
$app->post('/api/docker/watchtower', AIO\Controller\DockerController::class . ':StartWatchtowerContainer');
|
||||
$app->get('/api/docker/getwatchtower', AIO\Controller\DockerController::class . ':StartWatchtowerContainer');
|
||||
|
||||
@@ -32,4 +32,7 @@ function setThemeIcon(theme) {
|
||||
setThemeToDOM(getSavedTheme());
|
||||
|
||||
// Apply theme when the page loads
|
||||
document.addEventListener('DOMContentLoaded', () => setThemeIcon(getSavedTheme()));
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setThemeIcon(getSavedTheme())
|
||||
document.querySelector('button#theme-toggle')?.addEventListener('click', toggleTheme);
|
||||
});
|
||||
|
||||
23
php/src/Middleware/SecurityHeadersMiddleware.php
Normal file
23
php/src/Middleware/SecurityHeadersMiddleware.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace AIO\Middleware;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
readonly class SecurityHeadersMiddleware {
|
||||
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$response = $handler->handle($request);
|
||||
return $response
|
||||
->withHeader('Content-Security-Policy', "default-src 'self'; base-uri 'self'; worker-src 'none'; object-src 'none'; upgrade-insecure-requests;")
|
||||
->withHeader('X-Content-Type-Options', 'nosniff')
|
||||
->withHeader('X-Frame-Options', 'DENY')
|
||||
->withHeader('X-Permitted-Cross-Domain-Policies', 'none')
|
||||
->withHeader('X-DNS-Prefetch-Control', 'off')
|
||||
->withHeader('Referrer-Policy', 'no-referrer')
|
||||
->withHeader('X-Robots-Tag', 'noindex, nofollow');
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
{# js for optional containers and additional containers forms #}
|
||||
<script type="text/javascript" src="containers-form-submit.js?v7"></script>
|
||||
<script type="text/javascript" src="click-handlers.js?v1"></script>
|
||||
|
||||
{% set hasBackupLocation = borg_backup_host_location or borg_remote_repo %}
|
||||
{% set isAnyRunning = false %}
|
||||
@@ -153,7 +154,7 @@
|
||||
<form method="POST" action="api/docker/backup-check-repair" target="overlay-log">
|
||||
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
|
||||
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
|
||||
<input type="submit" value="Check and repair backup integrity" onclick="return confirm('Check and repair backup integrity? Are you sure that you want to check and repair the backup integrity? This should only be done after reading the mentioned documentation.')"/>
|
||||
<input type="submit" value="Check and repair backup integrity" data-confirm='Check and repair backup integrity? Are you sure that you want to check and repair the backup integrity? This should only be done after reading the mentioned documentation.'/>
|
||||
</form>
|
||||
</details>
|
||||
{% endif %}
|
||||
@@ -178,7 +179,7 @@
|
||||
{% endfor %}
|
||||
</select><br>
|
||||
<input type="checkbox" id="restore-exclude-previews" name="restore-exclude-previews"><label for="restore-exclude-previews">Exclude previews from restore which will speed up the restore process but will trigger a scan of the preview folder as soon as the Nextcloud container starts the next time</label><br>
|
||||
<input type="submit" value="Restore selected backup" onclick="return confirm('⚠️ Important: If the backup that you want to restore contained any community container, you need to restore the same backup a second time after this attempt so that the community container data is also correctly restored.')"/>
|
||||
<input type="submit" value="Restore selected backup" data-confirm='⚠️ Important: If the backup that you want to restore contained any community container, you need to restore the same backup a second time after this attempt so that the community container data is also correctly restored.'/>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% elseif borg_backup_mode == 'restore' %}
|
||||
@@ -366,7 +367,7 @@
|
||||
{% if bypass_container_update == true %}
|
||||
<input type="hidden" name="bypass_container_update" value="true">
|
||||
{% endif %}
|
||||
<input class="button " type="submit" value="Start and update containers" onclick="return confirm('Start and update containers? You should consider creating a backup first.')" />
|
||||
<input class="button " type="submit" value="Start and update containers" data-confirm='Start and update containers? You should consider creating a backup first.' />
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
@@ -413,7 +414,7 @@
|
||||
<form method="POST" action="api/docker/backup-check-repair" target="overlay-log">
|
||||
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
|
||||
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
|
||||
<input type="submit" value="Check and repair backup integrity" onclick="return confirm('Check and repair backup integrity? Are you sure that you want to check and repair the backup integrity? This should only be done after reading the mentioned documentation.')"/>
|
||||
<input type="submit" value="Check and repair backup integrity" data-confirm='Check and repair backup integrity? Are you sure that you want to check and repair the backup integrity? This should only be done after reading the mentioned documentation.'/>
|
||||
</form>
|
||||
</details>
|
||||
{% endif %}
|
||||
@@ -478,7 +479,7 @@
|
||||
<form method="POST" action="api/docker/backup" target="overlay-log">
|
||||
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
|
||||
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
|
||||
<input type="submit" value="Create backup" onclick="return confirm('Create backup? Are you sure that you want to create a backup? This will stop all running containers and create the backup.')" />
|
||||
<input type="submit" value="Create backup" data-confirm='Create backup? Are you sure that you want to create a backup? This will stop all running containers and create the backup.' />
|
||||
</form>
|
||||
|
||||
{% if has_backup_run_once == true %}
|
||||
@@ -490,7 +491,7 @@
|
||||
<form method="POST" action="api/docker/backup-check" target="overlay-log">
|
||||
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
|
||||
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
|
||||
<input type="submit" value="Check backup integrity" onclick="return confirm('Check backup integrity? Are you sure that you want to check the backup? This can take a long time depending on the size of your backup.')" />
|
||||
<input type="submit" value="Check backup integrity" data-confirm='Check backup integrity? Are you sure that you want to check the backup? This can take a long time depending on the size of your backup.' />
|
||||
</form>
|
||||
|
||||
<h3>Backup restore</h3>
|
||||
@@ -503,7 +504,7 @@
|
||||
<option value="{{ restore_time }}">{{ restore_time }} UTC</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="submit" value="Restore selected backup" onclick="return confirm('Restore the selected backup? Are you sure that you want to restore the selected backup? This will stop all running containers and restore the selected backup. It is recommended to create a backup first. You might also want to check the backup integrity.')" />
|
||||
<input type="submit" value="Restore selected backup" data-confirm='Restore the selected backup? Are you sure that you want to restore the selected backup? This will stop all running containers and restore the selected backup. It is recommended to create a backup first. You might also want to check the backup integrity.' />
|
||||
</form>
|
||||
|
||||
<h3>Update backup list</h3>
|
||||
@@ -570,7 +571,7 @@
|
||||
<input type="hidden" name="delete_borg_backup_location_vars" value="yes"/>
|
||||
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
|
||||
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
|
||||
<input type="submit" value="Reset backup location" onclick="return confirm('Are you sure that you want to reset the backup location?')" />
|
||||
<input type="submit" value="Reset backup location" data-confirm='Are you sure that you want to reset the backup location?' />
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if has_backup_run_once == true %}
|
||||
@@ -616,7 +617,7 @@
|
||||
<input type="text" id="timezone" name="timezone" placeholder="Europe/Berlin" />
|
||||
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
|
||||
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
|
||||
<input type="submit" value="Submit timezone" onclick="return confirm('Are you sure that this is a valid timezone? Please double check by following the wikipedia article and checking the correct column. If the timezone is not valid, it will break the startup since the database will not be correctly initialized and you will end up in a startup loop.')" />
|
||||
<input type="submit" value="Submit timezone" data-confirm='Are you sure that this is a valid timezone? Please double check by following the wikipedia article and checking the correct column. If the timezone is not valid, it will break the startup since the database will not be correctly initialized and you will end up in a startup loop.' />
|
||||
</form>
|
||||
<p>You need to make sure that the timezone that you enter is valid. An example is <strong>Europe/Berlin</strong>. You can get valid values by looking at the 'TZ identifier' column of this list: <a target="_blank" href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List"><strong>click here</strong></a>. The default is <strong>Etc/UTC</strong> if nothing is entered.</p>
|
||||
{% else %}
|
||||
|
||||
@@ -37,6 +37,6 @@
|
||||
</p>
|
||||
{% endfor %}
|
||||
|
||||
<input id="community-form-submit" type="submit" value="Save changes" onclick="return confirm('Are you sure that you read the documentation of all community containers that you enabled? If no, please do not continue as this might break your instance!')" />
|
||||
<input id="community-form-submit" type="submit" value="Save changes" data-confirm='Are you sure that you read the documentation of all community containers that you enabled? If no, please do not continue as this might break your instance!' />
|
||||
</form>
|
||||
</details>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<li>Best support for legacy files</li>
|
||||
</ul>
|
||||
{% if isAnyRunning == false %}
|
||||
<a href="https://www.collaboraoffice.com/code/" target="_blank" class="office-learn-more" onclick="event.stopPropagation();">
|
||||
<a href="https://www.collaboraoffice.com/code/" target="_blank" class="office-learn-more" data-stop-event-propagation="true">
|
||||
Learn more
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: middle; margin-left: 4px;">
|
||||
<path d="M6 12L10 8L6 4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
@@ -76,7 +76,7 @@
|
||||
<li>Limited ODF compatibility</li>
|
||||
</ul>
|
||||
{% if isAnyRunning == false %}
|
||||
<a href="https://www.onlyoffice.com/" target="_blank" class="office-learn-more" onclick="event.stopPropagation();">
|
||||
<a href="https://www.onlyoffice.com/" target="_blank" class="office-learn-more" data-stop-event-propagation="true">
|
||||
Learn more
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: middle; margin-left: 4px;">
|
||||
<path d="M6 12L10 8L6 4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="loader"></div>
|
||||
<iframe name="overlay-log" id="overlay-log"></iframe>
|
||||
</div>
|
||||
<button id="theme-toggle" onclick="toggleTheme()">
|
||||
<button id="theme-toggle">
|
||||
<span id="theme-icon"></span>
|
||||
</button>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user