Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow admin auth bypass #130

Merged
merged 5 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ MAILER_DSN=smtp://localhost:465?encryption=ssl&auth_mode=login&username=&passwor
# The admin password for the backend
ADMIN_LOGIN=admin
ADMIN_PASSWORD=test
# You can bypass auth entirely by setting this to "true" (case sensitive).
# Useful if you use an external authorization provider such as Authelia
ADMIN_AUTH_BYPASS=false

# Auth Realm for HTTP auth
AUTH_REALM=SabreDAV
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ ADMIN_LOGIN=admin
ADMIN_PASSWORD=test
```

> [!NOTE]
>
> You can bypass auth entirely if you use a third party authorization provider such as Authelia. In that case, set the `ADMIN_AUTH_BYPASS` env var to `true` (case-sensitive, this is actually the string `true`, not a boolean) to allow full access to the dashboard. This does not change the behaviour of the DAV server.

c. The auth Realm and method for HTTP auth

```
Expand Down
8 changes: 4 additions & 4 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ security:
access_control:
- { path: ^/$, roles: PUBLIC_ACCESS }
- { path: ^/dav, roles: PUBLIC_ACCESS }
- { path: ^/dashboard, roles: ROLE_ADMIN }
- { path: ^/users, roles: ROLE_ADMIN }
- { path: ^/calendars, roles: ROLE_ADMIN }
- { path: ^/adressbooks, roles: ROLE_ADMIN }
- { path: ^/dashboard, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
- { path: ^/users, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
- { path: ^/calendars, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
- { path: ^/adressbooks, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
default_database_driver: "mysql"
default_admin_auth_bypass: "false"
timezone: '%env(APP_TIMEZONE)%'

services:
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/DashboardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testLoginIncorrectUsername(): void
$crawler = $client->followRedirect();
$this->assertResponseIsSuccessful();

$this->assertSelectorTextContains('div.alert.alert-danger', 'Username could not be found.');
$this->assertSelectorTextContains('div.alert.alert-danger', 'Invalid credentials.');
}

public function testLoginIncorrectPassword(): void
Expand Down
2 changes: 1 addition & 1 deletion translations/security.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</trans-unit>
<trans-unit id="z3cOUZo" resname="Username could not be found.">
<source>Username could not be found.</source>
<target>Username could not be found.</target>
<target>Invalid credentials.</target>
</trans-unit>
<trans-unit id="By5eLYM" resname="Account has expired.">
<source>Account has expired.</source>
Expand Down