Commit Graph

190 Commits

Author SHA1 Message Date
Ralf Haferkamp
db752dc5ac graph: Add support for "or" filter on /users
This add support for combining filters on the /users with a logical "or" operation.
E.g. the filter:

"filter=(memberOf/any(m:m/id eq 509a9dcd-bb37-4f4f-a01a-19dca27d9cfa) or memberOf/any(m:m/id eq 262982c1-2362-4afa-bfdf-8cbfef64a06e)"

will return all users that are a member of either of the referenced group.

Closes: #5667
2023-03-02 13:26:00 +01:00
David Christofas
0fadc79c32 make graph/education API errors more consistent 2023-02-28 15:25:45 +01:00
kobergj
e631b74032 Merge pull request #5600 from kobergj/EventHistory
Eventhistory Service
2023-02-21 14:08:01 +01:00
Ralf Haferkamp
1dab0f7a54 graph: Improve appRoleAssignemts filters
This should improve the processing of filters for appRoleAssignments
a bit when combining them with other filters. We try to avoid reading
the full user list if possible. And delay the processing of an
appRoleAssignments filter so we can apply it on a subset of user.

E.g. a filter:

`appRoleAssignments/any(m:m/appRoleId eq 71881883-1768-46bd-a24d-a356a2afdf7f) and memberOf/any(m:m/id eq 509a9dcd-bb37-4f4f-a01a-19dca27d9cfa)`

Will be reordered to first process the memberOf filter (which can be
executed without reading the full user list) and only apply the
appRoleAssignments filter on the resultset of the memberOf filter.
2023-02-21 12:30:59 +01:00
Ralf Haferkamp
1552f6df5a Add support for $filter on appRoleAssignment
This add support for filtering on the `appRoleAssignment` relation of
users.  E.g.

```
$filter=appRoleAssignments/any(m:m/appRoleId eq '262982c1-2362-4afa-bfdf-8cbfef64a06e')
```

combining it with a filter on groupMemberShip does also work:

```
$filter=memberOf/any(m:m/id eq '262982c1-2362-4afa-bfdf-8cbfef64a06e') and appRoleAssignments/any(m:m/appRoleId eq 'd7beeea8-8ff4-406b-8fb6-ab2dd81e6b11')
```

The filter is still very inefficient as it always needs to get the full
users list. We need to adapt it to only filter on a subset of users when
using this filter 'and' combined with other filters.

Closes: #5488
2023-02-21 12:30:59 +01:00
jkoberg
c9dfb778a9 sharpen eventhistory service
Signed-off-by: jkoberg <jkoberg@owncloud.com>
2023-02-21 10:51:32 +01:00
Daniël Franke
3f39bb530e Integrate feedback. 2023-02-20 14:40:10 +01:00
Daniël Franke
bea3ec6207 Add refint support to user rename.
When refint is enabled on an LDAP server, it will rename all references
to an entity if its DN is modified. If this happens, the member
renames will not be needed, and will also return an error.

This PR does the following:

