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

Feature: User-based access to tasks #18

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

mrtamm
Copy link
Contributor

@mrtamm mrtamm commented Oct 11, 2024

This PR provides the code for associating tasks with the users who create them, and restricting access to tasks based on whether the user is an administrator or the creator of the task. It also supports the scenario when there is no user-authentication: then the tasks have no owners and everyone can see tasks without owners. There are no API-changes due to this development.

Changes to databases should be backward compatible, except that existing tasks (without ownership) won't be visible to non-admin users. In the configuration file, it's now possible to specify that a user (under Basic authentication) is an administrator. It is not supported with OIDC. Related configuration and documentation files were also updated a bit.

For this feature, user authentication information is now stored in the request Context as UserInfo({IsPublic bool, IsAdmin bool, Username string}). Different database implementations get the UserInfo from the Context and evaluate task ownership, or store the username with a task (if Username is not empty).

Notes about database implementations:

  1. Badger: tasks are stored under keys tasks<taskId> and their owners under keys owners<taskId>.
  2. BoltDB: owners are stored in a separate bucket ("tasks-owner") where taskID (key) has the value of its owner (username).
  3. Google Datastore: owner is stored with the task data
  4. Amazon DynamoDB: owner is stored with the task data
  5. ElasticSearch: owner is stored with the task data
  6. MongoDB: owner is stored with the task data

During testing I realised that support for ElasticSearch, MongoDB, Datastore is quite old. For example, I had to use Mongo version 4 (latest is 8) for testing. ElasticSearch client library is at version 5 while ElasticSearch itself is at version 8. The successor of Google Datastore is Google Firestore... I did not go into upgrading but it's good to bear in mind that Badger and BoltDB are probably the most convenient to use, at the moment.

Just in case, here is a reference that the CI pipeline was successful:
https://github.com/mrtamm/funnel-gdi/actions/runs/11291323700

@mrtamm mrtamm changed the title Feature: User-based access to tasks #14 Feature: User-based access to tasks Oct 11, 2024
@mrtamm mrtamm mentioned this pull request Oct 11, 2024
@mrtamm
Copy link
Contributor Author

mrtamm commented Oct 14, 2024

My GitHub actions CI script for the second commit succeeded: https://github.com/mrtamm/funnel-gdi/actions/runs/11327029713

Comment on lines 15 to 34
Server:
BasicAuth:
- User: admin
Password: someReallyComplexSecret
Admin: true
- User: funnel
Password: abc123
```

Note that users see only their tasks, by default, unless a user is explicitly marked as administrator.
Administrative users can see and interact with the tasks of all users.

If you are using BoltDB or Badger, the Funnel worker communicates to the server via gRPC
so you will also need to configure the RPC client.
so you will also need to configure the RPC client.

```yaml
RPCClient:
User: funnel
Password: abc123
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the RPCClient always use an admin user? Otherwise, it is bound to a single user "account" and cannot access other tasks. If that's the case, it would be nice to mention it in the docs or at least modify the example accordingly.

@xhejtman xhejtman merged commit 8e4b1ab into CERIT-SC:master Oct 16, 2024
5 checks passed
@mrtamm mrtamm deleted the dev-user-based-tasks branch November 7, 2024 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants