-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(AuthUIConfiguration): implement configuration model, DSL builder and tests #2216
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
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a62097d
feat(AuthUIConfiguration): implement configuration model, DSL builder…
demolaf bf7c10b
Merge branch 'version-10.0.0-dev' of https://github.com/firebase/Fire…
demolaf 2c563bd
refactor: use OAuthProvider base class for common properties
demolaf 1ba20ae
feat: add Provider enum class for provider ids
demolaf 63c8e18
feat: setup default provider styles for each provider
demolaf a5a944a
test: added builder validation logic from old auth library and tests
demolaf 19787df
refactor: changes in API design docs
demolaf 7e010e4
test: fix AuthUIConfiguration constructor test
demolaf 4c9cc5e
Merge branch 'version-10.0.0-dev' of github.com:demolaf/FirebaseUI-An…
demolaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
270 changes: 270 additions & 0 deletions
270
auth/src/main/java/com/firebase/ui/auth/compose/configuration/AuthProvider.kt
This file contains hidden or 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,270 @@ | ||
| /* | ||
| * Copyright 2025 Google Inc. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
| * in compliance with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under the | ||
| * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.firebase.ui.auth.compose.configuration | ||
|
|
||
| import android.graphics.Color | ||
| import androidx.compose.ui.graphics.vector.ImageVector | ||
| import com.google.firebase.auth.ActionCodeSettings | ||
|
|
||
| @AuthUIConfigurationDsl | ||
| class AuthProvidersBuilder { | ||
| private val providers = mutableListOf<AuthProvider>() | ||
|
|
||
| fun provider(provider: AuthProvider) { | ||
| providers.add(provider) | ||
| } | ||
|
|
||
| internal fun build(): List<AuthProvider> = providers.toList() | ||
| } | ||
|
|
||
| /** | ||
| * Base sealed class for authentication providers. | ||
| */ | ||
| sealed class AuthProvider() { | ||
| /** | ||
| * Email/Password authentication provider configuration. | ||
| */ | ||
| data class Email( | ||
| /** | ||
| * Requires the user to provide a display name. Defaults to true. | ||
| */ | ||
| val requireDisplayName: Boolean = true, | ||
|
|
||
| /** | ||
| * Enables email link sign-in, Defaults to false. | ||
| */ | ||
| val enableEmailLinkSignIn: Boolean = false, | ||
|
|
||
| /** | ||
| * Settings for email link actions. | ||
| */ | ||
| val actionCodeSettings: ActionCodeSettings?, | ||
|
|
||
| /** | ||
| * Allows new accounts to be created. Defaults to true. | ||
| */ | ||
| val allowNewAccounts: Boolean = true, | ||
|
|
||
| /** | ||
| * The minimum length for a password. Defaults to 6. | ||
| */ | ||
| val minimumPasswordLength: Int = 6, | ||
|
|
||
| /** | ||
| * A list of custom password validation rules. | ||
| */ | ||
| val passwordValidationRules: List<PasswordRule> | ||
| ) : AuthProvider() | ||
|
|
||
| /** | ||
| * Phone number authentication provider configuration. | ||
| */ | ||
| data class Phone( | ||
| /** | ||
| * The default country code to pre-select. | ||
| */ | ||
| val defaultCountryCode: String?, | ||
|
|
||
| /** | ||
| * A list of allowed country codes. | ||
| */ | ||
| val allowedCountries: List<String>?, | ||
|
|
||
| /** | ||
| * The expected length of the SMS verification code. Defaults to 6. | ||
| */ | ||
| val smsCodeLength: Int = 6, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this verified against what we get from Firebase by default?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got this from the API Design docs, is there somewhere else I could check this from? |
||
|
|
||
| /** | ||
| * The timeout in seconds for receiving the SMS. Defaults to 60L. | ||
| */ | ||
| val timeout: Long = 60L, | ||
|
|
||
| /** | ||
| * Enables instant verification of the phone number. Defaults to true. | ||
| */ | ||
| val enableInstantVerification: Boolean = true, | ||
|
|
||
| /** | ||
| * Enables automatic retrieval of the SMS code. Defaults to true. | ||
| */ | ||
| val enableAutoRetrieval: Boolean = true | ||
| ) : AuthProvider() | ||
|
|
||
| /** | ||
| * Google Sign-In provider configuration. | ||
| */ | ||
| data class Google( | ||
| /** | ||
| * The list of scopes to request. | ||
| */ | ||
| val scopes: List<String>, | ||
|
|
||
| /** | ||
| * The OAuth 2.0 client ID for your server. | ||
| */ | ||
| val serverClientId: String?, | ||
|
|
||
| /** | ||
| * Requests an ID token. Default to true. | ||
| */ | ||
| val requestIdToken: Boolean = true, | ||
|
|
||
| /** | ||
| * Requests the user's profile information. Defaults to true. | ||
| */ | ||
| val requestProfile: Boolean = true, | ||
|
|
||
| /** | ||
| * Requests the user's email address. Defaults to true. | ||
| */ | ||
| val requestEmail: Boolean = true | ||
| ) : AuthProvider() | ||
|
|
||
| /** | ||
| * Facebook Login provider configuration. | ||
| */ | ||
| data class Facebook( | ||
| /** | ||
| * The list of scopes (permissions) to request. Defaults to email and public_profile. | ||
| */ | ||
| val scopes: List<String> = listOf("email", "public_profile"), | ||
|
|
||
| /** | ||
| * if true, enable limited login mode. Defaults to false. | ||
| */ | ||
| val limitedLogin: Boolean = false | ||
| ) : AuthProvider() | ||
|
|
||
| /** | ||
| * Twitter/X authentication provider configuration. | ||
| */ | ||
| data class Twitter( | ||
| /** | ||
| * A map of custom OAuth parameters. | ||
| */ | ||
| val customParameters: Map<String, String> | ||
| ) : AuthProvider() | ||
|
|
||
| /** | ||
| * Github authentication provider configuration. | ||
| */ | ||
| data class Github( | ||
| /** | ||
| * The list of scopes to request. Defaults to user:email. | ||
| */ | ||
| val scopes: List<String> = listOf("user:email"), | ||
|
|
||
| /** | ||
| * A map of custom OAuth parameters. | ||
| */ | ||
| val customParameters: Map<String, String> | ||
| ) : AuthProvider() | ||
|
|
||
| /** | ||
| * Microsoft authentication provider configuration. | ||
| */ | ||
| data class Microsoft( | ||
| /** | ||
| * The list of scopes to request. Defaults to openid, profile, email. | ||
| */ | ||
| val scopes: List<String> = listOf("openid", "profile", "email"), | ||
|
|
||
| /** | ||
| * The tenant ID for Azure Active Directory. | ||
| */ | ||
| val tenant: String?, | ||
|
|
||
| /** | ||
| * A map of custom OAuth parameters. | ||
| */ | ||
| val customParameters: Map<String, String> | ||
demolaf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) : AuthProvider() | ||
|
|
||
| /** | ||
| * Yahoo authentication provider configuration. | ||
| */ | ||
| data class Yahoo( | ||
| /** | ||
| * The list of scopes to request. Defaults to openid, profile, email. | ||
| */ | ||
| val scopes: List<String> = listOf("openid", "profile", "email"), | ||
|
|
||
| /** | ||
| * A map of custom OAuth parameters. | ||
| */ | ||
| val customParameters: Map<String, String> | ||
| ) : AuthProvider() | ||
|
|
||
| /** | ||
| * Apple Sign-In provider configuration. | ||
| */ | ||
| data class Apple( | ||
| /** | ||
| * The list of scopes to request. Defaults to name and email. | ||
| */ | ||
| val scopes: List<String> = listOf("name", "email"), | ||
|
|
||
| /** | ||
| * The locale for the sign-in page. | ||
| */ | ||
| val locale: String?, | ||
|
|
||
| /** | ||
| * A map of custom OAuth parameters. | ||
| */ | ||
| val customParameters: Map<String, String> | ||
| ) : AuthProvider() | ||
|
|
||
| /** | ||
| * Anonymous authentication provider. It has no configurable properties. | ||
| */ | ||
| object Anonymous : AuthProvider() | ||
|
|
||
| /** | ||
| * A generic OAuth provider for any unsupported provider. | ||
| */ | ||
| data class GenericOAuth( | ||
| /** | ||
| * The provider ID as configured in the Firebase console. | ||
| */ | ||
| val providerId: String, | ||
|
|
||
| /** | ||
| * The list of scopes to request. | ||
| */ | ||
| val scopes: List<String>, | ||
|
|
||
| /** | ||
| * A map of custom OAuth parameters. | ||
| */ | ||
| val customParameters: Map<String, String>, | ||
|
|
||
| /** | ||
| * The text to display on the provider button. | ||
| */ | ||
| val buttonLabel: String, | ||
|
|
||
| /** | ||
| * An optional icon for the provider button. | ||
| */ | ||
| val buttonIcon: ImageVector?, | ||
|
|
||
| /** | ||
| * An optional background color for the provider button. | ||
| */ | ||
| val buttonColor: Color? | ||
| ) : AuthProvider() | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.