-
Notifications
You must be signed in to change notification settings - Fork 4k
feat(ui): add firebase_ui_auth and oauth providers #9343
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
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
339835d
feat(ui): add firebase_ui_auth and oauth providers
lesnitsky 8320499
chore(ui): fix unit tests
lesnitsky 52e9595
chore(ui): fix e2e tests
lesnitsky 0cb2ec4
chore(ui): fix example dependency
lesnitsky 9fffd49
chore(ui): fix OAuthProviderButton test
lesnitsky a4c4f9a
chore(ui): fix email verification domain
lesnitsky 5dec282
fix(ui): fix keyboard overlapping sign in screen ui
lesnitsky 1ae1248
feat(ui): reload user when app goes back to foreground
lesnitsky 358559d
fix(ui): fix reauthenticate dialog
lesnitsky a5ee4c0
fix(ui): fix dependencies
lesnitsky c0af2d6
fix(ui): fix default resizeToAvoidBottomInset
lesnitsky a9b1f99
fix(ui): fix review comments
lesnitsky dedc53c
fix(ui): use Text.rich instead of RichText
lesnitsky 9051ce0
fix(ui): fix phone and sms code input for RTL locales
lesnitsky d70108c
fix(ui): fix sign in action button on delete account action
lesnitsky a113bdd
fix(ui): fix description, repository and homepage URLs
lesnitsky 8affb5e
Merge branch 'master' into ui/auth
lesnitsky 79261f2
chore(ui): trigger CI
lesnitsky e8e9388
docs(ui_auth): fix review commets
lesnitsky 83e5bfb
chore(ui_auth): drop unnecessary assets folder
lesnitsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
/pubspec.lock | ||
**/doc/api/ | ||
.dart_tool/ | ||
.packages | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: f1875d570e39de09040c8f79aa13cc56baab8db1 | ||
channel: stable | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## 1.0.0-dev.0 | ||
|
||
- Bump "firebase_ui_auth" to `1.0.0-dev.0`. | ||
|
||
## 0.0.1 | ||
|
||
* TODO: Describe initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Copyright 2017, the Chromium project authors. All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Firebase UI Auth | ||
|
||
[](https://pub.dev/packages/firebase_ui_auth) | ||
|
||
Firebase UI Auth is a set of Flutter widgets and utilities designed to help you build and integrate your user interface with Firebase Authentication. | ||
|
||
> Please contribute to the [discussion](https://github.com/firebase/flutterfire/discussions/6978) with feedback. | ||
|
||
## Platoform support | ||
|
||
| Feature/platform | Android | iOS | Web | macOS | Windows | Linux | | ||
| ------------------ | ------- | --- | ---------------- | ---------------- | ---------------- | ---------------- | | ||
| Email | ✓ | ✓ | ✓ | ✓ | ✓ <sup>(1)</sup> | ✓ <sup>(1)</sup> | | ||
| Phone | ✓ | ✓ | ✓ | ╳ | ╳ | ╳ | | ||
| Email link | ✓ | ✓ | ╳ | ╳ | ╳ | ╳ | | ||
| Email verification | ✓ | ✓ | ✓ <sup>(2)</sup> | ✓ <sup>(2)</sup> | ✓ <sup>(1)</sup> | ✓ <sup>(1)</sup> | | ||
| Sign in with Apple | ╳ | ✓ | ╳ | ✓ | ╳ | ╳ | | ||
| Google Sign in | ✓ | ✓ | ✓ | ✓ | ✓ <sup>(1)</sup> | ✓ <sup>(1)</sup> | | ||
| Twitter Login | ✓ | ✓ | ✓ | ✓ | ✓ <sup>(1)</sup> | ✓ <sup>(1)</sup> | | ||
| Facebook Sign in | ✓ | ✓ | ✓ | ✓ | ✓ <sup>(1)</sup> | ✓ <sup>(1)</sup> | | ||
|
||
1. Available with [flutterfire_desktop](https://github.com/invertase/flutterfire_desktop) | ||
2. No deep-linking into app, so email verification link opens a web page | ||
|
||
## Installation | ||
|
||
```sh | ||
flutter pub add firebase_ui_auth | ||
``` | ||
|
||
## Getting Started | ||
|
||
Here's a quick example that shows how to build a `SignInScreen` and `ProfileScreen` in your app | ||
|
||
```dart | ||
import 'package:flutter/material.dart'; | ||
import 'package:firebase_auth/firebase_auth.dart'; | ||
import 'package:firebase_ui_auth/firebase_ui_auth.dart'; | ||
|
||
class MyApp extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
const providers = [EmailAuthProvider()]; | ||
|
||
return MaterialApp( | ||
initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile', | ||
routes: { | ||
'/sign-in': (context) { | ||
return SignInScreen( | ||
providers: providers, | ||
actions: [ | ||
AuthStateChangeAction<SignedIn>((context, state) { | ||
Navigator.pushReplacementNamed(context, '/profile'); | ||
}), | ||
], | ||
); | ||
}, | ||
'/profile': (context) { | ||
return ProfileScreen( | ||
providers: providers, | ||
actions: [ | ||
SignedOutAction((context) { | ||
Navigator.pushReplacementNamed(context, '/sign-in'); | ||
}), | ||
], | ||
); | ||
}, | ||
}, | ||
); | ||
} | ||
} | ||
``` | ||
|
||
Learn more [here](https://github.com/firebase/flutterfire/packages/firebase_ui_auth/doc/README.md). | ||
|
||
## Roadmap / Features | ||
|
||
- For issues, please create a new [issue on the repository](https://github.com/firebase/flutterfire/issues). | ||
- For feature requests, & questions, please participate on the [discussion](https://github.com/firebase/flutterfire/discussions/6978) thread. | ||
- To contribute a change to this plugin, please review our [contribution guide](https://github.com/firebase/flutterfire/blob/master/CONTRIBUTING.md) and open a [pull request](https://github.com/firebase/flutterfire/pulls). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Firebase UI for authentication | ||
|
||
Firebase UI for authentication provides a simple and easy way to implement authentication in your Flutter app. | ||
The library provides fully featured UI screens to drop into new or existing applications, along with | ||
lower level abstractions for developers looking for tighter control. | ||
|
||
## Installation | ||
|
||
Activate FlutterFire CLI | ||
|
||
```sh | ||
dart pub global activate flutterfire_cli | ||
``` | ||
|
||
Install dependencies | ||
|
||
```sh | ||
flutter pub add firebase_core | ||
flutter pub add firebase_auth | ||
# required for email link sign in and email verification | ||
flutter pub add firebase_dynamic_links | ||
flutter pub add firebase_ui_auth | ||
``` | ||
|
||
## Configuration | ||
|
||
Configure firebase using cli: | ||
|
||
```sh | ||
flutterfire configure | ||
``` | ||
|
||
Initialize firebase app: | ||
|
||
```dart | ||
void main() { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
|
||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); | ||
} | ||
``` | ||
|
||
## macOS entitlements | ||
|
||
If you're building for macOS, make sure to add necessary entitlements. Learn more [from the official Flutter documentation](https://docs.flutter.dev/development/platform-integration/macos/building). | ||
|
||
## Next steps | ||
|
||
To understand what Firebase UI for authentication offers, the following documentation pages walk you through the various topics on | ||
how to use the package within your Flutter app. | ||
|
||
- Available auth providers: | ||
|
||
- [EmaiAuthProvider](./providers/email.md) - allows registering and signing in using email and password. | ||
- [EmailLinkAuthProvider](./providers/email-link.md) - allows registering and signing in using a link sent to email. | ||
- [PhoneAuthProvider](./providers/phone.md) - allows registering and signing in using a phone number | ||
- [UniversalEmailSignInProvider](./providers/universal-email-sign-in.md) - gets all connected auth providers for a given email. | ||
- [OAuth](./providers/oauth.md) | ||
|
||
- [Localization](../../firebase_ui_localizations/README.md) | ||
- [Theming](./theming.md) | ||
- [Navigation](./navigation.md) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+71.7 KB
packages/firebase_ui_auth/doc/images/ui-auth-email-google-provider.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.6 KB
packages/firebase_ui_auth/doc/images/ui-auth-theming-outline-border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+173 KB
packages/firebase_ui_auth/doc/images/ui-google-provider-client-id copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Navigation | ||
|
||
Firebase UI uses Flutter navigation capabilities to navigate between pages. | ||
|
||
By default, it uses "Navigator 1." when a new screen needs to be shown as a result of user interaction (`Navigator.push(context, route)` is used). | ||
|
||
For applications using the standard navigation APIs, navigation will work out of the box and require no intervention. However, for applications using | ||
a custom routing package, you will need to override the default navigation actions to integrate with your routing strategy. | ||
|
||
## Custom routing | ||
|
||
For this example, the application will create [named routes](https://docs.flutter.dev/cookbook/navigation/named-routes). Within the UI logic, we can | ||
override the default actions (e.g. signing in or signing out) the UI performs to instead integrate with those named routes. | ||
|
||
First, we define the root route that checks for authentication state and renders a `SignInScreen` or `ProfileScreen`: | ||
|
||
```dart | ||
class MyApp extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
const providers = [EmailProvider()]; | ||
|
||
return MaterialApp( | ||
initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile', | ||
routes: { | ||
'/sign-in': (context) => SignInScreen(providers: providers), | ||
'/profile': (context) => ProfileScreen(providers: providers), | ||
}, | ||
); | ||
} | ||
} | ||
``` | ||
|
||
By default, when a user triggers a sign-in via the `SignInScreen`, no action default occurs. Since we are not subscribing to the authentication | ||
state (via the `authStateChanges` API), we need to manually force the navigator to push to a new screen (the `/profile` route). | ||
|
||
To do this, add a `AuthStateChangeAction` action to the `actions` property of the widget, for example for a successful sign in: | ||
|
||
```dart | ||
SignInScreen( | ||
actions: [ | ||
AuthStateChangeAction<SignedIn>((context, _) { | ||
Navigator.of(context).pushReplacementNamed('/profile'); | ||
}), | ||
], | ||
// ... | ||
) | ||
``` | ||
|
||
You could also react to the user signing out in a similar manner: | ||
|
||
```dart | ||
ProfileScreen( | ||
actions: [ | ||
SignedOutAction((context, _) { | ||
Navigator.of(context).pushReplacementNamed('/sign-in'); | ||
}), | ||
], | ||
// ... | ||
) | ||
``` | ||
|
||
Some UI widgets also come with internal actions which triggers navigation to a new screen. For example the `SignInScreen` widget allows users to | ||
reset their password by pressing the "Forgot Password" button, which internally navigates to a `ForgotPasswordScreen`. To override this action and | ||
navigate to a named route, provide the `actions` list with a `ForgotPasswordAction`: | ||
|
||
```dart | ||
class MyApp extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
const providers = [EmailProvider()]; | ||
|
||
return MaterialApp( | ||
initialRoute: FirebaseAuth.instance.currentUser == null ? '/sign-in' : '/profile', | ||
routes: { | ||
'/sign-in': (context) { | ||
return SignInScreen( | ||
providers: providers, | ||
actions: [ | ||
ForgotPasswordAction((context, email) { | ||
Navigator.of(context).pushNamed( | ||
'/forgot-password', | ||
arguments: {'email': email}, | ||
); | ||
}), | ||
], | ||
); | ||
}, | ||
'/profile': (context) => ProfileScreen(providers: providers), | ||
'/forgot-password': (context) => MyCustomForgotPasswordScreen(), | ||
}, | ||
); | ||
} | ||
} | ||
``` | ||
|
||
To learn more about the available actions, check out the [FirebaseUIActions API reference](https://pub.dev/documentation/firebase_ui_auth/latest/firebase_ui_auth/FirebaseUIActions-class.html). | ||
|
||
## Other topics | ||
|
||
## Other topics | ||
|
||
- [EmaiAuthProvider](./providers/email.md) - allows registering and signing using email and password. | ||
- [EmailLinkAuthProvider](./providers/email-link.md) - allows registering and signing using a link sent to email. | ||
- [PhoneAuthProvider](./providers/phone.md) - allows registering and signing using a phone number | ||
- [UniversalEmailSignInProvider](./providers/universal-email-sign-in.md) - gets all connected auth providers for a given email. | ||
- [OAuth](./providers/oauth.md) | ||
- [Localization](../../firebase_ui_localizations/README.md) | ||
- [Theming](./theming.md) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I can't remember now, but do we need this? I just ran

melos version
and it produced another version:version -
1.0.0-dev.1
🤔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.
I'm not sure how this works either. We've put this manually for the dev release.
Next release should be without
-dev.1
postfix, but rather regular1.0.0
version.I believe this should be done with
--graduate
.As for actual changelog – it'd just mention a stable release and point to the migration guide in docs section.