Skip to content

Commit

Permalink
Allow admin auth bypass (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
tchapi authored Jan 14, 2024
1 parent 0b0b6f6 commit bf3fc88
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
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

0 comments on commit bf3fc88

Please sign in to comment.