auth0 / auth0-flutter

Auth0 SDK for Flutter
https://pub.dev/documentation/auth0_flutter/latest/
Apache License 2.0
61 stars 41 forks source link

Package does not support multiple domains in Android #265

Closed guy-plentific closed 1 year ago

guy-plentific commented 1 year ago

Checklist

Description

When using this package in Android we have to specify the Auth0 domain in the build.gradle file like: manifestPlaceholders['auth0Domain'] = "xyz.us.auth0.com"

We have multiple domains that we use for dynamically changed namespaces such as EU/US. The particular domain is not known at compile time, and the user can change it on the login page within the app (before they are presented with the Auth0 web-view to login). Because of this we are having difficulty getting login to work using this package.

I did notice there were some similar issues raised for other Auth0 projects:

How can we overcome this issue in order to be able to migrate to this official package, any help is greatly appreciated.

Reproduction

Please see description.

auth0_flutter version

1.1.0

Flutter version

3.7.6

Platform

Android

Platform version(s)

13

Widcket commented 1 year ago

Hi @guy-plentific, thanks for raising this. @poovamraj could you please take a look?

poovamraj commented 1 year ago

@guy-plentific The best way to go ahead would be to follow the instruction from our Auth0.Android SDK Basically you can override your manifest file to receive callback from multiple domains to open back the SDK. You can check the solution here - https://github.com/auth0/auth0.android/blob/main/FAQ.md#2-why-do-i-need-to-declare-manifest-placeholders-for-the-auth0-domain-and-scheme

guy-plentific commented 1 year ago

@poovamraj Many thanks for such a fast response! I have been able to override the manifest file and add multiple intent filters, one for each of our domains - it is now working as expected :)

Please consider updating the documentation/FAQs with instructions on how to support multiple domains in Android, possibly with an example of this being done.

guy-plentific commented 1 year ago

For anyone facing the same problem, here is an example of what we added to our Android manifest:

<!-- The following activity enables redirection from Auth0 web view and is required for auth0_flutter package -->
        <activity
            android:name="com.auth0.android.provider.RedirectActivity"
            android:exported="true"
            tools:node="replace">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <!-- Staging EU -->
                <data
                    android:host="xyz-staging.eu.auth0.com"
                    android:pathPrefix="/android/${applicationId}/callback"
                    android:scheme="com.plentific.xyz" />
                <!-- Staging US -->
                <data
                    android:host="xyz-us-staging.us.auth0.com"
                    android:pathPrefix="/android/${applicationId}/callback"
                    android:scheme="com.plentific.xyz" />
                <!-- Production EU -->
                <data
                    android:host="xyz.eu.auth0.com"
                    android:pathPrefix="/android/${applicationId}/callback"
                    android:scheme="com.plentific.xyz" />
                <!-- Production US -->
                <data
                    android:host="xyz-us.us.auth0.com"
                    android:pathPrefix="/android/${applicationId}/callback"
                    android:scheme="com.plentific.xyz" />
            </intent-filter>
        </activity>
ChrisOgden commented 1 year ago

@guy-plentific Was there an equivalent change you needed to make for iOS as well?

guy-plentific commented 1 year ago

@guy-plentific Was there an equivalent change you needed to make for iOS as well?

No there wasn't; iOS was straightforward to setup by following the package documentation.

youssefAbid commented 8 months ago

I am facing probebly the same issue but the diffrence is thate each cutomer will have it's own domain and scheema. is it possible some how to override that data base on an external file ?

the application will be downloaded from the appStore/playstore each customer have it's own domain and scheema

is there any solution @guy-plentific @poovamraj @ChrisOgden @Widcket ?

guy-plentific commented 8 months ago

I am facing probebly the same issue but the diffrence is thate each cutomer will have it's own domain and scheema. is it possible some how to override that data base on an external file ?

the application will be downloaded from the appStore/playstore each customer have it's own domain and scheema

is there any solution @guy-plentific @poovamraj @ChrisOgden @Widcket ?

I don't think this will be possible at runtime. I believe you will have to release an updated app version with new info in the manifest each time there is a new customer.

ChrisOgden commented 8 months ago

I am facing probebly the same issue but the diffrence is thate each cutomer will have it's own domain and scheema. is it possible some how to override that data base on an external file ? the application will be downloaded from the appStore/playstore each customer have it's own domain and scheema is there any solution @guy-plentific @poovamraj @ChrisOgden @Widcket ?

I don't think this will be possible at runtime. I believe you will have to release an updated app version with new info in the manifest each time there is a new customer.

@youssefAbid I would agree with @guy-plentific here based on my understanding. A small version bump in the app store shouldn't be too much of an issue for users though.

youssefAbid commented 8 months ago

Thank you very much @guy-plentific @ChrisOgden that was helpful!

simon-zhangmuye commented 7 months ago

Hello everyone, my company has many clients who are using Auth0, and we want to link all users to one application. However, currently, we can only do this by configuring all the user information in the AndroidManifest.xml. If we need to add a new client, we must update the entire application. This brings great inconvenience to our users. So, I would like to ask if there is a way to dynamically add domains. For example, by obtaining all the domain information through an API when the application loads?