* Detects the attribute error, and don't return an error.
* Log that the server has been misconfigured.
* Add config value that skips renaming if set.
2023-02-20 14:40:10 +01:00
Daniel Swärd
fcf5783a1b graph: Add accountEnabled flag to ldap backend. (#5588)
* graph: Add accountEnabled flag to ldap backend.

* Add missing accountEnabled attribute to user listing.
2023-02-17 13:48:12 +01:00
Daniël Franke
92f4d60a06 Properly generate new DN.
This fixes issue #5581 by properly parsing the old DN and replacing the
first part with the new DN.
2023-02-16 12:41:29 +01:00
Jörn Friedrich Dreyer
92923f6801 Add http endpoint to list permissions (#5571)
* Add http endpoint to list permissions

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* extract handler registration

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use generated protobuf

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update permissions mock in graph service

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add unit test

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* return correct userid

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* assert error message type in tests

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

---------

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-02-15 14:24:19 +01:00
Daniël Franke
9bd1551c6b Integrate @rhafer's feedback 2023-02-15 10:06:23 +01:00
Daniël Franke
172807bb69 Add testcase for changing username. 2023-02-15 10:06:23 +01:00
Daniël Franke
bed4a82ff0 Finish working code and most of tests. 2023-02-15 10:06:23 +01:00
Daniël Franke
a51393e5bf Add username changing functionality.
This is an incomplete implementation of username changing code.

The things still needed to be finished:

* The method that changes the member attribute has to be filled in.
* The functionality needs to be tested.
* Unit tests need to be added.
2023-02-15 10:06:23 +01:00
Ralf Haferkamp
b7ec7c92c4 graph: Initial support for $filter in /users (#5533)
This adds some initial support for using $filter (as defined in the
odata spec) on the /users endpoint. Currently the following filters are
supported:

A single filter on `id` property of the `memberOf` relation of users.
To list all users that are members of a specific group:

```
curl 'https://localhost:9200/graph/v1.0/users?$filter=memberOf/any(m:m/id eq '262982c1-2362-4afa-bfdf-8cbfef64a06e')
```

A logical AND filteri on the `id` property of the `memberOf` relation of users.

`$filter=memberOf/any(m:m/id eq 262982c1-2362-4afa-bfdf-8cbfef64a06e) and memberOf/any(m:m/id eq 6040aa17-9c64-4fef-9bd0-77234d71bad0)`

This will cause at least two queries on the identity backend. The `and`
operation is performed locally.

Closes: #5487
2023-02-14 10:32:32 +01:00
Daniel Swärd
e853b98918 Merge pull request #5534 from owncloud/excds/feature/5411_support_adding_and_removing_of_teachers_for_classes
graph: Add support for listing/adding/removing teachers to a class
2023-02-13 11:48:58 +01:00
Daniel Swärd
2338515444 Make ldap functions package local and remove a superfluous comment. 2023-02-10 15:12:19 +01:00
Jörn Friedrich Dreyer
fc95edb914 allow GETing a users personal drive (#5539)
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-02-10 14:17:19 +01:00
Daniel Swärd
82e312ac2f Fix sonarcloud comment nitpick. 2023-02-10 11:50:46 +01:00
Daniel Swärd
a21f485d2c Fix forgotten expected return values in tests. 2023-02-10 11:21:55 +01:00
Daniel Swärd
4c1325f02a Remove duplication and make method generic. 2023-02-09 11:56:10 +01:00
Daniel Swärd
399e05b256 Remove code duplication for ldap entry membership. 2023-02-09 11:38:50 +01:00
David Christofas
b6ea8a845c make linter happy 2023-02-08 17:05:06 +01:00
David Christofas
c7c4cda7d7 add an expiration to the space member permissions 2023-02-08 17:05:00 +01:00
Daniel Swärd
8e1a65fc29 graph: Add support for listing/adding/removing teachers to a class 2023-02-08 16:55:10 +01:00
Ralf Haferkamp
26f7523ff8 graph: Pass parsed odata request to the identity backend
In preparation for some more advanced queries pass the parse odata request
tVo the identity backend methods instead of the raw url.Values{}. This also
add some helpers for validating $expand and $search queries to reject
some unsupported queries.

Also remove support for `$select=memberOf` and `$select=drive|drives` queries
and stick to the technically correct `$expand=...`.
2023-02-08 14:25:55 +01:00
Ralf Haferkamp
25d2a2bc71 graph: Remove some uneeded stuff for the education backend
We don't need to support any complex queries on /education (yet?). And if we would need
to add support for $search, $filter, $expand or $select we should pass the parsed odata Query
instead of the raw url.Values struct.
2023-02-08 14:25:55 +01:00
mmattel
210cd54817 fix some envvar descriptions 2023-02-03 09:40:35 +01:00
Ralf Haferkamp
ba761a0c3f graph: Make roleService optional again
Allow to use the /graph/users and /graph/education/users endpoints standalone
without the RoleService running. When there is no Roleservice do not expose
the `/appRoleAssignments` endpoint.
2023-02-02 16:04:03 +01:00
Ralf Haferkamp
82021dca5a graph: Fix event handling for /groups
When running the graph service standalone with token auth we don't
have a user in the context. Avoid nil point exception when issueing
events in such a setup.
2023-02-02 16:04:03 +01:00
Daniël Franke
e1a4ac6b33 Fix tests 2023-01-31 12:52:49 +01:00
Daniël Franke
5ccb218267 Add memberOfSchoolAttribute to class attrr getter. 2023-01-31 12:52:49 +01:00
Daniël Franke
992ef9c5d7 Rename some variables, remove TODO. 2023-01-31 12:52:49 +01:00
Daniël Franke
e5eb1e1a6d Add tests for ldap functions.
Also add interface functions to middleware.
2023-01-31 12:52:49 +01:00
Daniël Franke
610ad7ddd0 Add tests for service handlers. 2023-01-31 12:52:49 +01:00
Daniël Franke
14734f3d16 Fix comments for exported methods. 2023-01-31 12:52:49 +01:00
Daniël Franke
20f6a212f3 Add service endpoints. 2023-01-31 12:52:49 +01:00
Daniël Franke
9b8adb65ed Add LDAP entries for adding classes to schools. 2023-01-31 12:52:49 +01:00
Jörn Friedrich Dreyer
aa12a60d16 fix populating user drive and drives (#5426)
* fix populating user drive and drives

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update changelog

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* fix test condition

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-01-26 11:54:32 +01:00
Daniël Franke
c48426f641 Emit GroupFeatureChanged event on class patch.
When a class has changed, emit a GroupFeatureChanged event.
2023-01-24 10:21:22 +01:00
Daniel Swärd
c79d4ec241 graph: Allow creating users without email (#5253) 2023-01-23 15:20:32 +01:00
Daniël Franke
b30b0b4a6c Fix test. 2023-01-23 14:38:12 +01:00
Daniël Franke
17bd1704fa Stop expecting class var. 2023-01-23 14:38:12 +01:00
Daniël Franke
e6273140a2 Revert status change. 2023-01-23 14:38:12 +01:00
Daniël Franke
a9fff65209 Remove tests for non-supported properties. 2023-01-23 14:38:12 +01:00
Daniël Franke
bfecff7747 Remove OnPremises code. 2023-01-23 14:38:12 +01:00
Daniël Franke
4389bcdd25 Add documentation comment. 2023-01-23 14:38:12 +01:00
Daniël Franke
d2076941f4 Add tests.
Also update mocks with mockery.
2023-01-23 14:38:12 +01:00
Daniël Franke
3772e8190e Change DN on externalID change. 2023-01-23 14:38:12 +01:00