2059 Commits

Author SHA1 Message Date
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
Andrew Ruthven
eb4d120bbf Honour do_not_sync_from_ldap when sync'ing group members
This had been working as a side effect of the way the SQL insert
statement was working, but better to be explict about skipping them.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
8a6274e6cf Rather than look for a flag, if a member is a DN, modify/fetch the record.
This changes 48c6512a70740c403027b66e9d609e9b871d29c0, in Eric's commit it
needs a flag to go fetch the record and apply the mapping to find the
username field. This approach looks for a telltale that this is DN (naively
an "=") and then either grabs the first element from the DN if the username
attr matches or fetches the entry from LDAP.

There have also been attempts in the past to special case uniqueMember and
to add a group_member_dnfix config option.

This should handle the cases where people use uid/cn/whatever for the
username.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
03d0e66b39 Handle there being no one in the group in the database 2024-02-17 02:25:25 +00:00
Andrew Ruthven
ef6bd9a7e9 fullname is a better default than group 2024-02-17 02:25:25 +00:00
Andrew Ruthven
98d9925241 Always update groups from LDAP
The logic actually handled updated group details, but only new groups were
being passed in. This will cause changes to what is being used for the
fullname to flow through.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
b77b2640f8 The displayname can be unset, test for that 2024-02-17 02:25:25 +00:00
Andrew Ruthven
cb287c5abf Use filterUsers from the config 2024-02-17 02:25:25 +00:00
Andrew Ruthven
56d7d22d86 Rename mapping_field to user_mapping_field
This is to be consistent with group_mapping_field. The code is backwards
compatible with mapping_field.

In sync_LDAP_groups assign user_mapping once, not for every group.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
3d28433b5b Fix the comments 2024-02-17 02:25:25 +00:00
Andrew Ruthven
9d40ae1aa7 Simplify the code by assigning the array after we've cleaned it up.
This allows shorter lines which means easier to understand code.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
2a30a9646c Have some sane defaults for LDAP group mappings 2024-02-17 02:25:25 +00:00
Andrew Ruthven
13083b07e8 Rename username to name in group mappings, drop unused fullname from example
Usinger "username" for the group name is confusing and misleading. Just
use name, but support our users who still have username.

We don't use fullname, drop it from the example.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
bb713137fd memberUid is deprecated, make member default 2024-02-17 02:25:25 +00:00
Andrew Ruthven
a7fc46a848 Add whitespace to sync_LDAP_groups
Make the function more readable.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
dc2991666a Allow the LDAP group to have no members 2024-02-17 02:25:25 +00:00
Andrew Ruthven
3846d31664 Handle there being no group members in the DB 2024-02-17 02:25:25 +00:00
Andrew Ruthven
1db3663302 We're using a baseDN, not querying a DN 2024-02-17 02:25:25 +00:00
Andrew Ruthven
775ecb8f3b Ensure that users_nothing_done is created as an array
This is likely only going to generate an error on the first time you
sync from LDAP, but still, let's not spit an unncessary error out.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
ed7f308b87 Add default filters for users and groups
Some (all?) LDAP servers will just not respond if there is no filter,
provide a sensible default.
2024-02-17 02:25:25 +00:00
Andrew Ruthven
702fc05b57 Bail out early to prevent bogus errors if baseDNGroups isn't set 2024-02-17 02:25:25 +00:00
Andrew Ruthven
e73f2d73d4 Better handle when we can't talk to the server, log that 2024-02-17 02:25:25 +00:00
Andrew Ruthven
15e5a89675 Log better information about the connection to the server 2024-02-17 02:25:25 +00:00
Eric Wagner
016e51b4ac use username attr for matching group members 2024-02-17 02:25:25 +00:00
Andrew Ruthven
c75e7aee29 If curl is missing, complain, loudly
As requested on #175,
2024-02-04 01:40:08 +13:00
Andrew Ruthven
1ca8284bdc Add ROOM as a principal type
This hopefully resolves #282.
2024-01-21 19:12:42 +13:00
Andrew Ruthven
39d0cd5837 Don't change passwords to $pwstars
The password input boxes are supposed to contain the value of $pwstars,
not the string '$pwstars'.
2024-01-21 13:34:30 +13:00
Andrew Ruthven
dabe01657d Bump the AWL version here as well 2024-01-20 15:27:51 +13:00
Andrew Ruthven
d42c3dc186 Add PHP version check to setup.php 2024-01-20 15:27:51 +13:00
Andrew Ruthven
3bf44378fa Fix checking if the session is active
The phpversion check was backwards. For PHP >= 5.4.0 we should be
using session_status() === PHP_SESSION_ACTIVE not < 5.4.0.

But in fact, we only support >= 5.4.0, so this check is now redundant.
2024-01-20 02:21:40 +00:00
Chris S
069445579c Fix conversion to UTC for DST changes
The RepeatRuleDateTime constructor extracts the date's time zone then
passes it to the parent class DateTime. Because PHP's DateTime has full
support for time zones, it compensates for them when parsing a string.
Normally this isn't a problem, because the opposite occurs when a
DateTime is converted back into a string; the two adjustments cancel
each other.

Davical often converts a time to UTC by negating the time zone offset
and adding it to the underlying DateTime (keeping the time zone intact).
A problem occurs when the result is on the other side of a daylight-
saving-time transition. In that case the adjustments do not cancel and
an incorrect time string is returned.

This bug is tricky because the problem doesn't manifest during the DST
transition iself, but hours earlier or later depending on the original
time zone. For example, 2022-03-12T18:30:00-08:00 (America/Los_Angeles)
is 2022-03-13T02:30:00Z. Since 2022-03-13 is a 23-hour day in the Los
Angeles time zone (the 2AM-3AM hour is skipped) this becomes
2022-03-13T03:30:00-07:00 after adding the negated offset. FloatOrUTC()
would strip the new offset and simply return "20220313T033000".
2024-01-19 19:13:07 +13:00
eppesuig
de29c6c6ee Better check for $_SERVER['PATH_INFO'] 2023-06-21 23:21:57 +00:00
Andrew Ruthven
ea2a75d86b Confidential resources should retain more reccurence information
To allow for correct expansion of recurring confidential information
we also need to retain EXDATE, RECURRENCE-ID and SEQUENCE, otherwise
client side expansion may well be wrong.

Closes #291
2023-05-02 10:44:52 +00:00
Andrew Ruthven
e8f3a3e6f2 Add a missing space to a SQL statement to fix adding groups.
It looks to me like this bug has been present since 2011.

Closes: #294
2023-04-30 12:13:37 +12:00
Scott Savarese
0059d0dcdb Support ldap connections via URI to handle ldaps and redundant ldap servers 2023-04-27 11:00:50 +00:00