Skip to content

Implement UseUserAccessGroup for Firebase Auth C++ SDK #1754

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

Closed
wants to merge 2 commits into from

Conversation

jonsimantov
Copy link
Contributor

This commit introduces the UseUserAccessGroup method to the Firebase Authentication C++ SDK.

This method allows developers to specify a user access group for iCloud keychain access on iOS. It calls the underlying Objective-C method [FIRAuth useUserAccessGroup:error:].

On other platforms (Desktop, Android), this method is a no-op and returns kAuthErrorNone as the feature is iOS-specific.

Key changes:

  • Added UseUserAccessGroup declaration to firebase::auth::Auth in auth/src/include/firebase/auth.h with Doxygen comments.
  • Implemented the iOS-specific logic in auth/src/ios/auth_ios.mm, including error handling and string conversion.
  • Added a stub implementation in auth/src/desktop/auth_desktop.cc for non-iOS platforms.

Description

Provide details of the change, and generalize the change in the PR title above.


Testing

Describe how you've tested these changes. Link any manually triggered Integration tests or CPP binary SDK Packaging Github Action workflows, if applicable.


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Notes

  • Bug fixes and feature changes require an update to the Release Notes section of release_build_files/readme.md.
  • Read the contribution guidelines CONTRIBUTING.md.
  • Changes to the public API require an internal API review. If you'd like to help us make Firebase APIs better, please propose your change in a feature request so that we can discuss it together.

This commit introduces the `UseUserAccessGroup` method to the Firebase
Authentication C++ SDK.

This method allows developers to specify a user access group for iCloud
keychain access on iOS. It calls the underlying Objective-C method
`[FIRAuth useUserAccessGroup:error:]`.

On other platforms (Desktop, Android), this method is a no-op and returns
`kAuthErrorNone` as the feature is iOS-specific.

Key changes:
- Added `UseUserAccessGroup` declaration to `firebase::auth::Auth` in
  `auth/src/include/firebase/auth.h` with Doxygen comments.
- Implemented the iOS-specific logic in `auth/src/ios/auth_ios.mm`,
  including error handling and string conversion.
- Added a stub implementation in `auth/src/desktop/auth_desktop.cc` for
  non-iOS platforms.
@@ -575,6 +575,11 @@ void Auth::UseEmulator(std::string host, uint32_t port) {
auth_impl->assigned_emulator_url.append(std::to_string(port));
}

AuthError Auth::UseUserAccessGroup(const char* access_group) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Android also needs this stub.

return kAuthErrorUninitialized;
}
NSString* access_group_ns_str = nil;
if (access_group_str != nullptr && strlen(access_group_str) > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is a blank string, let's pass it in verbatim instead of nil. Remember to update the docs to reflect this.

if (success) {
return kAuthErrorNone;
} else {
return AuthErrorFromNSError(error);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you double-check which error codes this might return and make sure there are values for all of them in the AuthError enum and the AuthErrorFromNSError function?

This commit addresses feedback from the pull request review for the
UseUserAccessGroup feature:

- Added a stub implementation for Android in `auth_android.cc`.
- Updated iOS implementation in `auth_ios.mm` to pass an empty NSString
  (`@""`) to the native SDK if an empty C++ string is provided.
  `nullptr` still results in `nil` being passed.
- Updated Doxygen comments in `auth.h` to reflect the iOS behavior for
  `nullptr` and empty string inputs more accurately.
- Investigated potential NSError codes for the underlying iOS SDK method.
  Confirmed that `FIRAuthErrorCodeKeychainError` is the most relevant documented
  error, and it is already correctly handled by the existing C++ error
  mapping.
@firebase firebase locked and limited conversation to collaborators Jul 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant