Skip to content

[PM-29570] feat: Implement password generation with UI in AutoFill extension#2782

Open
fedemkr wants to merge 2 commits into
PM-29569/extension-password-generation-no-uifrom
PM-29570/extension-password-generation-with-ui
Open

[PM-29570] feat: Implement password generation with UI in AutoFill extension#2782
fedemkr wants to merge 2 commits into
PM-29569/extension-password-generation-no-uifrom
PM-29570/extension-password-generation-with-ui

Conversation

@fedemkr

@fedemkr fedemkr commented Jun 12, 2026

Copy link
Copy Markdown
Member

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-29570

📔 Objective

Implements prepareInterface(for:) in CredentialProviderViewController to handle ASGeneratePasswordsRequest with user interaction (iOS 26.2+).

When the OS triggers this entry point, the extension:

  1. Initialises the app with a generatePasswordCredential(_:userInteraction: true) context.
  2. After auth, navigates to the generator via the new VaultRoute.generatePassword route.
  3. A GeneratePasswordExtensionDelegate bridges GeneratorCoordinatorDelegate callbacks to the extension context, mapping GeneratorType + password string to ASGeneratedPassword.Kind (.passphrase, .strong, or .alphanumeric).
  4. On completion, calls extensionContext.completeGeneratePasswordRequest(results:) with the user-selected password.

Warning

Info.plist values has not been updated as we need to wait for #2743 to be merged to have bitwarden/sdk-internal#1102 included to get the appropriate generation rules. Currently the password generation rules are not the ones that come from the OS. The SDK incorporation and update of the Info.plist will be done in a future PR.

📸 Screenshots

Password.generation.with.UI.mov

…tension

Adds prepareInterface(for:) to handle ASGeneratePasswordsRequest with user
interaction (iOS 26.2+). A GeneratePasswordExtensionDelegate bridges
GeneratorCoordinatorDelegate to the extension context, mapping GeneratorType
and the password string to ASGeneratedPassword.Kind (.passphrase, .strong,
.alphanumeric). VaultCoordinator handles the new VaultRoute.generatePassword
route by pushing the generator via the existing stack navigator rather than
presenting modally, avoiding the window-hierarchy crash at auth-completion time.
@fedemkr fedemkr added the ai-review Request a Claude code review label Jun 12, 2026
@github-actions github-actions Bot added app:password-manager Bitwarden Password Manager app context t:feature labels Jun 12, 2026
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR implements the iOS 26.2+ prepareInterface(for: ASGeneratePasswordsRequest) entry point in the AutoFill extension and adds a corresponding VaultRoute.generatePassword route. A new GeneratePasswordExtensionDelegate bridges GeneratorCoordinatorDelegate callbacks to CredentialProviderExtensionDelegate, mapping GeneratorType and the generated password to ASGeneratedPassword.Kind. The implementation follows the established patterns from the save-password and FIDO2 flows, uses correct @available annotations throughout, and includes coverage in CredentialProviderContextTests (migrated to Swift Testing), VaultCoordinatorTests, AppProcessorTests, and the new GeneratePasswordExtensionDelegateTests.

Code Review Details

No findings.

The hardcoded PasswordGeneratorRequest parameters in AppProcessor.generatePasswordCredential(request:), the .alphanumeric kind in CredentialProviderViewController.generatePassword(request:), and the special-character heuristic in GeneratePasswordExtensionDelegate.didCompleteGenerator(for:with:) are each marked with TODO: PM-29569 and gated behind a still-disabled SupportsGeneratePasswordCredentials Info.plist key. The PR description's warning block correctly notes that SDK rule mapping (bitwarden/sdk-internal#1102) and Info.plist enablement will land in a follow-up after #2743 is merged, so the placeholder logic is not reachable in production builds.

@fedemkr fedemkr marked this pull request as ready for review June 12, 2026 14:38
@fedemkr fedemkr requested review from a team and matt-livefront as code owners June 12, 2026 14:38
@@ -0,0 +1,88 @@
import AuthenticationServices
import XCTest

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.

⛏️ Want to convert this to Swift Testing?

@fedemkr fedemkr Jun 17, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As far as I know I can't, as we would require @availability check at the suite level (given var subject: GeneratePasswordExtensionDelegate!) and that's not possible for the time being. See swiftlang/swift-testing#608

///
@available(iOSApplicationExtension 26.2, *)
public func generatePasswordCredential(request: any GeneratePasswordRequestProxy) async throws -> String {
try await unlockVaultWithNeverlockKey()

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 the vault need to be unlocked to generate a password? Or is this needed for something else?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've asked Product because if we need to save the password in the password generator history, then we need to unlock the vault. Otherwise it wouldn't be necessary.

Comment on lines +56 to +57
/// A route to the generate password screen in the autofill extension.
case generatePassword

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.

🤔 If this is something that wouldn't ever be used standalone, and only used with the extension, I wonder if we should name it to be specific to the extension?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it could potentially be used with AppIntents if we were to integrate the UI somehow there. Also I believe that given that it's in the VaultRoute it doesn't matter whether that is for the extension or for whatever else, it just tells what's the route. I can see that I may need to remove the comment of "autofill extension" on the comment though. Would that be fine or would you still like me to rename it?

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.

I guess there was two things that prompted my initial question. 1) the comment "in the autofill extension", which could be removed. But 2) showGeneratePassword() requires appExtensionDelegate to be set, which kind of limits it to being used in the extension, at least how it's set up today.

See my other comment though, if this route just displays the generator as the root view, instead of showing it on/over the vault list, I feel like it would be better to promote this to AppRoute, since that would better match the view hierarchy of how it's displayed.

stackNavigator: stackNavigator,
).asAnyCoordinator()
coordinator.start()
coordinator.navigate(to: .generator(staticType: .password))

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.

🤔 Given that we're essentially bypassing the vault here and just showing the generator, would it make sense to add a generator route to AppRoute and have AppCoordinator handle displaying the generator? Is that more or less complex than using the vault coordinator?

@fedemkr fedemkr changed the base branch from main to PM-29569/extension-password-generation-no-ui June 17, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review app:password-manager Bitwarden Password Manager app context t:feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants