Feature: User-based access to tasks #18
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
asUserInfo({IsPublic bool, IsAdmin bool, Username string})
. Different database implementations get theUserInfo
from theContext
and evaluate task ownership, or store the username with a task (ifUsername
is not empty).Notes about database implementations:
tasks<taskId>
and their owners under keysowners<taskId>
.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