Skip to content

Follow OrgRules to forbid backups keys - #376

Merged
tomholub merged 8 commits into
masterfrom
feature/issue-277-follow-orgrules-to-forbid-backups
Jul 9, 2021
Merged

Follow OrgRules to forbid backups keys#376
tomholub merged 8 commits into
masterfrom
feature/issue-277-follow-orgrules-to-forbid-backups

Conversation

@ekievsky

@ekievskyekievsky commented Jul 3, 2021

Copy link
Copy Markdown
Contributor

This PR:
Skipping backups searching on Setup and Settings if OrgRules has canBackupKeys false;
Handling unknown ClientConfigurationFlag;
Added tests for unknown ClientConfigurationFlag;
Waiting for OrgRules to be fetched on Startup;

close#277


Tests:

  • Tests added or updated

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities
  • is documented clearly and usefully, or doesn't need documentation

…ackupKeys false;
Handling unknown ClientConfigurationFlag;
Added tests for unknown ClientConfigurationFlag;
Waiting for OrgRules to be fetched on Startup;
@ekievsky

Copy link
Copy Markdown
ContributorAuthor

@tomholub The build fails on CI and if I open SemaphoreCI it shows me empty screen with Secret flowcrypt-ios-ci-secrets not found message, is it internal Semaphore issue?

@Kharchevskyi

Copy link
Copy Markdown
Contributor

same for https://flowcrypt.semaphoreci.com/workflows/183fcbb7-7dec-4c55-aa82-680e9f0beb39

@Kharchevskyi

Copy link
Copy Markdown
Contributor

@tomholub we do not run ui tests on CI. Maybe we can remove this step from CI flow?

@ekievsky

Copy link
Copy Markdown
ContributorAuthor

Hi @tomholub , which task should I take next?

@tomholub

tomholub commented Jul 6, 2021 via email

Copy link
Copy Markdown
Collaborator

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for the PR - see my comments.

Some of the naming choices were not ideal already in the code before your PR, but got highlighted now - so we'll do a bit of refactoring per my comments.

Comment threadFlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift Outdated
Comment threadFlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift Outdated
Comment threadFlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift Outdated
Comment threadFlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift Outdated
Comment threadFlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift Outdated
Comment threadFlowCrypt/Controllers/Settings/Settings List/SettingsViewController.swift Outdated
Comment threadFlowCrypt/Controllers/Setup/SetupInitialViewController.swift
Comment threadFlowCrypt/Models/ClientConfiguration.swift
@tomholub
tomholub marked this pull request as draft July 8, 2021 18:43
@ekievsky

Copy link
Copy Markdown
ContributorAuthor

@tomholub there could be error with JSON parsing and wrong user domain in EnterpriseServerApi should we show error on startup with error description or just create OrgRules with empty ClientConfig?

@tomholub

tomholub commented Jul 8, 2021

Copy link
Copy Markdown
Collaborator

@tomholub there could be error with JSON parsing and wrong user domain in EnterpriseServerApi should we show error on startup with error description or just create OrgRules with empty ClientConfig?

Thank you for asking. Absolutely have to show error to the user, never default to empty ClientConfig to resolve errors.

Additionally:

  • If this error happened when we already had OrgRules saved before (we are refreshing them), then leave already saved OrgRules as they are
  • if this error happens during setup flow - before any OrgRules were saved before - we cannot proceed setup at all.

Only default to empty ClientConfig on gmail.com domain and similar where we know there are no OrgRules to fetch.

In general, I want errors to be handled "harshly" - either crash the app if it's never expected (like a value that should never be nil but somehow is), or show the error to the user if it's some errors that could conceivably happen (like a network error, or badly formatted external json like here).

We do a lot of "soft" error handling in the app with something ?? "" and similar and I dislike it a lot, because errors don't get properly discovered where they happen, and instead they either blow up somewhere else (best case) or go completely unnoticed (worst case), so I'd like to move away from doing that.

Made OrganisationalRules not optional;
Fixed PR comments;
@ekievsky
ekievsky marked this pull request as ready for review July 9, 2021 09:09
Comment on lines 123 to +124
storage.delete(userToDelete)
storage.delete(clientConfigurations)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Kharchevskyi does the order of items matter here? If there are some foreign keys then we probably need to delete the user last?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think in this case - yes.
ClientConfigurationObject has userObject as a reference.
To be sure please check if this cause a crash on log out when there are 2 accounts logged in.

@@ -12,8 +12,21 @@ protocol EnterpriseServerApiType {
func getActiveFesUrl(for email: String) -> Promise<String?>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Changes in this file are very good, thanks

return nil
func getSavedOrganisationalRulesForCurrentUser() -> OrganisationalRules {
guard let configuration = self.clientConfigurationProvider.fetch() else {
assertionFailure("There should not be a user without OrganisationalRules")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does assertionFailure also work for production builds?

@tomholub
tomholub enabled auto-merge (squash) July 9, 2021 14:52
@tomholub
tomholub merged commit d737ff6 into masterJul 9, 2021
@tomholub
tomholub deleted the feature/issue-277-follow-orgrules-to-forbid-backups branch July 9, 2021 15:05
Sign up for freeto 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.

follow OrgRule to forbid backing up keys

3 participants

@ekievsky@Kharchevskyi@tomholub