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

Prevent removing last _ALL right from entity collaborator #4464

Merged
merged 1 commit into from
Aug 2, 2021

Conversation

htdvisser
Copy link
Contributor

@htdvisser htdvisser commented Jul 29, 2021

Summary

This pull request changes the SetCollaborator RPCs of the Identity Server to ensure that every entity has at least one collaborator with the _ALL right.

We previously thought that users deleting their own account was a problem and worked on handling that (#3458 / #3616; eventually dropped), but in fact it's much more common for users to accidentally revoke their collaborator access from their entities, which should be solved by this PR.

Refs https://www.thethingsnetwork.org/forum/t/move-your-ttig-to-v3-yes/49287/59?u=htdvisser

Testing

I've extended the existing tests a little, but couldn't reliably cover the error itself because of the randomly populated database. Luckily we can still monkey-test this:

Screen Shot 2021-07-29 at 14 13 27

⚠️ The error message was updated after I took the screenshot. The message is now

every gateway needs at least one collaborator with all rights

Regressions

This could make it impossible to update collaborators of entities that already don't have a collaborator with the _ALL right.

Notes for Reviewers

This doesn't fully cover accidental loss of access to entities when rights are granted through organizations, but I think it's already better than having no protection at all.

Checklist

  • Scope: The referenced issue is addressed, there are no unrelated changes.
  • Compatibility: The changes are backwards compatible with existing API, storage, configuration and CLI, according to the compatibility commitments in README.md for the chosen target branch.
  • Documentation: Relevant documentation is added or updated.
  • Changelog: Significant features, behavior changes, deprecations and fixes are added to CHANGELOG.md.
  • Commits: Commit messages follow guidelines in CONTRIBUTING.md, there are no fixup commits left.

@htdvisser htdvisser added this to the v3.14.1 milestone Jul 29, 2021
@htdvisser htdvisser self-assigned this Jul 29, 2021
@github-actions github-actions bot added the c/identity server This is related to the Identity Server label Jul 29, 2021
Copy link
Member

@kschiffer kschiffer left a comment

Choose a reason for hiding this comment

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

Please don't remove the Changes section in the PR description. It helps me to verify/check off bits of changes.

Changes LGTM, please see my note on the messages.

@@ -227,6 +228,8 @@ func (is *IdentityServer) getApplicationCollaborator(ctx context.Context, req *t
return res, nil
}

var errApplicationNeedsCollaborator = errors.DefineFailedPrecondition("application_needs_collaborator", "every application needs at least one collaborator with all rights")
Copy link
Member

Choose a reason for hiding this comment

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

Can't we use one message with an attribute for the entity type for all messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but then we'll have a random entity type variable in the message that we can't translate.

@htdvisser
Copy link
Contributor Author

Please don't remove the Changes section in the PR description. It helps me to verify/check off bits of changes.

Sorry. This is one change, exactly as described in the summary. And then copy-pasted from gateways to applications, clients and organizations.

@htdvisser htdvisser merged commit d665b1c into v3.14 Aug 2, 2021
@htdvisser htdvisser deleted the issue/avoid-orphans branch August 2, 2021 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/identity server This is related to the Identity Server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants