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

Authorization Interactor #356

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

micbakos-rdx
Copy link
Contributor

@micbakos-rdx micbakos-rdx commented Jan 24, 2025

A new interactor responsible for asking the user through the host to authorise an operation. Such operation is called AuthorizationPurpose and it currently supports variants for creating one or batch accounts, or one or batch personas.If the user rejects authorization, then such operation does not mutate the profile, nor does consume the cache.

The user can either AuthorizationResponse::Authorized or AuthorizationResponse::Rejected.

Note that, I also changed the name of the error used to be called SigningRejected to HostInteractionAborted. It can be thrown by hosts when answering to the interactor callbacks, and returned back to the method that initiated the interaction. It is a "common result" that hosts receive and can just reset the UI for the user to try again.

@micbakos-rdx micbakos-rdx added Swift 🍏 Changes in Swift Sargon UniFFI 🦄 Changes in UniFFI exported APIs labels Jan 24, 2025
@micbakos-rdx micbakos-rdx self-assigned this Jan 24, 2025
match authorization {
AuthorizationResponse::Rejected => {
debug!("User rejected authorization, aborting.");
return Err(CommonError::HostInteractionAborted);
Copy link
Contributor

Choose a reason for hiding this comment

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

Good! We auth before consuming instances in Cache, perfect

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have any unit test that fails if you would move up consume to be called before auth?

Otherwise I prefer it if you can add such a unit test :)

Typically create an account, Alice

Try creating account and abort/reject.

Try crating account, Bob, again this time Auth.

Assert that Bobs VECI derivation entity Index is that of Alice+1 and not +2.

Should do it right?

And then analogously for Persona

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, will try that, indeed adds value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Take a look at the last commits. I had to change a bit the API of the TestAuthorizationInteractor.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not pushed yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, sorry waiting for pre-commit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can check now

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks great

Copy link
Contributor

@CyonAlexRDX CyonAlexRDX left a comment

Choose a reason for hiding this comment

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

LGTM, just missing test which fails If we were to refactor order of things

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.59%. Comparing base (22a4d57) to head (d356495).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #356   +/-   ##
=======================================
  Coverage   92.59%   92.59%           
=======================================
  Files        1169     1170    +1     
  Lines       26153    26248   +95     
  Branches       81       81           
=======================================
+ Hits        24217    24305   +88     
- Misses       1925     1932    +7     
  Partials       11       11           
Flag Coverage Δ
kotlin 97.73% <ø> (ø)
rust 92.20% <100.00%> (+<0.01%) ⬆️
swift 93.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@micbakos-rdx micbakos-rdx added Rust 🦀 Changes in Rust Sargon Kotlin 🤖 Changes in Kotlin Sargon labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kotlin 🤖 Changes in Kotlin Sargon Rust 🦀 Changes in Rust Sargon Swift 🍏 Changes in Swift Sargon UniFFI 🦄 Changes in UniFFI exported APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants