Skip to content

Add new "Authorization" states and functions to authorize additional scopes.#7306

Draft
mhammond wants to merge 1 commit intomozilla:mainfrom
mhammond:push-mkxvwknxqksu
Draft

Add new "Authorization" states and functions to authorize additional scopes.#7306
mhammond wants to merge 1 commit intomozilla:mainfrom
mhammond:push-mkxvwknxqksu

Conversation

@mhammond
Copy link
Copy Markdown
Member

@mhammond mhammond commented Apr 7, 2026

As @jonalmeida and I were chatting about. @bendk does this look correct to you? @LZoog and @skhamis for some context for our slack messages.

This supports desktop-like flows, where a user is already signed in to (say) Sync, but not wants to authorize "vpn" or "smartwindow".

I used the term "Authorization" to try and reflect we aren't expected to "authenticate" here - we are already authenticated - we typically expect just a confirmation button. I'm not entirely convinced the distinction between "authorize" and "authenticate" is enough, so the names might be confusing - I started with something like "UpgradeScopes" etc. Regardless, better names welcome here.

I've tried to keep the names consistent, which made them verbose. Better names welcome here too.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

Copy link
Copy Markdown
Contributor

@bendk bendk left a comment

Choose a reason for hiding this comment

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

This looks pretty much correct to me, except I think there's one more step to do.

My main takeaway is that these state machines feel overly complicated. It seems like you should be able to add an extra event, add code in a corresponding switch case, and that's it. When we were doing the Android migration and using the state machine tester to verify the code, we were getting some value in exchange. Now, more and more I'm feeling like we could rework this and simplify it.

FxaEvent::CheckAuthorizationStatus => Ok(CheckAuthorizationStatus),
FxaEvent::CallGetProfile => Ok(GetProfile),
FxaEvent::BeginOAuthScopeAuthorizationFlow { scopes, entrypoint } => {
Ok(BeginOAuthFlow { scopes, entrypoint })
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 you'll need a new internal state for this since it should call begin_oauth_scope_authorization_flow() instead of begin_oauth_flow(). Ditto for the complete flow event.

state_machine/internal_machines/mod.rs should get some extra cases to map the new states to the right calls.

@mhammond mhammond force-pushed the push-mkxvwknxqksu branch from 11b1351 to f2e57d0 Compare April 10, 2026 05:49
…scopes.

This supports desktop-like flows, where a user is already signed in to (say) Sync,
but not wants to authorize "vpn" or "smartwindow".

I used the term "Authorization" to try and reflect we aren't expected to "authenticate"
here - we are already authenticated - we typically expect just a confirmation button.
I'm not entirely convinced the distinction between "authorize" and "authenticate" is
enough, so the names might be confusing - I started with something like "UpgradeScopes" etc.
Regardless, better names welcome here.

I've tried to keep the names consistent, which made them verbose.
Better names welcome here too.
@mhammond mhammond force-pushed the push-mkxvwknxqksu branch from f2e57d0 to 735d3d7 Compare April 10, 2026 05:56
@mhammond
Copy link
Copy Markdown
Member Author

https://phabricator.services.mozilla.com/D293447 is the fenix side of this. I think I got the semantics correct for the new flow, but it's hard to know if it doesn't work for that reason or for an fxa reason - I know Lauren mentioned some work needs to be done on the fxa side for this to work. This PR however doesn't seem like a breaking change and should be safe even if it need tweaks - wdyt?

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.

2 participants