Commit Graph

1303 Commits (e2ea6d46802255cd1dcdedf0c0d5aeabdcaf283d)

Author SHA1 Message Date
Anna Larch 5d5134e615 Do not log passwords in debug mode
Signed-off-by: Anna Larch <anna@nextcloud.com>
2023-08-24 10:39:27 +07:00
Aaron Dewes 16908999ed Simplify escapeFilterPart
Signed-off-by: Aaron Dewes <aaron.dewes@protonmail.com>
2023-08-13 15:43:04 +07:00
Aaron Dewes 13d9494af3 Escape some more values
Signed-off-by: Aaron Dewes <aaron.dewes@protonmail.com>
2023-08-13 15:43:04 +07:00
AaronDewes c42d9d439a Fix: Escape group names for LDAP
Groups may contain special characters (Like "(" or ")") that should be escaped to ensure geenrted queries are correct.

Signed-off-by: AaronDewes <aaron.dewes@protonmail.com>
2023-08-13 15:43:04 +07:00
Côme Chilliet a0808111b4
Add unique index for user_ldap group memberships
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:37 +07:00
Côme Chilliet b8a0954f55
Fix check-group --update for deleted groups
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:37 +07:00
Côme Chilliet 5425f7d3bd
Use BIGINT for new table id field
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:36 +07:00
Côme Chilliet 7732de75ee
Removed GroupCreatedEvent/GroupDeletedEvent from UpdateGroupsService
This should be handled when mapping groups, not when registering their
 members. An empty group may still exist.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:36 +07:00
