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

fix: save enrollment details to local keystore #599

Merged
merged 38 commits into from
Jul 25, 2024

Conversation

murali-shris
Copy link
Member

@murali-shris murali-shris commented Jun 18, 2024

Closes #556
Enroll details are needed in local storage for at_client to perform enrollment authorization checks for local secondary verbs. While we started implementing authorization checks in at_client, we wanted to use enroll:fetch instead of local key to get enrollment details. But enroll:fetch approach will not work for 1) offline at_client 2) every verb operation will result in remote call. So we decided to store a local key for enrollment details

- What I did

  • Store enrollment details on LocalSecondary after approval and successful auth using a new enrollment
  • Handle edge cases, when null SelfEncryptionKey or EncryptionPrivateKey is received from server
  • Changes to OnboardingService.close() :
    • call AtLookup.close() only if AtLookup.isConnectionAvailable is true (to NOT trigger the null exception)
    • Also close atClient.notificationService as this might keep a monitor connection running in the background in some cases
  • Changed OnboardingService._readAtKeysFile () to visibleForTesting
  • introduced a setter for enrollmentBase to allow injection of mocks (only visibleForTesting)
  • Formatted method docs
  • Some refactoring to support mocking

- How to verify it

  • unit tests and functional tests added to assert the changes

- Description for the changelog

fix: save enrollment details to local keystore

@murali-shris murali-shris marked this pull request as ready for review June 18, 2024 07:01
@murali-shris murali-shris marked this pull request as draft June 18, 2024 07:02
@srieteja srieteja marked this pull request as ready for review June 24, 2024 11:10
@srieteja srieteja requested a review from sitaram-kalluri June 26, 2024 07:20
sitaram-kalluri
sitaram-kalluri previously approved these changes Jul 1, 2024
@srieteja srieteja requested a review from sitaram-kalluri July 17, 2024 15:53
@srieteja
Copy link
Contributor

waiting for #606 to be merged into this branch.

test: add couple of functional tests related to APKAM
@gkc
Copy link
Contributor

gkc commented Jul 19, 2024

waiting for #606 to be merged into this branch.

#606 has been merged to trunk

@gkc
Copy link
Contributor

gkc commented Jul 19, 2024

waiting for #606 to be merged into this branch.

#606 has been merged to trunk

@srieteja I'll resolve the merge conflicts and merge trunk into this branch

…ils_new

# Conflicts:
#	packages/at_onboarding_cli/lib/src/onboard/at_onboarding_service_impl.dart
@srieteja
Copy link
Contributor

@gkc once the conflicts are resolved, functional tests will fail as a result of changes. Working on updating them

@gkc
Copy link
Contributor

gkc commented Jul 19, 2024

@gkc once the conflicts are resolved, functional tests will fail as a result of changes. Working on updating them

I've fixed all the ripple effects and pushed to the branch

Copy link
Contributor

@gkc gkc left a comment

Choose a reason for hiding this comment

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

  1. The PR description explains what has been done, but not why. Please add an explanation of the problem that is being addressed here (or link to a ticket which has that explanation).
  2. This PR handles writing to the keystore ... is the intent that there will be code elsewhere which reads this information from the keystore?
  3. The information is currently written to '${enrollmentResponse.enrollmentId}.new.enrollments.__manage${atClient!.getCurrentAtSign()}'
  • Given that this is purely for local client-side use, we should use a local key
  • And we should not be using the __manage namespace

@murali-shris
Copy link
Member Author

murali-shris commented Jul 19, 2024

  1. The PR description explains what has been done, but not why. Please add an explanation of the problem that is being addressed here (or link to a ticket which has that explanation).
  2. This PR handles writing to the keystore ... is the intent that there will be code elsewhere which reads this information from the keystore?
  3. The information is currently written to '${enrollmentResponse.enrollmentId}.new.enrollments.__manage${atClient!.getCurrentAtSign()}'
  • Given that this is purely for local client-side use, we should use a local key
  • And we should not be using the __manage namespace
  1. added to the PR description
  2. the local key which stores the enrollment details will be read from LocalSecondary --> isEnrollmentAuthorizedForOperation(..) in at_client
  3. agreed. Will make the change

@srieteja srieteja requested a review from gkc July 25, 2024 12:42

// The put operation is expected to fail as the new enrollment only has
// access to wavi namespace
expect(() => client?.put(buzzKey, 'value'), throwsA(predicate((e) {
expect(() async => await client?.put(buzzKey, 'value'),
Copy link
Contributor

Choose a reason for hiding this comment

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

it's cleaner to do await expectLater(...)

Copy link
Contributor

@gkc gkc left a comment

Choose a reason for hiding this comment

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

Please un-skip the test(s) in test/at_onboarding_cli_test.dart

Copy link
Contributor

@gkc gkc left a comment

Choose a reason for hiding this comment

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

LGTM

@srieteja srieteja merged commit 922195b into trunk Jul 25, 2024
11 checks passed
@srieteja srieteja deleted the save_enrollment_details_new branch July 25, 2024 16:06
Sign up for free to 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.

feat: at_onboarding_cli store enrollment details in local secondary after apkam auth is success
4 participants