Skip to content

Commit

Permalink
Merge branch 'master' into tchapi/auth-bypass
Browse files Browse the repository at this point in the history
  • Loading branch information
tchapi authored Jan 14, 2024
2 parents ec21ff9 + 0b0b6f6 commit 3d131f1
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ APP_SECRET=630dc0d699fd37e720aff268f75583ed
#TRUSTED_HOSTS='^localhost|example\.com$'
###< symfony/framework-bundle ###

APP_TIMEZONE="Europe/Paris"

###> doctrine/doctrine-bundle ###
DATABASE_DRIVER=mysql # or postgresql, or sqlite
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ You can use an absolute file path here, and you can use Symfony's `%kernel.logs_
LOG_FILE_PATH="%kernel.logs_dir%/%kernel.environment%.log"
```

h. The timezone you want for the app

This must comply with the [official list](https://www.php.net/manual/en/timezones.php)

```
APP_TIMEZONE="Australia/Lord_Howe"
```

> Set a void value like so:
> ```
> APP_TIMEZONE=
> ```
> in your environment file if you wish to use the **actual default timezone of the server**, and not enforcing it.
### Specific environment variables for IMAP and LDAP authentication methods
In case you use the `IMAP` auth type, you must specify the auth url (_the "mailbox" url_) in `IMAP_AUTH_URL`. See https://www.php.net/manual/en/function.imap-open.php for more details.
Expand Down Expand Up @@ -431,6 +445,14 @@ Depending on how you run Davis, logs are either:
>
> It's `./var/log` (relative to the Davis installation), not `/var/log`
### I have a "Bad timezone configuration env var" error on the dashboard
If you see this:
![Bad timezone configuration env var error](_screenshots/bad_timezone_configuration_env_var.png)
It means that the value you set for the `APP_TIMEZONE` env var is not a correct timezone, as per [the official list](https://www.php.net/manual/en/timezones.php). Your timezone has thus not been set and is the server's default (Here, UTC). Adjust the setting accordingly.
### I have a 500 and no tables have been created
You probably forgot to run the migration once to create the necessary DB schema
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
parameters:
default_database_driver: "mysql"
default_admin_auth_bypass: "false"
timezone: '%env(APP_TIMEZONE)%'

services:
# default configuration for services in *this* file
Expand Down
2 changes: 2 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# For the MariaDB container mainly
DB_ROOT_PASSWORD=notSoSecure

TIMEZONE="Europe/Paris"

# The Davis database, user and password
DB_DATABASE=davis
DB_USER=davis_user
Expand Down
3 changes: 0 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ RUN apk --update --virtual build-deps-imap add --no-cache imap-dev openssl-dev k
&& apk del build-deps-imap \
&& rm -rf /tmp/*

# Set timezone correctly
RUN echo 'date.timezone = "Europe/Paris"' > /usr/local/etc/php/conf.d/timezone.ini

# Davis installation
ADD . /var/www/davis
WORKDIR /var/www/davis
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose-postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ services:
- WEBDAV_TMP_DIR=${WEBDAV_TMP_DIR}
- WEBDAV_PUBLIC_DIR=${WEBDAV_PUBLIC_DIR}
- INVITE_FROM_ADDRESS=${INVITE_FROM_ADDRESS}
- APP_TIMEZONE=${TIMEZONE}
depends_on:
- postgresql
volumes:
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ services:
- WEBDAV_TMP_DIR=${WEBDAV_TMP_DIR}
- WEBDAV_PUBLIC_DIR=${WEBDAV_PUBLIC_DIR}
- INVITE_FROM_ADDRESS=${INVITE_FROM_ADDRESS}
- APP_TIMEZONE=${TIMEZONE}
volumes:
- davis_www:/var/www/davis
- davis_data:/data
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ services:
- WEBDAV_TMP_DIR=${WEBDAV_TMP_DIR}
- WEBDAV_PUBLIC_DIR=${WEBDAV_PUBLIC_DIR}
- INVITE_FROM_ADDRESS=${INVITE_FROM_ADDRESS}
- APP_TIMEZONE=${TIMEZONE}
depends_on:
- mysql
volumes:
Expand Down
8 changes: 7 additions & 1 deletion src/Controller/Admin/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ public function dashboard(ManagerRegistry $doctrine)
$events = $doctrine->getRepository(CalendarObject::class)->findAll();
$contacts = $doctrine->getRepository(Card::class)->findAll();

$timezoneParameter = $this->getParameter('timezone');

return $this->render('dashboard.html.twig', [
'users' => $users,
'calendars' => $calendars,
'addressbooks' => $addressbooks,
'events' => $events,
'contacts' => $contacts,
'timezone' => date_default_timezone_get(),
'timezone' => [
'actual_default' => date_default_timezone_get(),
'not_set_in_app' => '' === $timezoneParameter,
'bad_value' => '' !== $timezoneParameter && !in_array($timezoneParameter, \DateTimeZone::listIdentifiers()),
],
'version' => \App\Version::VERSION,
'sabredav_version' => \Sabre\DAV\Version::VERSION,
]);
Expand Down
14 changes: 14 additions & 0 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ class Kernel extends BaseKernel
{
use MicroKernelTrait;

public function boot(): void
{
parent::boot();
$timezone = $this->getContainer()->getParameter('timezone');
if ('' === $timezone) {
return;
}
try {
date_default_timezone_set($timezone);
} catch (\Exception $e) {
// We don't crash the app, the setting will be flagged as incorrect in the dashboard
}
}

protected function configureContainer(ContainerConfigurator $container): void
{
$container->import('../config/{packages}/*.yaml');
Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

final class Version
{
public const VERSION = '4.3.0';
public const VERSION = '4.4.0';
}
7 changes: 5 additions & 2 deletions templates/dashboard.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@
<li class="list-group-item list-group-item-primary">{{ "dashboard.version"|trans }} : <code>{{ version }}</code> (SabreDAV <code>{{ sabredav_version }}</code>)</li>
<li class="list-group-item list-group-item-secondary">{{ "dashboard.auth"|trans }} : <code>{{ authMethod }}</code> ({{ "dashboard.auth_realm"|trans }}: <code>{{ authRealm }}</code>)</li>
<li class="list-group-item list-group-item-secondary">{{ "dashboard.invite_from_address"|trans }} : <code>{{ invite_from_address|default('Not set') }}</code></li>
<li class="list-group-item list-group-item-secondary">{{ "dashboard.server_timezone"|trans }} : <code>{{ timezone }}</code> <a class="small ms-2" target="_blank" href="https://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone">{{ "dashboard.how_to_change_it"|trans }}</a></li>

<li class="list-group-item list-group-item-secondary d-flex justify-content-between align-items-center ">
<span>{{ "dashboard.server_timezone"|trans }} : <code>{{ timezone.actual_default }}</code></span>
{% if timezone.not_set_in_app %}<span class="badge bg-secondary rounded-pill">{{ "dashboard.no_timezone_configuration"|trans }}</span>{% endif %}
{% if timezone.bad_value %}<span class="badge bg-danger rounded-pill">{{ "dashboard.bad_timezone_configuration"|trans }}</span>{% endif %}
</li>
</ul>
</div>

Expand Down
12 changes: 8 additions & 4 deletions translations/messages+intl-icu.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,15 @@
</trans-unit>
<trans-unit id="Ppc629a" resname="dashboard.server_timezone">
<source>dashboard.server_timezone</source>
<target>Server Timezone</target>
<target>App (PHP) Timezone</target>
</trans-unit>
<trans-unit id="vsty3iK" resname="dashboard.how_to_change_it">
<source>dashboard.how_to_change_it</source>
<target>How to change it ?</target>
<trans-unit id="8.dmAfF" resname="dashboard.bad_timezone_configuration">
<source>dashboard.bad_timezone_configuration</source>
<target>Bad timezone configuration env var</target>
</trans-unit>
<trans-unit id="c.1lOsz" resname="dashboard.no_timezone_configuration">
<source>dashboard.no_timezone_configuration</source>
<target>Timezone not enforced by app</target>
</trans-unit>
<trans-unit id="rJf3tq1" resname="dashboard.users">
<source>dashboard.users</source>
Expand Down

0 comments on commit 3d131f1

Please sign in to comment.