Côme Chilliet ad1e487f67
Dispatch UserRemovedEvents for removed groups
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:35 +07:00
Côme Chilliet c33c40f677
[user_ldap] Small perf improvements suggestion from review
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:35 +07:00
Côme Chilliet 1026b2131c
Fix check-group command for new groups
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:34 +07:00
Côme Chilliet 42448c0d78
Fix getKnownGroups return value
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:34 +07:00
Côme Chilliet 7a14aa748e
Add output to check-group --update command
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:34 +07:00
Côme Chilliet ce5a4e5b66
Always empty cache before updating a group
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:34 +07:00
Côme Chilliet 1b102ca9b3
Fix errors in UpdateGroupsService.php
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:33 +07:00
Côme Chilliet ec13f22ae3
Add missing primary key for ldap_group_membership
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:33 +07:00
Côme Chilliet f9ed48eab9
Add check-group command
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:33 +07:00
Côme Chilliet 2c19aac9e1
Move UpdateGroups methods to a service
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:33 +07:00
Côme Chilliet 34fa4138fb
Add group events to UpdateGroups
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:32 +07:00
Côme Chilliet d8142b6a5a
Refactor user_ldap group membership to use flat DB
Move away from serialized arrays. Also use a QBMapper class for the new table.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-08-10 10:57:25 +07:00
Côme Chilliet b155f87a84
Merge pull request #39058 from nextcloud/fix/fix-ldap-filters-for-empty-search
Avoid adding (attribute=) part to filter which will confuse LDAP servers
2023-08-08 09:21:20 +07:00
jld3103 61a13bed4d
user_ldap: Add OpenAPI spec
Signed-off-by: jld3103 <jld3103yt@gmail.com>
2023-07-31 12:17:42 +07:00
Joas Schilling 77bc6c32d8
fix(dispatcher): Move remaining simple cases in apps/ folder to IEventDispatcher
Signed-off-by: Joas Schilling <coding@schilljs.com>
2023-07-25 11:19:26 +07:00
Arthur Schiwon 4054a7ddc8
fix(LDAP): add return type hint and description
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-07-07 10:46:00 +07:00
Arthur Schiwon 92a082d823
fix(ldap): avatar is not being fetched
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-07-05 17:13:43 +07:00
Côme Chilliet b2f01b72fe
Merge pull request #34443 from nextcloud/feat/add-enabled-user-backend
Add IProvideEnabledStateBackend interface
2023-07-03 10:19:32 +07:00
Côme Chilliet 189ccc2d72
Add method to list disabled users to IProvideEnabledStateBackend
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-06-29 16:15:12 +07:00
Côme Chilliet 4a0351878c
Avoid adding (attribute=) part to filter which will confuse LDAP servers
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-06-29 10:42:59 +07:00
Arthur Schiwon 2e81a1d839
Merge pull request #38457 from nextcloud/fix/improve-ldap-offset-search-perf
Use default page size for jumping to desired offset
2023-06-22 21:46:03 +07:00
Côme Chilliet b980722e89
Fix paged search when offset is not a multiple of default page size
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-06-20 16:13:59 +07:00
Côme Chilliet 1603cdc8d2
Fix since annotations and add boolean return type for setUserEnabled
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-06-20 15:10:39 +07:00
Faraz Samapoor b0938b9083 Refactors "strpos" calls in /apps/user_ldap to improve code readability.
Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
2023-06-02 15:26:55 +07:00
Côme Chilliet add59d2309
Use DI for DeletedUsersIndex and fix tests
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-05-25 12:18:28 +07:00
Côme Chilliet b186cffdbe
Use default page size for jumping to desired offset
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-05-25 11:31:29 +07:00
Côme Chilliet 50ccfb4f5b
[user_ldap] Add per-connection setting for marking remnants as disabled
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-05-23 16:03:17 +07:00
Côme Chilliet 684a81e4bd
Use the new IProvideEnabledStateBackend interface in user_ldap
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-05-23 11:25:22 +07:00
Côme Chilliet c995428431
Merge pull request #37903 from nextcloud/fix/user_ldap-fix-multiple-ldap-support
Fix multiple LDAP configuration support by fixing AccessFactory
2023-05-02 17:11:01 +07:00
Côme Chilliet b6c17c6ce7
Clear up return types
usersInGroup index by int for BC, searchInGroup index by uid (string).

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-04-27 12:00:45 +07:00
Côme Chilliet 6385a5af36
Let OC\Group\Group handle the fallback and remove default implementation from ABackend
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-04-27 12:00:43 +07:00
Carl Schwan 35dc223500
Optimize retrieving display name when searching for users in a group
This is recurrent scenario that we are searching for users and then for
each users we fetch the displayName. This is inefficient, so instead try
to do one query to fetch everything (e.g. Database backend) or use the
already existing DisplayNameCache helper.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2023-04-27 11:57:45 +07:00
Côme Chilliet 967955358c
Add comment about Manager instance not being shared
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-04-27 11:21:53 +07:00
Daniel 2abefff289
Merge pull request #36784 from nextcloud/fix/user_ldap-update-groups-fail-get
Properly test and log when a group is not found
2023-04-24 16:26:30 +07:00
Côme Chilliet 429db14a00
Fix multiple LDAP configuration support by fixing AccessFactory
It must not reuse the same OCA\User_LDAP\User\Manager instance for
 several Access instances.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-04-24 16:03:40 +07:00
Marc Hefter 621c6c3c56
code styling
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Marc Hefter <marchefter@march42.net>
2023-04-24 10:21:45 +07:00
Marc Hefter aa210365ec
Update apps/user_ldap/lib/User/User.php
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Marc Hefter <marchefter@march42.net>
2023-04-24 10:14:17 +07:00
Marc Hefter e83520617d
removed profile data from LDAP will get removed
If attribute mapping is configured and no value present in LDAP, the
according profile field is emptied. Removing an attribute e.g. phone
from LDAP will cause the phone number being removed from profile.

Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-21 10:35:44 +07:00
Simon L 93966e99c1
Merge pull request #36565 from march42/feature/ldap_update_profile
[user_ldap] Update profile from LDAP fields
2023-04-20 11:23:24 +07:00
Marc Hefter 64914593a0
optimized handling of user profile data change
Check profile data checksum before updating user profile, to ensure
data has changed. Write checksum to user settings and cache.

Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-14 11:08:46 +07:00
Julien Veyssier f3cd559c54 perform exact Ldap search as well to make sure it works for attributes without a substr matching rule
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
2023-04-13 19:59:17 +07:00
Marc Hefter eec5e702da
error handling in update profile from LDAP
added error message on InvalidArgumentException

Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-11 16:40:00 +07:00
Marc Hefter ebb0c53f9e
trying to make github-code-scanning bot happy
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:31 +07:00
Marc Hefter 72d0a3f26e
added simple data conversion for LDAP attributes
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:31 +07:00
Marc Hefter 1e7bc93ec8
handling, formatting of postalAddress attribute syntax
replace '$' with ', ' delimiter for address property
reformatted some code to 80 column
early check and return, if wasRefreshed('profile')
removed FIXMEs after digging and double checking

Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:30 +07:00
Marc Hefter 5ea46d81bb
nice up the code handling AccountManager
merging defaultScopes from DEFAULT_SCOPES and account_manager.default_property_scope
removing unneccessary profileScope setting (using config.php instead)
honoring admin choice 'profile.enabled'=>false in config.php
moved checking for empty array to updateProfile function
corrected some typos and cleaned some comments

Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:30 +07:00
Marc Hefter dd2bd6a925
refined code, to be independend from OCP\IUser
rework updateProfile in user_ldap/lib/User/User.php
some cleanup at processAttributes in user_ldap/lib/User/User.php
rearranged Fediverse attribute, to match profile layout

Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:29 +07:00
Marc Hefter c6408587ed
fixing Psalm messages
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:28 +07:00
Marc Hefter f812b87576
handling updateProfile with array of values
using an array to buffer profile updates, like suggested by @come-nc
clean some code and remove unneccessary redundancy
added the Fediverse profile property

Co-Authored-By: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:28 +07:00
Marc Hefter 5c4a05cfd6
CleanUp: removed redundant storing profile attributes in user settings
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:27 +07:00
Marc Hefter 3020290751
CleanUp: removed redundant condition if block
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:27 +07:00
Marc Hefter 2f76b7a3d5
CleanUp: tidy checking for empty profileScope
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:26 +07:00
Marc Hefter 44065c0fea
Fix: Parameter $scope has no provided type
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Marc Hefter <marchefter@march42.net>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:25 +07:00
Marc Hefter 26aa1c3580
CleanUp: remove unneeded UNSET, to unclutter code
Signed-off-by: march42 <marchefter@gmail.com>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:25 +07:00
Marc Hefter 240c57b94b
cleanup: removed unnecessary imports of IAccountManager, AccountManager, IDBConnection
Signed-off-by: Marc Hefter <marchefter@march42.net>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:24 +07:00
Marc Hefter b72fbd58f6
fixed error: Array to string conversion at user_ldap/lib/User/User.php#639
Signed-off-by: Marc Hefter <marchefter@march42.net>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:23 +07:00
Marc Hefter c7623c7869
bugfix: changed forgotten userName, to getUsername
Signed-off-by: Marc Hefter <marchefter@march42.net>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:22 +07:00
Marc Hefter eee0275dc5
added user profile scope setting
Signed-off-by: Marc Hefter <marchefter@march42.net>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:22 +07:00
Marc Hefter 2315c17726
feature addition: [user_ldap] update user profile from LDAP
Signed-off-by: Marc Hefter <marchefter@march42.net>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:21 +07:00
Marc Hefter 7fa3c674de
feature addition: [user_ldap] update user profile from LDAP; WIP; fixing some uggly copy-and-paste errors; testing functionality; preparing and editing the documentation
Signed-off-by: Marc Hefter <marchefter@march42.net>
Signed-off-by: Marc Hefter <marchefter@gmail.com>
2023-04-06 08:20:20 +07:00
Marc Hefter 404d26aa4a
feature addition: [user_ldap] update user profile from LDAP; WIP work-in-progress; TODO update profile
Signed-off-by: Marc Hefter <marchefter@march42.net>
2023-04-06 08:19:39 +07:00
Arthur Schiwon bd0f374cfd
Merge pull request #37575 from nextcloud/fix/user_ldap-log-suffix-names
Log a warning when a user or group is mapped with a suffix
2023-04-05 10:28:23 +07:00
jld3103 d9f8522003
Fix types for reading and writing config values
Signed-off-by: jld3103 <jld3103yt@gmail.com>
2023-04-05 09:08:56 +07:00
Côme Chilliet 51705da7a4
Log a warning when a user or group is mapped with a suffix
Most of the time, this is the result of a misconfiguration by the admin
 and is not what is expected.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-04-04 14:08:24 +07:00
Arthur Schiwon 17afaa488f
fix undefined method getExtStorageHome()
- adds a type check
- defines missing method in OfflineUser

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2023-03-22 13:54:27 +07:00
Arthur Schiwon 8f59ff880f
Merge pull request #37006 from nextcloud/ldap-unmark-dh
also unmark deleted ldap user when checking the ldap entry
2023-03-20 16:15:03 +07:00
Côme Chilliet d82d6df646
Do not send a pagination control with size = 0 if cookie is empty
It only makes sense to send a pagination control with size 0 with a
 cookie to abandon a paged search.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-03-13 16:05:41 +07:00
Robin Appelman 3a9597fd1b
also unmark deleted ldap user when checking the ldap entry
Signed-off-by: Robin Appelman <robin@icewind.nl>
2023-03-02 16:22:17 +07:00
Côme Chilliet 0186194ae9
Properly test and log when a group is not found
Avoid an error about passing null instead of IGroup to the event
 constructor, instead skip the failed group and log the problem.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-02-20 17:34:53 +07:00
Côme Chilliet 3c0b1bdc30
Remove redundant cast to string in user_ldap
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-01-02 15:11:13 +07:00
Côme Chilliet a372564850
Fix psalm spotted errors with new requirements
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-01-02 15:02:28 +07:00
Vincent Petry 13d5426893
Merge pull request #35839 from nextcloud/feat/user_ldap-longer-ttl-for-fallback
Apply a longer TTL of 15min to falling back on backup server
2022-12-20 17:19:56 +07:00
Côme Chilliet f6ff717b56
Merge pull request #34772 from nextcloud/fix/clean-ldap-access-factory-usage
Make sure to use AccessFactory to create Access instances and use DI
2022-12-20 16:48:07 +07:00
Côme Chilliet 1ac2c74830
Apply a longer TTL of 15min to falling back on backup server
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-12-20 12:01:25 +07:00
Côme Chilliet 6b7ffcd6a8
Fixed backup host logic
Now forcing backup host applies to both main and background.
And background will fallback to backup if not responding.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-12-19 14:15:48 +07:00
Côme Chilliet 406750552e
Make code clearer for background host
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-12-19 14:15:48 +07:00
Côme Chilliet 4758bdc476
Use a dedicated LDAP host and port for background jobs if configured
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-12-19 14:15:46 +07:00
Côme Chilliet 75e369d306
Merge pull request #35231 from nextcloud/fix/user_ldap-cache-fetched-list-of-groups
Cache the fetched list of groups
2022-12-19 12:34:05 +07:00
Côme Chilliet f7cd7047a2
Merge pull request #24574 from zenlord/ldapi-unix-socket-support
Ldapi unix socket support
2022-12-08 17:25:00 +07:00
Côme Chilliet a0f6a6545b
Use TimedJob from OCP instead of OC
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-12-05 10:13:34 +07:00
blizzz b16c9838c6
Merge pull request #35355 from nextcloud/artonge/feat/ldap_connection_timeout
Allow to set a custom timeout for ldap connections
2022-11-30 14:44:15 +07:00
Côme Chilliet e00740ea38
Merge pull request #35230 from nextcloud/fix/user_ldap-log-backup-switch
Log switching to LDAP backup host because main one is not available
2022-11-24 18:20:36 +07:00
Louis Chemineau a781ae3afb Allow to set a custom timeout for ldap connections
Signed-off-by: Louis Chemineau <louis@chmn.me>
2022-11-23 11:37:49 +07:00
Côme Chilliet 90165309e1
Improve a bit codestyle
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-11-22 16:57:24 +07:00
Côme Chilliet 911967867f
Merge branch 'master' into ldapi-unix-socket-support
Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
2022-11-22 16:47:42 +07:00
Côme Chilliet 341dda1de6
Merge branch 'master' into fix/clean-ldap-access-factory-usage
Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
2022-11-21 16:05:17 +07:00
Côme Chilliet 4893501abe
Log as warning instead of info when main LDAP server is unreachable
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-11-21 10:31:24 +07:00
Côme Chilliet 9e1dd52c99
Cache the fetched list of groups
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-11-17 15:12:24 +07:00
Côme Chilliet 3e15ea6cd0
Log switching to LDAP backup host because main one is not available
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-11-17 14:58:44 +07:00
Côme Chilliet 1d00290621
Cache display name even if it was not filled
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-11-17 14:47:00 +07:00
Arthur Schiwon e6e18b4008
[LDAP] always create instance of own user manager
- it is config specific and cannot be shared
- because the Access instance is bound later, it is not obvious from the
  constructor

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-11-10 10:32:01 +07:00
Vincent Petry a736a2b03b
Merge pull request #34702 from nextcloud/fix/clean-ldap-wizard-typing
Clean up LDAP Wizard typing
2022-11-04 17:29:30 +07:00
Carl Schwan 4344a54a1d
Merge pull request #34691 from nextcloud/profiler/ldap-backtrace
Add backtrace to ldap profiler collector
2022-10-25 17:00:23 +07:00
Côme Chilliet 556e3c84e6
Fix return type for countUsers method
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-25 10:20:09 +07:00
Côme Chilliet 5242a78994
Fix $host var handling to avoid passing null to ldap_connect
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-25 09:59:56 +07:00
Côme Chilliet 4130a4cbd8
Make sure to use AccessFactory to create Access instances and use DI
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-25 09:52:35 +07:00
Côme Chilliet 142f9913a6
Expose mapped user count from LDAP and use that for user limit check
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-24 16:54:41 +07:00
Simon L 47da08fe85
Merge pull request #33945 from nextcloud/fix/noid/fair-use-ldap
LDAP to not register new users when outside of fair use or over limits
2022-10-21 18:53:16 +07:00
Carl Schwan 25519b7089 Add backtrace to ldap profiler collector
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 16:55:44 +07:00
Côme Chilliet 3dedfd34b9
Clean up LDAP Wizard typing
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 16:51:39 +07:00
Côme Chilliet 00c4c3d723
Merge pull request #30223 from nextcloud/nested_ldap_groups
Nested ldap groups
2022-10-20 15:03:37 +07:00
Carl Schwan 99a752922f Fix psalm
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 13:14:39 +07:00
Carl Schwan 60ec5e655c Check if cache is present with isset
Otherwise we get false for empty array

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 13:14:39 +07:00
Côme Chilliet 1a6a6c985a Bring back small fixes by Carl
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 13:14:39 +07:00
Côme Chilliet 746a5fb7e0 Fix LDAP recursive nested group support
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 13:14:39 +07:00
Carl Schwan be5338e572 Revert Carl changes on apps/user_ldap/lib/Group_LDAP.php
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 13:14:31 +07:00
Côme Chilliet 8d07bc9b20
Cleanup typing and improve logging
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:56:17 +07:00
Côme Chilliet 81064b3d22
Fix ldap_parse_result call
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:56:17 +07:00
Côme Chilliet e872f461f2
Adapt interface to new search signature
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:56:16 +07:00
Côme Chilliet 50a52ac2a5
Pass paging information directly to search and get rid of adapter
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:56:16 +07:00
Côme Chilliet 14804d9677
Renamed ambiguous $limit parameter to pageSize
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:56:16 +07:00
Côme Chilliet d10dfa84db
Unfold call to ldap_parse_result. Handle cookie outside of adapter.
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:56:15 +07:00
Côme Chilliet 3c9b1c5296
Do not init a paged search for read operations
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:56:15 +07:00
Côme Chilliet d6e49cd2de
Remove useless getReadArgs/setReadArgs methods from PagedResults
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:56:15 +07:00
Côme Chilliet d790d45567
Remove dead code in paged result handling
There is only one paged result API now that PHP 7.2 is long dead.
Starting by removing empty function calls.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:56:14 +07:00
Carl Schwan 1b12a08ec2 Fix user_ldap tests
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 12:09:06 +07:00
Carl Schwan e0fbd39840 Add back runtime cache for intermediate ldap read results
This is a small optimization that save a few LDAP queries

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 12:09:06 +07:00
Carl Schwan 33be3f754a Only cache base inGroup search
And not intermediate search for nested groups, this is causing issues
othewise with nested groups

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 12:09:06 +07:00
Côme Chilliet 604b5ace12 Add missing copyright author in Group_LDAP
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:09:06 +07:00
Côme Chilliet 69f9e9f387 Removed unused use declaration
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:09:06 +07:00
Côme Chilliet 150e6adbc5 Fix types in docblocks
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:09:06 +07:00
Côme Chilliet 6ed0d0b8b1 Refactor group membership listing for nested groups
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:09:06 +07:00
Côme Chilliet 8b19cfcd88 Small optimisation of _groupMembers
This will not change the result as users are check to be existing
 afterwards but avoids this check when we know it’s a group.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:09:06 +07:00
