Prevent unwanted organization detach from server #24
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.
Right now any update of the organizations attached to a server resource is handled detaching the ones in the old list and attaching the ones in the new list.
A side effect of this behaviour is the server loss of the former primary organizazion and primary user, even if this former organization was never intended to be removed in the first place.
The loss of primary org/user triggers, at server restart, the generation of a new server certificate, issued by the new established primary organization CA.
Any client ovpn profile in use that don't have the latter CA present in its ca.pem won't be able to validate the new server certificate.
As a solution, the list of organizations to be detached (and than the one to be attached) will be the result of a diff between the two different lists of organizations. In doing so, only the organizations that were explicitly removed will be detached from server.