-
Notifications
You must be signed in to change notification settings - Fork 125
feat: Implement UseUserAccessGroup for iOS #1756
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
Conversation
This commit introduces the `UseUserAccessGroup` method in the Firebase C++ Authentication SDK. This method allows developers to specify a user access group for keychain operations on iOS, enabling keychain sharing between apps from the same developer. It wraps the `[FIRAuth useUserAccessGroup:error:]` Objective-C method. - Added `Auth::UseUserAccessGroup(const char* access_group)` to the public API in `firebase/auth.h`. - Implemented the method for iOS in `auth_ios.mm`, calling the corresponding FIRAuth method and handling potential errors. - Provided no-op stub implementations for Android and desktop platforms, as the functionality is iOS-specific. The method returns `kAuthErrorNone` on success or if it's a no-op on non-iOS platforms. On iOS, it returns an appropriate `AuthError` if the underlying Objective-C method reports an error.
auth/src/android/auth_android.cc
Outdated
@@ -670,6 +670,11 @@ void Auth::UseEmulator(std::string host, uint32_t port) { | |||
SetEmulatorJni(auth_data_, host.c_str(), port); | |||
} | |||
|
|||
AuthError Auth::UseUserAccessGroup(const char* access_group) { | |||
// No-op on Android. | |||
return kAuthErrorNone; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return Unimplemented instead of None
auth/src/ios/auth_ios.mm
Outdated
@@ -590,6 +590,26 @@ void SignInCallback(FIRUser *_Nullable user, NSError *_Nullable error, | |||
SetEmulatorJni(auth_data_, host.c_str(), port); | |||
} | |||
|
|||
AuthError Auth::UseUserAccessGroup(const char* access_group) { | |||
if (!auth_data_) { | |||
return kAuthErrorNone; // Or appropriate error if auth_data_ is unexpectedly null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return Not Initialized error
FIRAuth* fir_auth = AuthImpl(auth_data_); | ||
NSString* ns_access_group = nil; | ||
if (access_group) { | ||
ns_access_group = [NSString stringWithUTF8String:access_group]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle an empty string too
This commit incorporates feedback for the `UseUserAccessGroup` method: - Stub implementations for Android and desktop now return `kAuthErrorUnimplemented` instead of `kAuthErrorNone`. - The iOS implementation now returns `kAuthErrorUninitialized` if `auth_data_` is null. - The iOS implementation now treats an empty string for `access_group` the same as `nullptr` (passing `nil` to the Objective-C method).
This commit introduces the
UseUserAccessGroup
method in the Firebase C++ Authentication SDK.This method allows developers to specify a user access group for keychain operations on iOS, enabling keychain sharing between apps from the same developer. It wraps the
[FIRAuth useUserAccessGroup:error:]
Objective-C method.Auth::UseUserAccessGroup(const char* access_group)
to the public API infirebase/auth.h
.auth_ios.mm
, calling the corresponding FIRAuth method and handling potential errors.The method returns
kAuthErrorNone
on success or if it's a no-op on non-iOS platforms. On iOS, it returns an appropriateAuthError
if the underlying Objective-C method reports an error.Description
Testing
Type of Change
Place an
x
the applicable box:Notes
Release Notes
section ofrelease_build_files/readme.md
.