Côme Chilliet d07f43dc12 Refactor _groupMembers to correctly use cache on intermediate results
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-20 12:09:06 +07:00
Carl Schwan 6522f8a6d9 Fix merging list with null
This fixes some cases observed with the debugger where we end up merging
a non empty list with null. The result is then null and the looping over
the items would then end.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 12:09:06 +07:00
Carl Schwan 49aa352069 Unify a bit the types of the fetcher
Now it will only accept a string as parameter instead of either a string
(DN) or a array (complete record).

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 12:09:06 +07:00
Carl Schwan 0fd7a51e3c Add more type hinting
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 12:09:06 +07:00
Arthur Schiwon 5647093319 Cache intermediates
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Co-authored-by: Carl Schwan <carl@carlschwan.eu>
2022-10-20 12:08:34 +07:00
Arthur Schiwon ad2fdbe377 Refactor code to split common loop
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-10-20 12:08:24 +07:00
Arthur Schiwon 1e4ac22c94 Make it possible to return nested records whem walking over groups
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-10-20 12:08:09 +07:00
Arthur Schiwon 50d4963772
[LDAP] throw exception only against prov api
- unbreaks functionality for end users when on demand mapping takes
  place

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-10-18 23:26:16 +07:00
Arthur Schiwon 8e8acf2d90
LDAP to no register new users when outside of fair use or over limits
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-10-18 12:57:43 +07:00
Côme Chilliet 1d2d6e864d
Avoid double ldap_unbind in Wizard.php
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-11 09:54:04 +07:00
Côme Chilliet 0a9a749174
Fix code style with codesniffer
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-10-11 09:53:27 +07:00
Vincent Van Houtte c323022d06 Add ldap-unix-socket support - squashed commits to files Connection.php, Configuration.php, Wizard.php, LDAP.php and view.js
Signed-off-by: Vincent Van Houtte <vvh@aplusv.be>
2022-09-09 16:53:05 +07:00
luz paz 9d26671f05 Fix typos in apps/ subdirectory
Found via `codespell -q 3 -S l10n,./apps/files_external/3rdparty -L adn,ba,boxs,keypair,jus,optionel,ressource,tabel ./apps/`

Signed-off-by: luz paz <luzpaz@github.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
2022-09-05 12:59:54 +07:00
Carl Schwan b888c61463
Merge pull request #33047 from nextcloud/fix/ijob-logger-deprecated
Deprecated ILogger from IJob
2022-08-23 16:55:42 +07:00
Joas Schilling f4885ee3ba
Remove unused method
Signed-off-by: Joas Schilling <coding@schilljs.com>
2022-08-22 14:15:32 +07:00
Joas Schilling ef60257110
Fix plural usage in LDAP wizard
Signed-off-by: Joas Schilling <coding@schilljs.com>
2022-08-22 14:14:47 +07:00
Carl Schwan 48d9c4d2b0
Port existing server code to new interface
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-08-08 17:03:19 +07:00
Carl Schwan d5c23dbb9f Move CappedMemoryCache to OCP
This is an helpful helper that should be used in more place than just
server and this is already the case with groupfodlers, deck, user_oidc
and more using it, so let's make it public

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-07-14 15:54:31 +07:00
blizzz 52c957e751
simplify
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>

Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
2022-06-28 16:07:11 +07:00
Arthur Schiwon d97f32dd8e
delete groups in chunks instead of one by one
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-06-28 14:35:18 +07:00
Arthur Schiwon 632f2d7760
cleanup LDAP's UpdateGroups
- TimedJob from API
- DI of config
- property types
- throws hints in phpdoc
- argument and return types
- replace depracet execute() with executeStatement or -Query
- a missing return statement

Co-authored-by: Carl Schwan <carl@carlschwan.eu>

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-06-28 14:34:56 +07:00
Carl Schwan 35d8bdc840 Fix profiler trying to serialize invalid utf8
The cookie value contains invalid utf8 characters most of the time so
let's just ignore it as it is also not that interesting to analyse.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-06-20 11:11:12 +07:00
Carl Schwan ec6b83cc18 Add stricter psalm type for CappedMemoryCache
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-05-12 15:06:18 +07:00
Carl Schwan 95b5187300 Don't use slow hashing to check the LDAP binding
Using password_hash is expensive and should be used for hashing
passwords when saving them in the database. Here we just want to see if
the bind was already done with the given password, so use a fast hashing
algorythm.

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-05-05 16:29:38 +07:00
John Molakvoæ 1e5a879d2e
Fix createNamedParameter in LDAP migrations
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
2022-04-07 11:34:13 +07:00
blizzz 835e28d0b2
Merge pull request #31661 from nextcloud/enh/user_ldap-add-command-to-unmap-groups
Add ldap:reset-group command to unmap groups from LDAP
2022-04-05 10:57:33 +07:00
Carl Schwan 135bdb3d58
Merge pull request #30823 from nextcloud/work/profiler
Built-in profiler

This adds the required API for collecting information about requests. This information
can then be displayed with the new 'profiler' app.
2022-04-04 12:56:37 +07:00
Carl Schwan 7d272c54d0 Add a built-in profiler inside Nextcloud
The webui is provided by a seperate application named profiler

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-04-04 10:28:26 +07:00
Côme Chilliet d7a291039d Fix user_ldap unit tests
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-01 12:18:03 +07:00
Côme Chilliet 91d6e88c2f Add missing file
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-01 12:18:03 +07:00
Côme Chilliet a2c030ffea Add type information to fix psalm error
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-01 12:18:02 +07:00
Côme Chilliet 77bdad84c2 Add ldap:reset-group command to unmap groups from LDAP
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-04-01 12:18:02 +07:00
Christoph Wurst 9c922ed15a Fix assignment of the LDAP Wizard connection
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2022-03-31 14:42:39 +07:00
Côme Chilliet 9fc00fdb82 Avoid updating _lastChange when nothing is changed in the configuration
Had to set at least one var when creating an empty configuration in
 order to save the default values.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-31 08:38:05 +07:00
Côme Chilliet bd9c4fbc07 Do not update _lastChanged on auto-detected attributes
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-31 08:38:05 +07:00
Côme Chilliet d07208bd2c Use the new octetLength function to filter lines to migrate
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-30 14:43:09 +07:00
Côme Chilliet 6c7ba01dfe Adapt max length limit in AbstactMapping to match database
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-30 14:43:09 +07:00
Arthur Schiwon 52b57eb753 shrink ldap_dn column to 4000
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-03-30 14:43:08 +07:00
Arthur Schiwon 2f49f4a0fe limit ldap_dn columns to 4000
- enlarging string cols from 255 to more than 4000 fails on default
  Oracle installations for invalid datatype conversion

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-03-30 14:43:08 +07:00
Côme Chilliet efebbacca4 Add octetLength and charLength to function builder, and tests
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-24 20:35:02 +07:00
Côme Chilliet 7dc3eb1e9e Use getLengthExpression to measure field length instead of like
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-24 20:35:02 +07:00
Arthur Schiwon 4656753df0
do not forget DB table prefix with truncate query
- as used in LDAP's AbstractMapping::clear() method
- and in Comment's ManagerTest::setUp()
- fixes a DB Exception with Oracle

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-03-18 16:59:46 +07:00
Côme Chilliet 475a859aae
Merge pull request #31421 from nextcloud/fix/user_ldap-fix-ldap-connection-resets
user_ldap fix ldap connection resets
2022-03-17 09:13:44 +07:00
Carl Schwan 371fa1c49a
Merge pull request #31542 from nextcloud/psalm-userCounts
Fix psalm issue about userCounts
2022-03-14 11:27:43 +07:00
Carl Schwan 1bf5ab35a8 Use "use" to import namespaces
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-03-14 09:35:01 +07:00
Carl Schwan 8d7380a15d Fix psalm issue about userCounts
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
2022-03-11 14:17:29 +07:00
Côme Chilliet ccab35f23f
Fix similar potential problems with fetchOne loops
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-08 12:10:52 +07:00
Côme Chilliet 65a866556b
Fix duplicated UUID detection when there are empty uuids
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-08 11:57:33 +07:00
Côme Chilliet df29acb343
Set $limit as int as well in Access::count private method
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-08 10:21:54 +07:00
Arthur Schiwon 16b6504cc6
code style
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-03-03 21:32:54 +07:00
Arthur Schiwon f3668f2748
be conservative when reading from fresh created column
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-03-03 21:26:18 +07:00
Côme Chilliet dab5ea958a
Fix unit tests
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-03 16:35:06 +07:00
Côme Chilliet 0c5bd588ed
Fix types in OCA\User_LDAP\Configuration
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-03 11:53:50 +07:00
Côme Chilliet e80eb79a1e
Remove redundant is_array check
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-03 11:41:59 +07:00
Côme Chilliet fb63484ced
Improve typing in user_ldap to detect problems early
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-03 11:12:09 +07:00
Côme Chilliet 8349530fb4
Fix executeRead when connection is reset because of a timeout
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-03-03 10:24:07 +07:00
Côme Chilliet 44680b5c3b
Make it explicit that a DN can be used for ldap:check-user
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-17 10:00:25 +07:00
Côme Chilliet a6ad06f940
Improve typing in apps/user_ldap/lib/Command/CheckUser.php
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-17 09:58:51 +07:00
Côme Chilliet a4f96c18e9
Remove parenthesis around return in apps/user_ldap/lib/Command/CheckUser.php
Co-authored-by: Carl Schwan <carl@carlschwan.eu>

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-17 09:58:51 +07:00
Côme Chilliet 75ce9a4832
Fix ldap:check-user method for newly created LDAP users
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-17 09:58:28 +07:00
Vincent Petry cd1bf94181
Merge pull request #31073 from nextcloud/fix/user_ldap-fix-access-typing
Improve typing in OCA\User_LDAP\Access and reduce psalm errors
2022-02-10 17:53:58 +07:00
Côme Chilliet bcfe99cc62
Fix psalm errors in apps/user_ldap/lib/Jobs/CleanUp.php
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-10 10:15:00 +07:00
Côme Chilliet 9f2db6e65d
Fix ldap:update-uuid
Generators cannot be iterated with while or returned by an other
 generator, using foreach instead.
And a few other problems.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-10 10:15:00 +07:00
Arthur Schiwon 45d4c0bf66
add occ command to update UUIDs (incomplete)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-02-10 10:14:59 +07:00
Arthur Schiwon 601ce05dab
allow to re-run migration step when backup DB is already created
- to heal incomplete states from broken upgrades

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-02-10 10:14:59 +07:00
Arthur Schiwon 71fb44953e
invalidated duplicated UUIDs prior to migration change
- in a proper setup there are no duplicated UUIDs
- not all setups are proper
- log warning to admin

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
2022-02-10 10:14:58 +07:00
Côme Chilliet 77add404b1
Remove mixed type not available in PHP 7.4
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-08 14:32:23 +07:00
Côme Chilliet 5f65d5a58d
Add a comment explaining how Helper::loginName2UserName can work
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-08 14:25:09 +07:00
Côme Chilliet 2a0b2250d2
Improve typing in OCA\User_LDAP\Access and reduce psalm errors
This should avoid some PHP warning using PHP 8.1
 and help detecting type trouble early in the future.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2022-02-08 14:21:16 +07:00