2093 Commits

Author SHA1 Message Date
malve
fc4f6013db correctly emit error message when cancelling an event fails 2025-04-13 14:54:45 -07:00
Andrew Ruthven
8f38332fce Set DAVResource type correctly when restoring from memcache
Assuming we're always dealing with a Principal isn't correct.
2025-01-27 23:27:45 +13:00
Andrew Ruthven
1fec8fd111 Add debug logging for ACE changes 2025-01-27 23:27:45 +13:00
Andrew Ruthven
f6547bd376 Make some lines more readable 2025-01-27 23:27:45 +13:00
Andrew Ruthven
b4bcc6cc25 Fix DAV:current-user-principal for iPhone devices
iPhone devices incorrectly implement DAV:current-user-principal from
RFC 5397. They assume that current-user-principal is the href for the
resource being queried. The RFC says it should be the current resource.

See: https://gitlab.com/davical-project/davical/-/issues/335
2025-01-27 23:27:45 +13:00
Andrew Ruthven
c1cfd8eb0d Fix typo 2025-01-27 23:02:36 +13:00
Andrew Ruthven
734d5c1f99 The public access endpoint is public.php 2025-01-22 14:48:24 +13:00
Andrew Ruthven
11315dee47 Fix deprecation warning for explicit nullable type. 2024-12-30 20:17:22 +13:00
Andrew Ruthven
1077714a83 Make the log lines have consistent prefixes 2024-05-03 23:35:26 +12:00
Andrew Ruthven
af458f9d90 Remove default expiry times, make 0 disabled. 2024-05-03 23:35:26 +12:00
Andrew Ruthven
3c475a283c Switch to using hash_hmac, SHA256 and bcrypt for caching credentials
We also use a locally set password (aka a pepper) to ensure that the contents
of memcached isn't sufficient to perform dictionary attacks on the cached
credentials.
2024-05-03 23:35:26 +12:00
Andrew Ruthven
55feb03139 Include the username in the log messages. 2024-05-03 23:35:26 +12:00
Andrew Ruthven
ee26ee730f get can return the empty string, check for that.
While the credential checks were correctly failing when salt was the
empty string, it was giving confusing i.e., no log messages.
2024-05-03 23:35:26 +12:00
Andrew Ruthven
0b709c791d Fix the storing of cached credentials when an authentication hook is used.
Thank you LDAP tests for picking up this issue!
2024-05-03 23:35:26 +12:00
Andrew Ruthven
5826f5c3cf Cache password credentials received, and if they succeed or fail.
This is intended to reduce the load on external authentication sources
as most (all?) CalDAV clients use HTTPBasicAuth to authenticate and
if an external source is used, every request we receive requires
external authentication. This can place a large load on those external
sources.

Closes #254.
2024-05-03 23:34:42 +12:00
Andrew Ruthven
8f7da93a0d Return the Request ID if auth fails
Still only return it if in test_mode.
2024-05-03 23:33:25 +12:00
Andrew Ruthven
fcbd72e310 Fix an exception if a LDAP group mentions a user that doesn't exist
This tickles a bug as reported by Thorsten Marquardt in
https://sourceforge.net/p/davical/mailman/message/58766531/ with this
error message reported:

    Exception [0] ldap_get_attributes(): Argument #2 ($entry) must be of
    type LDAP\ResultEntry, false given
    At line 718 of /usr/share/davical-master/inc/drivers_ldap.php

You need to look in 3da860e5d5e732c2dedb62a73c76608a2b7098a4 for that line
number as I've just made some improvements to the code the last few commits.
2024-05-01 22:32:33 +12:00
Andrew Ruthven
629789612e Prevent using undefined or non-existant variables 2024-05-01 22:32:33 +12:00
Andrew Ruthven
a50e3eae90 Be a bit more verbose in the logging 2024-05-01 22:32:33 +12:00
Andrew Ruthven
d2a93643bc Don't be afraid of whitespace 2024-05-01 22:32:33 +12:00
Andrew Ruthven
aa35bc6e6d Require the latest DB version 2024-04-30 20:39:14 +12:00
Stonewall Jackson
d3a0c89eca Retain original i_use_mode_kerberos behavior, add fallback option
Add a new value for i_use_mode_kerberos: "allow_fallback_ldap_auth",
which will fallback to username/password authentication when the
REMOTE_USER value is unset.
2024-04-10 14:25:23 -04:00
Stonewall Jackson
0ba94e91de Support fallback to LDAP password with i_use_mode_kerberos
Currently, when `i_use_mode_kerberos` is enabled in the LDAP driver,
Davical checks the `REMOTE_USER` server variable, followed by the
`REDIRECT_REMOTE_USER` variable, for a matching username. If a matching
username is not found, authentication fails immediately.

