Skip to content
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

feat: added support for domain switching #931

Merged
merged 22 commits into from
Aug 2, 2024
Merged

Conversation

desusai7
Copy link
Contributor

Added support for domain switching

  • Updated the hasValidAuth0Instance method in both Android & iOS modules to check if the existing auth0 instance clientId & domain are same as the clientId & domain passed from the React Native layer and if they are different we are creating new instance of Auth0, this would enable customers to switch between different domains quickly.

  • To support multiple domains in an Android app, developers need to add intent filters to their AndroidManifest.xml file. The following code snippet demonstrates how to do this. By incorporating these changes, the default IntentFilter provided by the library is overridden, eliminating the need to specify manifestPlaceHolders in the app's build.gradle file. Simply add a <data> element within the <intent-filter> of com.auth0.android.provider.RedirectActivity for each domain you wish to accommodate.

    <activity
      android:name="com.auth0.android.provider.RedirectActivity" tools:node="replace"
      android:exported="true">
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />

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

        <data
          android:host="domain1"
          android:pathPrefix="/android/${applicationId}/callback"
          android:scheme="${applicationId}.auth0" />
        <data
          android:host="domain2"
          android:pathPrefix="/android/${applicationId}/callback"
          android:scheme="${applicationId}.auth0" />
      </intent-filter>
    </activity>

References

#747
#911

Testing

Since these changes are made on the bridge layers of both Android and iOS platforms, we do not have test setup there, so updated the sample app to use multiple domains in two different screens by default and tested it on both Android and iOS platforms.

  • This change adds unit test coverage
  • This change has been tested on the latest version of the platform/language or why not

Checklist

public void hasValidAuth0Instance(Promise promise) {
promise.resolve(this.auth0 != null && this.secureCredentialsManager != null);
public void hasValidAuth0Instance(String clientId, String domain, Promise promise) {
promise.resolve(this.auth0 != null && this.auth0.getClientId().equals(clientId) && this.auth0.getDomainUrl().contains(domain));
Copy link
Contributor

Choose a reason for hiding this comment

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

contains check needs to be reworked

poovamraj
poovamraj previously approved these changes Jul 30, 2024
poovamraj
poovamraj previously approved these changes Aug 1, 2024
desusai7 and others added 18 commits August 2, 2024 17:32
Signed-off-by: Sai Venkat Desu <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…933)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…3.0 (#920)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@desusai7 desusai7 merged commit 1aa5e70 into master Aug 2, 2024
5 checks passed
@desusai7 desusai7 deleted the feat/domain_switching branch August 2, 2024 14:52
@MAlvesKitestring
Copy link

Hey, guys! @desusai7 @poovamraj Great feature, thanks for working on it!

We are using expo, do you guys know how we could use it? Is it available through some config plugin property?

@desusai7 desusai7 mentioned this pull request Aug 5, 2024
@desusai7
Copy link
Contributor Author

desusai7 commented Aug 5, 2024

Hi @MAlvesKitestring,

We've released this just now as part of version 4.0.0-beta.0, yes, we are supporting expo as well, please check out more on it here

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.

4 participants