Skip to content

Commit fc88945

Browse files
Update dependencies and enhance webAuth methods to support HTTPS (#1125)
Co-authored-by: Rita Zerrizuela <[email protected]>
1 parent 2871241 commit fc88945

File tree

11 files changed

+164
-43
lines changed

11 files changed

+164
-43
lines changed

.snyk

+13-13
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ ignore:
55
SNYK-JS-INFLIGHT-6095116:
66
- '*':
77
reason: No fix available
8-
expires: 2025-04-12T09:15:05.191Z
8+
expires: 2025-05-12T09:15:05.191Z
99
created: 2025-02-02T05:47:18.380Z
1010
SNYK-JS-BABELHELPERS-9397697:
1111
- '*':
1212
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
13-
expires: 2025-04-12T09:15:05.191Z
13+
expires: 2025-05-12T09:15:05.191Z
1414
created: 2025-03-12T09:15:05.191Z
1515
SNYK-JS-IMAGESIZE-9634164:
1616
- '*':
@@ -20,56 +20,56 @@ ignore:
2020
snyk:lic:npm:lightningcss-win32-x64-msvc:MPL-2.0:
2121
- '*':
2222
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
23-
expires: 2025-04-12T09:15:05.191Z
23+
expires: 2025-05-12T09:15:05.191Z
2424
created: 2025-03-12T09:15:05.191Z
2525
snyk:lic:npm:lightningcss-linux-x64-musl:MPL-2.0:
2626
- '*':
2727
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
28-
expires: 2025-04-12T09:15:05.191Z
28+
expires: 2025-05-12T09:15:05.191Z
2929
created: 2025-03-12T09:15:05.191Z
3030
snyk:lic:npm:lightningcss-linux-x64-gnu:MPL-2.0:
3131
- '*':
3232
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
33-
expires: 2025-04-12T09:15:05.191Z
33+
expires: 2025-05-12T09:15:05.191Z
3434
created: 2025-03-12T09:15:05.191Z
3535
snyk:lic:npm:lightningcss-linux-arm64-musl:MPL-2.0:
3636
- '*':
3737
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
38-
expires: 2025-04-12T09:15:05.191Z
38+
expires: 2025-05-12T09:15:05.191Z
3939
created: 2025-03-12T09:15:05.191Z
4040
snyk:lic:npm:lightningcss-linux-arm64-gnu:MPL-2.0:
4141
- '*':
4242
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
43-
expires: 2025-04-12T09:15:05.191Z
43+
expires: 2025-05-12T09:15:05.191Z
4444
created: 2025-03-12T09:15:05.191Z
4545
snyk:lic:npm:lightningcss-linux-arm-gnueabihf:MPL-2.0:
4646
- '*':
4747
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
48-
expires: 2025-04-12T09:15:05.191Z
48+
expires: 2025-05-12T09:15:05.191Z
4949
created: 2025-03-12T09:15:05.191Z
5050
snyk:lic:npm:lightningcss-freebsd-x64:MPL-2.0:
5151
- '*':
5252
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
53-
expires: 2025-04-12T09:15:05.191Z
53+
expires: 2025-05-12T09:15:05.191Z
5454
created: 2025-03-12T09:15:05.191Z
5555
snyk:lic:npm:lightningcss-darwin-x64:MPL-2.0:
5656
- '*':
5757
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
58-
expires: 2025-04-12T09:15:05.191Z
58+
expires: 2025-05-12T09:15:05.191Z
5959
created: 2025-03-12T09:15:05.191Z
6060
snyk:lic:npm:lightningcss-darwin-arm64:MPL-2.0:
6161
- '*':
6262
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
63-
expires: 2025-04-12T09:15:05.191Z
63+
expires: 2025-05-12T09:15:05.191Z
6464
created: 2025-03-12T09:15:05.191Z
6565
snyk:lic:npm:lightningcss:MPL-2.0:
6666
- '*':
6767
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
68-
expires: 2025-04-12T09:15:05.191Z
68+
expires: 2025-05-12T09:15:05.191Z
6969
created: 2025-03-12T09:15:05.191Z
7070
snyk:lic:npm:lightningcss-win32-arm64-msvc:MPL-2.0:
7171
- '*':
7272
reason: This issue is temporarily ignored while we evaluate alternative dependencies or wait for an update from Expo/Metro.
73-
expires: 2025-04-12T09:15:05.191Z
73+
expires: 2025-05-12T09:15:05.191Z
7474
created: 2025-03-12T09:15:05.191Z
7575
patch: {}

A0Auth0.podspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717
s.requires_arc = true
1818

1919
s.dependency 'React-Core'
20-
s.dependency 'Auth0', '2.7.2'
21-
s.dependency 'JWTDecode', '3.1.0'
22-
s.dependency 'SimpleKeychain', '1.1.0'
20+
s.dependency 'Auth0', '2.10'
21+
s.dependency 'JWTDecode', '3.2.0'
22+
s.dependency 'SimpleKeychain', '1.2.0'
2323
end

EXAMPLES.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
- [Login using MFA with One Time Password code](#login-using-mfa-with-one-time-password-code)
99
- [Login with Passwordless](#login-with-passwordless)
1010
- [Create user in database connection](#create-user-in-database-connection)
11+
- [Using HTTPS callback URLs](#using-https-callback-urls)
1112
- [Management API (Users)](#management-api-users)
1213
- [Patch user with user_metadata](#patch-user-with-user_metadata)
1314
- [Get full user profile](#get-full-user-profile)
1415
- [Organizations](#organizations)
1516
- [Log in to an organization](#log-in-to-an-organization)
1617
- [Accept user invitations](#accept-user-invitations)
1718
- [Bot Protection](#bot-protection)
18-
- [Domain Switching](#domain-switching)
19+
- [Domain Switching](#domain-switching)
20+
- [Android](#android)
21+
- [iOS](#ios)
22+
- [Expo](#expo)
1923

2024
## Authentication API
2125

@@ -70,7 +74,9 @@ auth0.auth
7074
Custom Schemes can be used for redirecting to the React Native application after web authentication:
7175

7276
```js
73-
authorize({}, { customScheme: 'auth0' }).then(console.log).catch(console.error);
77+
authorize({}, { customScheme: 'YOUR_AUTH0_DOMAIN' })
78+
.then(console.log)
79+
.catch(console.error);
7480
```
7581

7682
### Login using MFA with One Time Password code
@@ -154,6 +160,17 @@ auth0.auth
154160
.catch(console.error);
155161
```
156162

163+
### Using HTTPS callback URLs
164+
165+
HTTPS callback URLs provide enhanced security compared to custom URL schemes. They work with Android App Links and iOS Universal Links to prevent URL scheme hijacking:
166+
167+
```js
168+
auth0.webAuth
169+
.authorize({ scope: 'openid profile email' }, { customScheme: 'https' })
170+
.then((credentials) => console.log(credentials))
171+
.catch((error) => console.log(error));
172+
```
173+
157174
## Management API (Users)
158175

159176
### Patch user with user_metadata

FAQ.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,4 @@ If you don't need SSO, consider using `ephemeral sessions` or `SFSafariViewContr
261261

262262
## 9. How can I prevent the autogenerated redirect_uri from breaking if the applicationId has mixed cases or special characters in it on Android ?
263263

264-
It is recommended to have your applicationId in lower case without special characters to prevent any mismatch with the generated redirect_uri. But in the scenario where you require your applicationId to be of mixed case, to avoid any mismatch , the user can pass a `redirectUri` whihc matches the one provided in the manage dashboard as part of the `AgentLoginOptions` property.
264+
It is recommended to have your applicationId in lower case without special characters to prevent any mismatch with the generated redirect_uri. But in the scenario where you require your applicationId to be of mixed case, to avoid any mismatch , the user can pass a `redirectUri` which matches the one provided in the manage dashboard as part of the `AgentLoginOptions` property.

README.md

+95-6
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ Take note of this value as you'll be requiring it to define the callback URLs be
103103

104104
> For more info please read the [React Native docs](https://facebook.github.io/react-native/docs/linking.html).
105105
106-
> Whenever possible, Auth0 recommends using `https` scheme with [Android App Links](https://auth0.com/docs/applications/enable-android-app-links) as a secure way to link directly to content within your app. Custom URL schemes can be subject to [client impersonation attacks](https://datatracker.ietf.org/doc/html/rfc8252#section-8.6).
107-
108106
##### Skipping the Web Authentication setup
109107

110108
If you don't plan to use Web Authentication, you will notice that the compiler will still prompt you to provide the `manifestPlaceholders` values, since the `RedirectActivity` included in this library will require them, and the Gradle tasks won't be able to run without them.
@@ -213,21 +211,112 @@ Go to the [Auth0 Dashboard](https://manage.auth0.com/#/applications), select you
213211

214212
If in addition you plan to use the log out method, you must also add these URLs to the **Allowed Logout URLs**.
215213

214+
> [!NOTE]
215+
> Whenever possible, Auth0 recommends using [Android App Links](https://developer.android.com/training/app-links) and [Apple Universal Links](https://developer.apple.com/documentation/xcode/allowing-apps-and-websites-to-link-to-your-content) for your callback and logout URLs. Custom URL schemes can be subject to [client impersonation attacks](https://datatracker.ietf.org/doc/html/rfc8252#section-8.6).
216+
>
217+
> 💡 If your Android app is using [product flavors](https://developer.android.com/studio/build/build-variants#product-flavors), you might need to specify different manifest placeholders for each flavor.
218+
216219
#### Android
217220

221+
##### Custom Scheme
222+
223+
```text
224+
{YOUR_APP_PACKAGE_NAME}.auth0://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
225+
```
226+
227+
##### App Link (Recommended):
228+
218229
```text
219-
{YOUR_APP_PACKAGE_NAME}.auth0://{AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
230+
https://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback
231+
```
232+
233+
> Replace {YOUR_APP_PACKAGE_NAME} and {YOUR_AUTH0_DOMAIN} with your actual application package name and Auth0 domain. Ensure that {YOUR_APP_PACKAGE_NAME} is all lowercase.
234+
235+
To enable App Links, set the `auth0Scheme` to `https` in your `build.gradle` file.
236+
237+
```text
238+
android {
239+
defaultConfig {
240+
manifestPlaceholders = [auth0Domain: "@string/com_auth0_domain", auth0Scheme: "https"]
241+
}
242+
}
220243
```
221244

222-
> Make sure to replace {YOUR_APP_PACKAGE_NAME} and {AUTH0_DOMAIN} with the actual values for your application. The {YOUR_APP_PACKAGE_NAME} value provided should be all lower case.
245+
This configuration ensures that your app uses https for the callback URL scheme, which is required for Android App Links.
246+
247+
#### Enable Android App Links Support
248+
249+
[Android App Links](https://developer.android.com/training/app-links) allow an application to designate itself as the default handler of a given type of link. For example, clicking a URL in an email would open the link in the designated application. This guide will show you how to enable Android App links support for your Auth0-registered application using Auth0's Dashboard.
250+
251+
1. Go to [Auth0 Dashboard > Applications > Applications](https://manage.auth0.com/#/applications), and select the name of the application to view.
252+
253+
2. Scroll to the bottom of the Settings page, and select **Show Advanced Settings**.
254+
3. Select Device Settings, provide the [App Package Name and](https://developer.android.com/studio/build/application-id) the SHA256 fingerprints of your app’s signing certificate for your Android application, and select Save Changes.
255+
![android-app-link](assets/android-app-link.png)
256+
257+
> You can use the following command to generate the fingerprint using the Java keytool in your terminal: `keytool -list -v -keystore my-release-key.keystore`
258+
259+
To learn more about signing certificates, see Android's [Sign Your App](https://developer.android.com/studio/publish/app-signing.html) developer documentation.
223260

224261
#### iOS
225262

263+
##### Custom Scheme
264+
226265
```text
227-
{PRODUCT_BUNDLE_IDENTIFIER}.auth0://{AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
266+
{PRODUCT_BUNDLE_IDENTIFIER}.auth0://{YOUR_AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
228267
```
229268

230-
> Make sure to replace {PRODUCT_BUNDLE_IDENTIFIER} and {AUTH0_DOMAIN} with the actual values for your application. The {PRODUCT_BUNDLE_IDENTIFIER} value provided should be all lower case.
269+
##### Universal Link (Recommended):
270+
271+
```text
272+
https://{YOUR_AUTH0_DOMAIN}/ios/{PRODUCT_BUNDLE_IDENTIFIER}/callback
273+
```
274+
275+
> Replace `{PRODUCT_BUNDLE_IDENTIFIER}` and `{YOUR_AUTH0_DOMAIN}` with your actual product bundle identifier and Auth0 domain. Ensure that {PRODUCT_BUNDLE_IDENTIFIER} is all lowercase.
276+
277+
#### Configure an associated domain for iOS
278+
279+
> [!IMPORTANT]
280+
> This step requires a paid Apple Developer account. It is needed to use Universal Links as callback and logout URLs.
281+
> Skip this step to use a custom URL scheme instead.
282+
283+
##### Configure the Team ID and bundle identifier
284+
285+
Scroll to the end of the settings page of your Auth0 application and open **Advanced Settings > Device Settings**. In the **iOS** section, set **Team ID** to your [Apple Team ID](https://developer.apple.com/help/account/manage-your-team/locate-your-team-id/), and **App ID** to your app's bundle identifier.
286+
287+
![Screenshot of the iOS section inside the Auth0 application settings page](https://github.com/auth0/Auth0.swift/assets/5055789/7eb5f6a2-7cc7-4c70-acf3-633fd72dc506)
288+
289+
This will add your app to your Auth0 tenant's `apple-app-site-association` file.
290+
291+
##### Add the associated domain capability
292+
293+
In Xcode, go to the **Signing and Capabilities** [tab](https://developer.apple.com/documentation/xcode/adding-capabilities-to-your-app#Add-a-capability) of your app's target settings, and press the **+ Capability** button. Then select **Associated Domains**.
294+
295+
![Screenshot of the capabilities library inside Xcode](https://github.com/auth0/Auth0.swift/assets/5055789/3f7b0a70-c36c-46bf-9441-29f98724204a)
296+
297+
Next, add the following [entry](https://developer.apple.com/documentation/xcode/configuring-an-associated-domain#Define-a-service-and-its-associated-domain) under **Associated Domains**:
298+
299+
```text
300+
webcredentials:YOUR_AUTH0_DOMAIN
301+
```
302+
303+
<details>
304+
<summary>Example</summary>
305+
306+
If your Auth0 Domain were `example.us.auth0.com`, then this value would be:
307+
308+
```text
309+
webcredentials:example.us.auth0.com
310+
```
311+
312+
</details>
313+
314+
If you have a [custom domain](https://auth0.com/docs/customize/custom-domains), replace `YOUR_AUTH0_DOMAIN` with your custom domain.
315+
316+
> [!NOTE]
317+
> For the associated domain to work, your app must be signed with your team certificate **even when building for the iOS simulator**. Make sure you are using the Apple Team whose Team ID is configured in the settings page of your Auth0 application.
318+
319+
Refer to the example of [Using custom scheme for web authentication redirection](https://github.com/auth0/react-native-auth0/blob/master/EXAMPLES.md#using-custom-scheme-for-web-authentication-redirection)
231320

232321
## Next Steps
233322

assets/android-app-link.png

41.2 KB
Loading

example/ios/Podfile.lock

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
PODS:
22
- A0Auth0 (4.4.0):
3-
- Auth0 (= 2.7.2)
4-
- JWTDecode (= 3.1.0)
3+
- Auth0 (= 2.10)
4+
- JWTDecode (= 3.2.0)
55
- React-Core
6-
- SimpleKeychain (= 1.1.0)
7-
- Auth0 (2.7.2):
8-
- JWTDecode (~> 3.1)
9-
- SimpleKeychain (~> 1.1)
6+
- SimpleKeychain (= 1.2.0)
7+
- Auth0 (2.10.0):
8+
- JWTDecode (= 3.2.0)
9+
- SimpleKeychain (= 1.2.0)
1010
- boost (1.84.0)
1111
- DoubleConversion (1.1.6)
1212
- fast_float (6.1.4)
@@ -16,7 +16,7 @@ PODS:
1616
- hermes-engine (0.77.0):
1717
- hermes-engine/Pre-built (= 0.77.0)
1818
- hermes-engine/Pre-built (0.77.0)
19-
- JWTDecode (3.1.0)
19+
- JWTDecode (3.2.0)
2020
- RCT-Folly (2024.11.18.00):
2121
- boost
2222
- DoubleConversion
@@ -1619,7 +1619,7 @@ PODS:
16191619
- ReactCommon/turbomodule/bridging
16201620
- ReactCommon/turbomodule/core
16211621
- Yoga
1622-
- SimpleKeychain (1.1.0)
1622+
- SimpleKeychain (1.2.0)
16231623
- SocketRocket (0.7.1)
16241624
- Yoga (0.0.0)
16251625

@@ -1845,16 +1845,16 @@ EXTERNAL SOURCES:
18451845
:path: "../node_modules/react-native/ReactCommon/yoga"
18461846

18471847
SPEC CHECKSUMS:
1848-
A0Auth0: 1a9d69121ff2455486a2a4ddc40c4f36585e5260
1849-
Auth0: 28cb24cb19ebd51f0b07751f16d83b59f4019532
1848+
A0Auth0: c54e2b28344e08ab2387986d00f2a418044fdbf9
1849+
Auth0: 2876d0c36857422eda9cb580a6cc896c7d14cb36
18501850
boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
18511851
DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
18521852
fast_float: 06eeec4fe712a76acc9376682e4808b05ce978b6
18531853
FBLazyVector: 2bc03a5cf64e29c611bbc5d7eb9d9f7431f37ee6
18541854
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
18551855
glog: eb93e2f488219332457c3c4eafd2738ddc7e80b8
18561856
hermes-engine: 1f783c3d53940aed0d2c84586f0b7a85ab7827ef
1857-
JWTDecode: 3eaab1e06b6f4dcbdd6716aff09ba4c2104ca8b7
1857+
JWTDecode: 7dae24cb9bf9b608eae61e5081029ec169bb5527
18581858
RCT-Folly: e78785aa9ba2ed998ea4151e314036f6c49e6d82
18591859
RCTDeprecation: f5c19ebdb8804b53ed029123eb69914356192fc8
18601860
RCTRequired: 6ae6cebe470486e0e0ce89c1c0eabb998e7c51f4
@@ -1915,7 +1915,7 @@ SPEC CHECKSUMS:
19151915
ReactCodegen: c08a5113d9c9c895fe10f3c296f74c6b705a60a9
19161916
ReactCommon: 1bd2dc684d7992acbf0dfee887b89a57a1ead86d
19171917
RNScreens: b32d0d59b53acb574fa795a9343591ef4e7ab7c2
1918-
SimpleKeychain: f8707c8e97b38c6a6e687b17732afc9bcef06439
1918+
SimpleKeychain: 768cf43ae778b1c21816e94dddf01bb8ee96a075
19191919
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
19201920
Yoga: 78d74e245ed67bb94275a1316cdc170b9b7fe884
19211921

ios/A0Auth0.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ - (dispatch_queue_t)methodQueue
5151
}
5252

5353
RCT_EXPORT_METHOD(webAuth:(NSString *)scheme redirectUri:(NSString *)redirectUri state:(NSString *)state nonce:(NSString *)nonce audience:(NSString *)audience scope:(NSString *)scope connection:(NSString *)connection maxAge:(NSInteger)maxAge organization:(NSString *)organization invitationUrl:(NSString *)invitationUrl leeway:(NSInteger)leeway ephemeralSession:(BOOL)ephemeralSession safariViewControllerPresentationStyle:(NSInteger)safariViewControllerPresentationStyle additionalParameters:(NSDictionary *)additionalParameters resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
54-
[self.nativeBridge webAuthWithState:state redirectUri:redirectUri nonce:nonce audience:audience scope:scope connection:connection maxAge:maxAge organization:organization invitationUrl:invitationUrl leeway:leeway ephemeralSession:ephemeralSession safariViewControllerPresentationStyle:safariViewControllerPresentationStyle additionalParameters:additionalParameters resolve:resolve reject:reject];
54+
[self.nativeBridge webAuthWithScheme:scheme state:state redirectUri:redirectUri nonce:nonce audience:audience scope:scope connection:connection maxAge:maxAge organization:organization invitationUrl:invitationUrl leeway:leeway ephemeralSession:ephemeralSession safariViewControllerPresentationStyle:safariViewControllerPresentationStyle additionalParameters:additionalParameters resolve:resolve reject:reject];
5555
}
5656

5757
RCT_EXPORT_METHOD(webAuthLogout:(NSString *)scheme federated:(BOOL)federated redirectUri:(NSString *)redirectUri resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
58-
[self.nativeBridge webAuthLogoutWithFederated:federated redirectUri:redirectUri resolve:resolve reject:reject];
58+
[self.nativeBridge webAuthLogoutWithScheme:scheme federated:federated redirectUri:redirectUri resolve:resolve reject:reject];
5959
}
6060

6161
RCT_EXPORT_METHOD(resumeWebAuth:(NSString *)url resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {

0 commit comments

Comments
 (0)