This commit modifies the LDAP driver to fallback to standard LDAP
password authentication when `i_use_mode_kerberos` is enabled and
neither of these server variables are set. This allows
non-kerberos-enabled clients to authenticate as well.

Fixes #323
2024-04-10 14:25:23 -04:00
Andrew Ruthven
786a9f5591 Remove the IMAP auth drivers
The PHP imap module is being retired. Closes #324.
2024-04-02 21:41:26 +13:00
Andrew Ruthven
7f2cccb94a Use isset when checking that the key exists
To resolve errors like this:

Warning:  Undefined array key "example.net" in /usr/share/davical/inc/iSchedule.php on line 207
2024-04-01 20:46:15 +13:00
Andrew Ruthven
901d82a293 Fix creation of dynamic properties
Add some properties to classes to fix errors like:

Creation of dynamic property iSchedule::$body_cannon is deprecated in /usr/share/davical/inc/iSchedule.php on line 533
Creation of dynamic property FakeSession::$user_active is deprecated in /usr/share/davical/inc/iSchedule-POST.php on line 23
2024-04-01 20:43:45 +13:00
Andrew Ruthven
d2d36399d3 Create the Timezone if we need to
Detected now due to a change from a few years ago to use a clean database
for each set of tests.
2024-04-01 18:34:33 +13:00
Andrew Ruthven
ec9159fd69 Fix some warnings about using undefined keys, simplify dns strings
Fixes:
- PHP Warning:  Trying to access array offset on value of type null in inc/iSchedule.php on line 83
- PHP Warning:  Undefined array key "t" in inc/iSchedule.php on line 165
- PHP Warning:  Undefined array key "t" in inc/iSchedule.php on line 167
- PHP Warning:  Undefined array key "p" in inc/iSchedule.php on line 184

Concatenate the DNS entry we're going to look up once rather than everytime
we need it.
2024-04-01 18:34:33 +13:00
Andrew Ruthven
ba4c1eb989 Skip the "text/calendar" record, so we don't run code that expects "="
Prevents this warning:
  PHP Warning:  Undefined array key 1 in inc/iSchedule-POST.php on line 96
2024-03-30 20:08:14 +13:00
Andrew Ruthven
b26d48fced Put a trailing newline on error messages 2024-03-30 19:03:39 +13:00
Andrew Ruthven
658bd4e786 Use request ID 2024-03-11 00:41:37 +13:00
Andrew Ruthven
f69480ce77 Test that deletion of a principal's items are secure
Test that other users can't delete:
 - collections
 - tickets
 - bindings

No significant change, just return an error message rather than assume that
things worked.
2024-03-10 00:37:11 +13:00
Andrew Ruthven
7e663b3a2b iSchedule should advertise the full date range that we support. 2024-03-04 00:44:12 +13:00
Andrew Ruthven
9c10ef5eb2 Support start or end missing from free-busy-query REPORT
Previously if either start or end were missing then the current time was
used. This would almost never be the expected behaviour.
2024-03-03 21:30:21 +13:00
Andrew Ruthven
88fee9f155 The use of quote_dt_param removes the need to append 'T000000Z'
All tests still pass.
2024-03-01 23:42:54 +13:00
Andrew Ruthven
435133adf5 We need to have dtstart_orig be what is passed in, possibly empty.
Using quote_dt_param resolves the error that Benedikt Spranger was
fixing in 3f326f2d3fcc429d7596a4ff59970217161f7930.
2024-03-01 23:42:54 +13:00
Andrew Ruthven
1c7954fc51 Enforce dates to be send as string (fixes #233)
Prevents AWL/PG from converting them magically.
2024-03-01 23:42:21 +13:00
Benedikt Spranger
15f304ab1c Fix handling of events started before 1900
commit 15d01c8bed2d ("Store DTSTART and DTEND from user in shadow columns")
breaks handling of events started before 1900:

[19-Sep-2023 14:30:39 UTC] davical: BUG: :DAViCal Fatal Error: [42804] SQLSTATE[42804]: Datatype mismatch: 7 ERROR:  column "dtstart_orig" is of type timestamp with time zone but expression is of type integer
[19-Sep-2023 14:30:39 UTC] ================= Stack Trace ===================
[19-Sep-2023 14:30:39 UTC] davical: LOG: :Response status 500 for PUT /<user>/home/6bb3a62b-43ae-4a21-bb83-fca84d9ef050.ics
[19-Sep-2023 14:30:39 UTC] davical: LOG: :***************** Response Header ****************
[19-Sep-2023 14:30:39 UTC] davical: LOG: headers:-->Server: 1.1
[19-Sep-2023 14:30:39 UTC] davical: LOG: headers:-->DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
[19-Sep-2023 14:30:39 UTC] davical: LOG: headers:-->DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
[19-Sep-2023 14:30:39 UTC] davical: LOG: headers:-->X-DAViCal-Version: DAViCal/1.1.12; DB/1.3.5
[19-Sep-2023 14:30:39 UTC] davical: LOG: headers:-->Content-type: text/plain; charset="utf-8"
[19-Sep-2023 14:30:39 UTC] davical: LOG: :******************** Response ********************
[19-Sep-2023 14:30:39 UTC] davical: LOG: response:-->DAViCal Fatal Error

Update dtstart_orig in these cases to avoid the database failure.

Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
2024-03-01 23:26:26 +13:00
Stonewall Jackson
fa44a257e9 allow specifying all sasl bind options in config.php 2024-02-28 16:29:56 -05:00
Stonewall Jackson
c8424ae5d5 Update LDAP driver to support SASL binds
Add a new 'sasl' option to the LDAP driver, which invokes
ldap_sasl_bind() instead of ldap_bind().

This allows authenticating to LDAP using the GSSAPI (kerberos) or
EXTERNAL mechanisms, rather than a bindDN and password.

Note that for GSSAPI binds, PHP needs access to valid kerberos
credentials (for example, by setting the KRB5CCNAME environment variable
for the PHP process).

Tested with OpenLDAP/Heimdal kerberos, but should also work with Active
Directory.
2024-02-28 16:29:56 -05:00
Andrew Ruthven
27ff697d55 Ensure we give bindec a value
Resolves this warning in PHP 7.4.0:

Deprecated: bindec(): Passing null to parameter #1 ($binary_string) of type
string is deprecated in /usr/share/davical/inc/ui/principal-edit.php on line
412
2024-02-29 09:55:23 +13:00
Andrew Ruthven
62441f7705 Ensure we have an array, and there is a value.
Resolves this warning in PHP 8.2:

Warning:  Undefined array key 0 in /usr/share/davical/inc/iSchedule.php on
  line 218
Warning:  Trying to access array offset on null in
  /usr/share/davical/inc/iSchedule.php on line 218
2024-02-29 00:43:50 +13:00
Andrew Ruthven
0a0c0a77cc Explicitly declare all class properties
PHP 8.2.0 has deprecated dynamic creation of properties.

This kind of warning message is displayed:

Deprecated:  Creation of dynamic property DAViCalSession::$login_failed is
  deprecated in /usr/share/awl/inc/Session.php on line 153
2024-02-29 00:43:50 +13:00
Andrew Ruthven
a102105f27 Hide many sections unless the user can modify the principal
There is potential to leak information when viewing the principal
page for another principal. I think it makes more sense to just
not include all of this information unles the user can change the
principal.
2024-02-29 00:43:49 +13:00
Andrew Ruthven
5347680642 Hide change password fields if the user can't change the principal
There is no need to show these fields as they do nothing.
2024-02-29 00:43:49 +13:00
Andrew Ruthven
15e9231ae3 Unescape URLs passed in as external bindings.
Previously PHP was escaping things like ampersands, which then caused
us to have broken URLs.

These aren't displayed anywhere in the UI, so no need to encode them anywhere.

Closes #314.
2024-02-29 00:43:49 +13:00
Stonewall Jackson
3a08e80d5a Fix scope=onelevel in LDAP driver
When `scope` is set to 'onelevel', the LDAP driver actually does a full
subtree search instead.

Should be `ldap_list` instead. Fixed.
2024-02-27 13:32:15 -05:00
Andrew Ruthven
4ae36c132d Have a sensible default setting for the UserAgent 2024-02-18 01:51:56 +13:00
Andrew Ruthven
e989e1cf97 Fix PROPFIND with Depth 1 if external bind is included
Previously something like this would be logged if debugging is enabled:

davical: LOG: Principal: Query: DBGQ: SELECT * FROM collection WHERE user_no= :user_no
davical: LOG: Principal: Query: DBGQ:  ":user_no" => ""
davical: BUG: :DAViCal Fatal Error: [42883] SQLSTATE[42883]: Undefined function: 7 ERROR:  operator does not exist: integer = boolean\nLINE 1: SELECT * FROM collection WHERE user_no= FALSE\n                                              ^\nHINT:  No operator matches the given name and argument types. You might need to add explicit type casts. at /home/puck/work/Calendar/awl/inc/AwlDatabase.php:94

And this would be returned as a response:

DAViCal Fatal Error

user_no doesn't get set when construction the Collection for the external
bind, so, just handle that instead of sending the empty string to the
database as a user_no.

Modify the tests from ccc7e182ba4cbfba66a4fe96e1c0620e46390b95 to tickle the
bug.

Closes #175.
2024-02-18 01:51:56 +13:00
Andrew Ruthven
d7d19b906f Set external_refresh by default
Let's just set a sane default of 60 minutes.
2024-02-18 00:04:37 +13:00