Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graph: Add support for filtering users by groupMembership #5487

Closed
rhafer opened this issue Feb 1, 2023 · 4 comments · Fixed by #5533
Closed

graph: Add support for filtering users by groupMembership #5487

rhafer opened this issue Feb 1, 2023 · 4 comments · Fixed by #5533
Assignees

Comments

@rhafer
Copy link
Contributor

rhafer commented Feb 1, 2023

Allow to query all users belonging to a specific group. By using filters on the /users API

/users?$filter=memberOf eq ''

First thing to clarify: Is this really needed? It's already possible to list all group members using

/groups/<group-id>/members/

Maybe that is good enough.

@rhafer rhafer changed the title graph: Add support for filter users by groupMembership graph: Add support for filtering users by groupMembership Feb 1, 2023
@exalate-issue-sync exalate-issue-sync bot changed the title graph: Add support for filtering users by groupMembership graph: Add support for filtering users by groupMembership Feb 1, 2023
@rhafer
Copy link
Contributor Author

rhafer commented Feb 1, 2023

@kulmann @janackermann do we really need this on the /users/ endpoint?

We already have: /groups/{group-id}/members which return all members of a specific group.

@JammingBen
Copy link
Contributor

JammingBen commented Feb 6, 2023

@rhafer It's still needed, because /groups/{group-id}/members] can only filter by one group ID, whereas /users?$filter=memberOf eq '' has (should have) the possibility to handle multiple group ids. What we want to have in Web is a filter in the users list where you can filter e.g. "List all users that are in the groups admin and/or physics-lovers".

@rhafer
Copy link
Contributor Author

rhafer commented Feb 7, 2023

After reading a bit more through the odata specs and MS Graph docs. I think the filter is somewhat more complex than initially thought. As memberOf is not a property of a user but a relation we need to use some more crazy "advanced" filters here. Basically to filter all users that a member of a group with id=some-id the filter looks like:

$filter=memberOf/any(m:m/id eq 'some-id')

to filter by group name it would be:

$filter=memberOf/any(m:m/displayName eq 'some-name')

My intention is to get the filter by id working first. And see from there.

@JammingBen
Copy link
Contributor

My intention is to get the filter by id working first. And see from there.

By ID is totally fine, Web does not need more (for now at least) 🙂

@rhafer rhafer self-assigned this Feb 7, 2023
rhafer added a commit to rhafer/ocis that referenced this issue Feb 8, 2023
This adds some initial support for using $filter (as defined in the
odata spec) on the /users endpoint. Currently the only supported filter
is 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')
```

Closes: owncloud#5487
rhafer added a commit to rhafer/ocis that referenced this issue Feb 8, 2023
This adds some initial support for using $filter (as defined in the
odata spec) on the /users endpoint. Currently the only supported filter
is 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')
```

Closes: owncloud#5487
rhafer added a commit to rhafer/ocis that referenced this issue Feb 8, 2023
This adds some initial support for using $filter (as defined in the
odata spec) on the /users endpoint. Currently the only supported filter
is 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')
```

Closes: owncloud#5487
rhafer added a commit to rhafer/ocis that referenced this issue Feb 13, 2023
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: owncloud#5487
rhafer added a commit to rhafer/ocis that referenced this issue Feb 13, 2023
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: owncloud#5487
rhafer added a commit to rhafer/ocis that referenced this issue Feb 14, 2023
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: owncloud#5487
butonic pushed a commit that referenced this issue Feb 14, 2023
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
ownclouders pushed a commit that referenced this issue Feb 14, 2023
Author: Ralf Haferkamp <[email protected]>
Date:   Tue Feb 14 10:32:32 2023 +0100

    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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants