Skip to content

Commit 415e421

Browse files
tchapitchapi
andauthored
Security fixes (#292)
Co-authored-by: tchapi <regbasket@gmail.com>
1 parent 31ea920 commit 415e421

16 files changed

Lines changed: 394 additions & 60 deletions

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ AUTH_REALM=SabreDAV
4949
AUTH_METHOD=Basic
5050

5151
# In case of IMAP Auth, you must specify the url of the mailbox in the following format host[:port].
52-
IMAP_AUTH_URL=null
52+
IMAP_AUTH_URL=
5353
IMAP_ENCRYPTION_METHOD=ssl
5454
IMAP_CERTIFICATE_VALIDATION=true
5555
IMAP_AUTH_USER_AUTOCREATE=false

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"symfony/process": "^7.4",
3232
"symfony/property-access": "^7.4",
3333
"symfony/property-info": "^7.4",
34+
"symfony/rate-limiter": "7.4.*",
3435
"symfony/runtime": "^7.4",
3536
"symfony/security-bundle": "^7.4",
3637
"symfony/serializer": "^7.4",

composer.lock

Lines changed: 75 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/packages/security.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,24 @@ security:
1818
custom_authenticators:
1919
- App\Security\LoginFormAuthenticator
2020
provider: admin_user_provider
21+
login_throttling:
22+
max_attempts: 5
2123
logout:
2224
path: app_logout
2325
target: dashboard
2426
# Without this, any page the admin visits can log them out with a plain GET
2527
enable_csrf: true
2628

2729

30+
# Only the first matching rule applies, so the public endpoints are listed first and the
31+
# admin interface is whatever is left. A route added later is protected unless it is added
32+
# to this list on purpose.
2833
access_control:
2934
- { path: ^/$, roles: PUBLIC_ACCESS }
3035
- { path: ^/dav, roles: PUBLIC_ACCESS }
31-
- { path: ^/dashboard, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
32-
- { path: ^/users, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
33-
- { path: ^/calendars, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
34-
- { path: ^/addressbooks, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
36+
- { path: ^/\.well-known/, roles: PUBLIC_ACCESS }
37+
- { path: ^/login$, roles: PUBLIC_ACCESS }
38+
- { path: ^/logout$, roles: PUBLIC_ACCESS }
3539
- { path: ^/api/v1/health$, roles: PUBLIC_ACCESS }
3640
- { path: ^/api, roles: IS_AUTHENTICATED }
41+
- { path: ^/, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }

config/reference.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@
629629
* }>,
630630
* },
631631
* rate_limiter?: bool|array{ // Rate limiter configuration
632-
* enabled?: bool|Param, // Default: false
632+
* enabled?: bool|Param, // Default: true
633633
* limiters?: array<string, array{ // Default: []
634634
* lock_factory?: scalar|Param|null, // The service ID of the lock factory used by this limiter (or null to disable locking). // Default: "auto"
635635
* cache_pool?: scalar|Param|null, // The cache pool to use for storing the current limiter state. // Default: "cache.rate_limiter"

docker/.env

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# General settings
2-
APP_ENV=prod # or dev
2+
# Either prod or dev
3+
APP_ENV=prod
34

45
CALDAV_ENABLED=true
56
CARDDAV_ENABLED=true
@@ -26,7 +27,8 @@ ADMIN_PASSWORD=admin
2627
ADMIN_AUTH_BYPASS=false
2728

2829
# DAV auth settings
29-
AUTH_METHOD=Basic # Basic or IMAP or LDAP
30+
# Either Basic, IMAP or LDAP
31+
AUTH_METHOD=Basic
3032

3133
# Basic HTTP auth settings
3234
AUTH_REALM=SabreDAV
@@ -42,7 +44,8 @@ LDAP_AUTH_URL=ldap://127.0.0.1:3890
4244
LDAP_DN_PATTERN=uid=%u,ou=users,dc=domain,dc=com
4345
LDAP_MAIL_ATTRIBUTE=mail
4446
LDAP_AUTH_USER_AUTOCREATE=false
45-
LDAP_CERTIFICATE_CHECKING_STRATEGY=try # never, hard, demand, try, or allow
47+
# Either never, hard, demand, try or allow
48+
LDAP_CERTIFICATE_CHECKING_STRATEGY=try
4649

4750
# WebDAV settings
4851
WEBDAV_TMP_DIR=/webdav/tmp

src/Entity/AddressBook.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ class AddressBook
2323
private $principalUri;
2424

2525
#[ORM\Column(name: 'displayname', type: 'string', length: 255, nullable: true)]
26+
#[Assert\Length(max: 255)]
2627
private $displayName;
2728

2829
#[ORM\Column(type: 'string', length: 255)]
2930
#[Assert\Regex("/[0-9a-z\-]+/")]
31+
#[Assert\Length(max: 255)]
3032
private $uri;
3133

3234
#[ORM\Column(type: 'text', nullable: true)]

src/Entity/CalendarInstance.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ public static function getOwnerAccesses(): array
3737
private $access;
3838

3939
#[ORM\Column(name: 'displayname', type: 'string', length: 255, nullable: true)]
40+
#[Assert\Length(max: 255)]
4041
private $displayName;
4142

4243
#[ORM\Column(type: 'string', length: 255, nullable: true)]
4344
#[Assert\Regex("/[0-9a-z\-]+/")]
45+
#[Assert\Length(max: 255)]
4446
private $uri;
4547

4648
#[ORM\Column(type: 'text', nullable: true)]
@@ -51,6 +53,7 @@ public static function getOwnerAccesses(): array
5153

5254
#[ORM\Column(name: 'calendarcolor', type: 'string', length: 10, nullable: true)]
5355
#[Assert\Regex("/\#[0-9A-F]{6}/")]
56+
#[Assert\Length(max: 10)]
5457
private $calendarColor;
5558

5659
#[ORM\Column(type: 'text', nullable: true)]

src/Entity/CalendarObject.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,6 @@ public function setCalendar(?Calendar $calendar): self
8888
return $this;
8989
}
9090

91-
public function getLastModifier(): ?int
92-
{
93-
return $this->lastModifier;
94-
}
95-
96-
public function setLastModifier(?int $lastModifier): self
97-
{
98-
$this->lastModifier = $lastModifier;
99-
100-
return $this;
101-
}
102-
10391
public function getEtag(): ?string
10492
{
10593
return $this->etag;

src/Entity/Principal.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ class Principal
2424
private $id;
2525

2626
#[ORM\Column(type: 'string', length: 255, unique: true)]
27-
#[Assert\Unique]
2827
#[Assert\NotBlank]
28+
#[Assert\Length(max: 255)]
2929
private $uri;
3030

3131
#[ORM\Column(type: 'string', length: 255, nullable: true)]
3232
#[Assert\NotBlank]
3333
#[Assert\Email(message: "The email '{{ value }}' is not a valid email.")]
34+
#[Assert\Length(max: 255)]
3435
private $email;
3536

3637
#[ORM\Column(name: 'displayname', type: 'string', length: 255, nullable: true)]
38+
#[Assert\Length(max: 255)]
3739
private $displayName;
3840

3941
#[ORM\Column(type: 'boolean')]
40-
#[Assert\NotBlank]
4142
private $isMain;
4243

4344
#[ORM\Column(type: 'boolean')]
44-
#[Assert\NotBlank]
4545
private $isAdmin;
4646

4747
#[ORM\ManyToMany(targetEntity: 'Principal')]

0 commit comments

Comments
 (0)