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

Add Role-based restriction to backend mutations #594

Merged
merged 16 commits into from
Sep 7, 2021

Conversation

ErlendHaa
Copy link
Contributor

@ErlendHaa ErlendHaa commented Sep 3, 2021

This PR adds role-based restrictions to all exposed mutations. Additionally it extends the current test-framework to test the new restrictions.

The test framework for Mutation testing in the backend only implements access-based tests at the moment, but it is intended to be used for further correctness testing of the mutations. However that is out of scope of this PR.

Closes #537
Closes #512

@ErlendHaa ErlendHaa force-pushed the restrict-mutation-backend branch from e227b4c to e4c8fde Compare September 6, 2021 06:18
@@ -1,4 +1,5 @@
using System;
using System.Linq;
Copy link
Contributor

Choose a reason for hiding this comment

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

probably don't need linq here

Comment on lines -215 to -218
public Note EditNote(string noteId, string text)
{
Note note = _noteService.GetNote(noteId);
return _noteService.EditNote(note, text);
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we are not using, nor want to have the possibility to edit Notes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's my so-far conclusion, yes.

This mutation is unused and there are currently no UI support for
editing notes - nor is any such feature planned.

Updating and maintaining this mutation without any current or future planned use-case for it seams like unnecessary work. If we ever need it, we can revert this commit

@ErlendHaa ErlendHaa force-pushed the restrict-mutation-backend branch from 79b3e48 to 55afd45 Compare September 7, 2021 05:47
@ErlendHaa
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

The goal is to implement restrictions for which roles can do what
mutations in the backend. To that end the AssertIsFacilitator is
replaced by the more general AssertCanPerformMutation.

To avoid having to replicate AssertCanPerformMutation in the mocked
version of the AuthService, the method is also moved to the Mutation
class.
Extend the functionallity of the MockAuthService class to allow setting
different "signed-in"-users.
This commit implements role-based restrictions on the CreateParticipant
mutation. Only Facilitator and OrganizationLead can use this mutation.

As a consequence, the seeding logic in the cypress test needs to be
updated to ensure that the mutation is only performed by a Facilitator.
This commit implements role-based restrictions on the SetAnswer
mutation. This effectively excludes Read-Only participants and
non-participating users from using this mutation.
This commit implements role-based restrictions on the CreateAction
mutation. This effectively excludes Read-Only participants and
non-participating users from using this mutation.

Whether Role.Participant should be able to create actions is currently up
for debate, so this might be subject to change.
This commit implements role-based restrictions on the EditAction
mutation. This effectively excludes Read-Only participants and
non-participating users from using this mutation.

Whether Role.Participant should be able to create actions is currently up
for debate, so this might be subject to change.
This commit implements role-based restrictions on the DeleteAction
mutation. Only Facilitators are permitted to use this mutation.
This commit implements role-based restrictions on the CreateNote
mutation. This effectively excludes Read-Only participants and
non-participating users from using this mutation.
This mutation is unused and there are currently no UI support for
editing notes - nor is any such feature planned.
This commit implements role-based restrictions on the
CreateClosingRemark mutation. This effectively excludes Read-Only
participants and non-participating users from using this mutation.

Whether Role.Participant should be able to create closing remarks is
currently up for debate, so this might be subject to change.
This commit implements role-based restrictions on the DeleteParticipant
mutation. Only Facilitator and OrganizationLead are permitted to use
this mutation.
This commit implements role-based restrictions on the
ProgressParticipant mutation. This effectively excludes Read-Only
participants and non-participating users from using this mutation
@ErlendHaa ErlendHaa force-pushed the restrict-mutation-backend branch from 55afd45 to 53e42d7 Compare September 7, 2021 06:25
@ErlendHaa ErlendHaa merged commit 858b84e into equinor:master Sep 7, 2021
@ErlendHaa ErlendHaa deleted the restrict-mutation-backend branch September 7, 2021 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants