Skip to content

Implement UseUserAccessGroup for Firebase Auth C++ SDK #1757

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 3 commits into from

Conversation

jonsimantov
Copy link
Contributor

This commit adds the UseUserAccessGroup method to the Firebase Auth C++ SDK.

  • On iOS, this method calls the native [FIRAuth useUserAccessGroup:error:] method to specify a user access group for iCloud keychain access.
  • On other platforms (desktop, Android), this method is a no-op and returns kAuthErrorNone as it's an iOS-only feature.

Public API has been added to firebase::auth::Auth in auth.h, with implementations in auth_ios.mm (iOS) and auth_desktop.cc (stub for other 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 adds the UseUserAccessGroup method to the Firebase Auth C++ SDK.

- On iOS, this method calls the native [FIRAuth useUserAccessGroup:error:] method to specify a user access group for iCloud keychain access.
- On other platforms (desktop, Android), this method is a no-op and returns kAuthErrorNone as it's an iOS-only feature.

Public API has been added to firebase::auth::Auth in auth.h, with implementations in auth_ios.mm (iOS) and auth_desktop.cc (stub for other 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.

We need an Android stub as well.

/// This method is only functional on iOS. On other platforms, it is a no-op
/// and will always return `kAuthErrorNone`.
///
/// If you are using iCloud keychain synchronization, you will need to call
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove this sentence.

/// this method to set the user access group.
///
/// @param[in] access_group The user access group to use. Set to `nullptr` or
/// an empty string to use the default 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.

Let's pass in an empty string verbatim instead of treating it as nil.

Copy link
Contributor Author

@jonsimantov jonsimantov left a comment

Choose a reason for hiding this comment

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

Could you add a VERY short test to the Analytics integration test that just runs this method to confirm it runs?

@@ -608,5 +608,23 @@ void DisableTokenAutoRefresh(AuthData *auth_data) {}
void InitializeTokenRefresher(AuthData *auth_data) {}
void DestroyTokenRefresher(AuthData *auth_data) {}

AuthError Auth::UseUserAccessGroup(const char* access_group_str) {
if (!auth_data_) {
return kAuthErrorUninitialized;
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 such error, this one doesn't exist, please check the AuthError enum and suggest a better option.

- Added Android stub for UseUserAccessGroup.
- Updated Doxygen comments in auth.h for clarity and accuracy regarding empty string handling.
- Modified iOS implementation to pass empty strings verbatim to the native SDK.
- Corrected error code used in iOS implementation when auth_data_ is null (kAuthErrorFailure instead of kAuthErrorUninitialized).
- Added a basic smoke test to integration_test.cc for iOS to ensure UseUserAccessGroup can be called.
The test now calls UseUserAccessGroup without checking its return value.
This is to prevent failures in environments where keychain sharing might not be configured, as the primary goal of this test is to ensure the method call itself doesn't crash on iOS.
@@ -1513,4 +1513,18 @@ TEST_F(FirebaseAuthTest, TestLinkFederatedProviderBadProviderIdFails) {

#endif // defined(ENABLE_OAUTH_TESTS)

#if TARGET_OS_IPHONE
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we have this stubbed out on other platforms, let's make sure that works and run this test on all platforms.

///
/// @param[in] access_group The user access group to use. Set to `nullptr`
/// to use the default access group. An empty string will be passed as an
/// empty string.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need to call out that the empty string is passed in special.

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.

1 participant