Commit Graph

88 Commits

Author SHA1 Message Date
Daniel Swärd
6f7bd454b2 Fix so that userType is not returned if not available. 2023-03-15 12:05:29 +01:00
Daniel Swärd
23ba180e8a graph: Use userType property to distinguish between Member and Guest accounts
Fixes 5603

- Calling POST /graph/v1.0/users with userType not set will create a user as "Member"
- Calling POST /graph/v1.0/users with userType set as "Member" or "Guest" will create a user as "Member" or "Guest"
- Calling POST /graph/v1.0/users with userType set as anything but "Member" or "Guest" returns error
- Calling POST /graph/v1.0/education/users with userType not set will create a user as "Member"
- Calling POST /graph/v1.0/education/users with userType set as "Member" will create a user as "Member" and primary role as parameter specifies
- Calling POST /graph/v1.0/education/users with userType set as "Guest" will create a user as "Guest" and primary role as parameter specifies
- Calling POST /graph/v1.0/education/users with userType not set as anything but "Member" or "Guest" returns error
- Calling PATCH on /users or /education/users will update attribute in the same way as for POST
2023-03-15 12:05:29 +01:00
Daniel Swärd
6b11f0bfe4 graph: Fix problem with unescaped semicolon and such causing problems. 2023-03-14 15:21:58 +01:00
Ralf Haferkamp
d133a8e4b2 graph: Add missing patch support for education/users (#5772)
* graph: Allow updating "surname" and "givenName" of users

Also use attribute getters to lookup the attribute Values instead of fiddling around
with pointers.

* graph: Allow updating education users

Update suppport for education users was still missing.
2023-03-09 07:52:06 +01:00
Daniel Swärd
ca746106d8 graph: Allow disabling user by adding to local group
* A new config option for disabling users with the options "none", "attribute" and "group".
* When set to "none", there will be no enabledAttribute returned in user info and trying to change enabledAttribute will return an error
* Disable/enable group name DN as config parameter
* Adding/removing users to specified group on user update
* Changing log level for service initialization failure to error
* Adding helper methods to check if user is enabled/disabled + tests

Fixes #5554
2023-03-06 09:31:23 +01:00
David Christofas
0fadc79c32 make graph/education API errors more consistent 2023-02-28 15:25:45 +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
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
2338515444 Make ldap functions package local and remove a superfluous comment. 2023-02-10 15:12: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
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
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
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
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
Daniël Franke
2ca35f0a2b Allow patching of EducationClass properties.
As described in #5410: add support for updating educationClass properties.
This adds the `UpdateEducationClass` to the `EducationBackend` interface,
and implements it on the `ErrEducationBackend` and `LDAP` backends.

It also alters `PatchEducationClass` to call the `UpdateEducationClass` method.

Closes #5410
2023-01-23 14:38:12 +01:00
Ralf Haferkamp
473c64fe03 graph: fix adding users to educationSchool by schoolNumber (#5422)
GET /education/schools/{school-id}/users
POST /education/schools/{school-id}/users/$ref
and
DELETE /education/schools/{school-id}/users/$ref

are supposed to also work when using the schoolNumber as the
'{school-id}' parameter. This fix that functionality. This also makes the
the mocks for the LDAP Modify operations more specific to avoid using
the generic mock.Anything
2023-01-23 10:37:24 +01:00
Ralf Haferkamp
c2ed4ab526 Bump libregraph-api-go (#5432) 2023-01-23 10:28:10 +01:00
Jörn Friedrich Dreyer
52b7f41624 Populate expanded properties (#5421)
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-01-18 15:51:53 +01:00
Jörn Friedrich Dreyer
3aa864aecc Remove Staticcheck warnings (#5394)
* remove deprecated ioutil imports

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

* remove duplicate imports

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

* remove unused values

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

* remove some unused types

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

* remove deprecated ioutil import

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

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2023-01-13 15:29:14 +01:00
Ralf Haferkamp
60ac8fcfbe graph education/classes: Add LDAP backend support for Create,Get,Delete 2023-01-12 17:37:10 +01:00
Ralf Haferkamp
6d5637ad79 graph: Move LDAP groups related code to a separate file 2023-01-12 17:37:10 +01:00
Daniël Franke
b0cd8779a7 Consistently add user attributes to AddRequest (#5392)
To make the `CreateUser` flow easier to test, the attributes of the
LDAP add request need to be added consistently. This way we can
expect that argument with the mock.

This PR does the following:

* Add a method `getUserAttrTypes` that returns a static list of attr names.
* Alter `userToAddRequest` to iterate over the static list, and add the attr
  if it exists in the `attrMap`.

Closes #5390
2023-01-12 17:25:43 +01:00
Daniël Franke
ddb0933033 Display surname and givenName attributes.
This PR makes it so that givenName and surname attributes are returned for users.

Fixes #5386
2023-01-12 15:01:14 +01:00
Daniël Franke
8055996874 Test CreateUser (#5382)
This tests the CreateUser functions.

Fixes #5375
2023-01-12 09:42:05 +01:00
Ralf Haferkamp
709ef1ffca graph:Add stubs for education/classes endpoints (#5360)
* Renamed files for consistency reasons

err_school.go implements the full education interface not just schools.
ldap_school.go renamed to ldap_education_school.go for making it
consistent with ldap_education_user.go

* graph: Add stubs for education/classes endpoints

The acutal backend implementations are still empty.
2023-01-11 20:38:18 +01:00
Daniël Franke
f7aff26636 Merge pull request #5370 from owncloud/ainmosni/issue/5210
Support givenName graph attribute.
2023-01-11 14:32:13 +01:00
Daniel Swärd
e1ad437d9e Fix problem with non-public error type because of forgotten rebase. 2023-01-11 12:14:54 +01:00
Daniel Swärd
e15b3cd8cc Adding so education PATCH updates school name or number. 2023-01-11 12:14:54 +01:00
Jörn Friedrich Dreyer
b9a4d0c8f7 Update services/graph/pkg/identity/ldap.go 2023-01-11 10:15:26 +01:00
Daniël Franke
5409a38549 Support givenName graph attribute.
This sets the LDAP `givenname` attribute when the libe-graph `givenName`
attribute exists.

Fixes #5210
2023-01-10 12:48:26 +01:00