Skip to content

feat(rn-externalidp): Custom social provider handler registry in rn-external-idp(SDKS-5452) - #88

Open
tsdamas wants to merge 1 commit into
mainfrom
SDKS-5452
Open

tsdamas wants to merge 1 commit into
mainfrom
SDKS-5452

Conversation

@tsdamas

@tsdamas tsdamas commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a native-only custom IdP handler registry to @ping-identity/rn-external-idp so apps can support social providers beyond the built-in apple/siwa/google/facebook set (for example LINE or WeChat). App code implements the native SDK's IdpHandler interface and registers it by provider name at startup; the Journey authorize path resolves through the registry first and falls back to the untouched native built-ins. No JS API, TurboModule, or client-configuration changes: existing selectProviderForJourney / authorizeForJourney calls route to the custom handler whenever the callback's provider value matches.

Requires native SDK 2.2.0, which is already pinned.

Changes

  • Android bridge: IdpHandlerRegistry (process-scoped ConcurrentHashMap, trimmed-lowercase keys, replace-on-re-register) and RNPingExternalIdpCommon.registerIdpHandler() for Application.onCreate. Registration rejects blank names and any name containing a reserved built-in token (apple, siwa, google, facebook, fb-limited) so a custom handler can never shadow a built-in route. com.pingidentity.sdks:external-idp moves from implementation to api scope so the native IdpHandler types resolve from app code.
  • iOS bridge: parallel NSLock-guarded registry with the same normalization and reserved-token list; registerIdpHandler(_:handler:) is Swift-only (non-@objc) because the native protocol is not @objc; IdpHandlerRegistrationError conforms to LocalizedError so reasons reach localizedDescription.
  • Redirect override: RedirectUriOverridingIdpHandler (Android; iOS reuses its existing wrapper) rewrites IdpClient.redirectUri with the JS-configured value before delegating, because native authorize() builds the client from the callback's own server-supplied redirect URI.
  • Sample app: LINE as a working reference implementation registered as line: Android LineIdpHandler + LineLoginBridge (linesdk 5.13.0), iOS LineIdpHandler (LineSDKSwift ~> 5.9, Info.plist URL schemes, open-URL wiring). New ios:build-run scripts and an Xcode 27 note in the app README.
  • PingTestRunner: StubIdpHandler (Kotlin + Swift) registered as stubprovider, proving app code can implement the interface and that import PingExternalIdP resolves transitively on iOS with no Podfile entry.
  • Tests: Android Robolectric and iOS XCTest suites covering normalization, reserved tokens, registry-miss fallback, nonce delivery, token propagation, and cancellation/failure mapping.
  • Docs: "Supporting additional social providers" section in the package README (handler contract, registration, resolution order, redirect override, threading and cancellation conventions).
  • Changeset: @ping-identity/rn-external-idp minor.

Platform notes

  • Registration is native-only and process-scoped: it happens before React boots, survives JS reloads, and must not be repeated after a dev reload.
  • Custom handlers apply to Journey only: authorizeForDaVinci does not consult the registry.
  • A registry miss keeps the pre-existing per-platform errors, now pinned by tests: Android EXTERNAL_IDP_CONFIG_ERROR (native throws IllegalArgumentException("Unsupported provider: ...")), iOS EXTERNAL_IDP_UNSUPPORTED_PROVIDER.
  • additionalParameters returned by a handler are replayed as request parameters on journey.next(), so they are server-visible; documented in the README.
  • PingTestRunner/ios/Podfile.lock contains checksum-only churn from a validation pod install (no version changes).
  • The LINE handler is validated by build and smoke only; it has not been run against a real LINE channel.

Verification

  • Formatting completed
  • Lint executed
  • Packages built
  • Type checking completed
  • JavaScript unit tests executed
  • Android native tests executed
  • iOS native tests executed
  • PingTestRunner integration tests executed
  • Sample-app smoke test completed

@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6e436e08-a268-4ec7-bbff-d84723127399
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

var handled = LoginManager.shared.application(application, open: url, options: options)
#if canImport(PingExternalIdPFacebook)
handled = FacebookHandler.handleOpenURL(application, url: url, options: options)
handled = FacebookHandler.handleOpenURL(application, url: url, options: options) || handled

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mend Code Security Check

New finding (1 of 1)

The Mend Code Security Check of your branch failed because of a External URL Access finding in this line.

SeverityVulnerability TypeCWEFileData FlowsDetected
LowExternal URL Access

CWE-676

AppDelegate.swift:161

12026-11-19 12:12am
Vulnerable Code

handled = FacebookHandler.handleOpenURL(application, url: url, options: options) || handled

Secure Code Warrior Training Material
Suppress Finding

To suppress this finding as a acceptable risk, comment:

/mend code suppress acceptable-risk 1c1229ea-1b1a-46f2-9373-9c6405bc7a23 Optional Comment

To suppress this finding as a false positive, comment:

/mend code suppress false-positive 1c1229ea-1b1a-46f2-9373-9c6405bc7a23 Optional Comment
💬 Discuss Finding

Add context or questions for the security reviewer by commenting on this issue:

/mend comment Your Message

Your message will appear in the Mend Platform for the security team to review.

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.86047% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.72%. Comparing base (be3d472) to head (a5ee319).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...l-idp/ios/Tests/RNPingExternalIdpCommonTests.swift 95.86% 11 Missing ⚠️
...gidentity/rnexternalidp/RNPingExternalIdpCommon.kt 0.00% 10 Missing ⚠️
...y/rnexternalidp/RedirectUriOverridingIdpHandler.kt 0.00% 7 Missing ⚠️

❌ Your project check has failed because the head coverage (73.72%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #88      +/-   ##
============================================
+ Coverage     72.14%   73.72%   +1.57%     
- Complexity      252      292      +40     
============================================
  Files           217      174      -43     
  Lines         26343    25102    -1241     
  Branches       1215      763     -452     
============================================
- Hits          19006    18507     -499     
+ Misses         7165     6531     -634     
+ Partials        172       64     -108     
Flag Coverage Δ
android 17.47% <37.03%> (+1.35%) ⬆️
ios 82.92% <96.52%> (+1.14%) ⬆️
javascript 98.73% <ø> (+27.07%) ⬆️
Components Coverage Δ
Bridge glue 54.41% <56.25%> (+0.52%) ⬆️
Pure logic 82.68% <97.00%> (+1.59%) ⬆️
Files with missing lines Coverage Δ
...m/pingidentity/rnexternalidp/IdpHandlerRegistry.kt 100.00% <100.00%> (ø)
packages/external-idp/ios/IdpHandlerRegistry.swift 100.00% <100.00%> (ø)
...ges/external-idp/ios/RNPingExternalIdpCommon.swift 63.73% <100.00%> (+4.87%) ⬆️
...y/rnexternalidp/RedirectUriOverridingIdpHandler.kt 0.00% <0.00%> (ø)
...gidentity/rnexternalidp/RNPingExternalIdpCommon.kt 2.05% <0.00%> (+2.05%) ⬆️
...l-idp/ios/Tests/RNPingExternalIdpCommonTests.swift 92.61% <95.86%> (+6.18%) ⬆️

... and 47 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c04d034...a5ee319. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://ForgeRock.github.io/ping-react-native-sdk/docs-preview/pr-88/

Built to branch gh-pages at 2026-11-19 00:16 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

"android": "react-native run-android",
"ios": "react-native run-ios",
"ios:build": "xcodebuild -workspace ios/PingSampleApp.xcworkspace -scheme PingSampleApp -configuration Debug -destination 'generic/platform=iOS Simulator' -derivedDataPath ios/build build",
"ios:install": "xcrun simctl install booted ios/build/Build/Products/Debug-iphonesimulator/PingSampleApp.app && xcrun simctl launch booted com.pingidentity.rnsampleapp.oidc",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice addition, this makes the Xcode 27 workflow much easier to follow. One small thing: the launch step uses com.pingidentity.rnsampleapp.oidc, but the app's PRODUCT_BUNDLE_IDENTIFIER is com.pingidentity.rnsampleapp (see project.pbxproj). The .oidc suffix only appears as a storage account string in src/clients.ts, so unless I'm missing something, simctl launch won't find an app with that ID and yarn ios:build-run will fail at the last step after a successful build and install.

Suggested change
"ios:install": "xcrun simctl install booted ios/build/Build/Products/Debug-iphonesimulator/PingSampleApp.app && xcrun simctl launch booted com.pingidentity.rnsampleapp.oidc",
"ios:install": "xcrun simctl install booted ios/build/Build/Products/Debug-iphonesimulator/PingSampleApp.app && xcrun simctl launch booted com.pingidentity.rnsampleapp",

val loginIntent = LineLoginApi.getLoginIntent(activity, channelId, params)

suspendCancellableCoroutine { continuation ->
val launcher = activity.activityResultRegistry.register(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for documenting the lifecycle limitation in the KDoc, that's really helpful for anyone copying this. One small note on the rotation case it mentions: MainActivity declares configChanges for orientation|screenSize|... in the manifest, so rotation shouldn't recreate the activity in this app. What's left is mainly the "Don't keep activities" developer option, or config changes that aren't in that list (locale, density, font scale) while the LINE UI is in the foreground. In those cases the registry callback is gone and the coroutine never resumes, so the JS promise stays pending.

Non-blocking, and perfectly fine to leave as-is for a sample. If you'd like to harden it cheaply, cancelling the continuation when the activity is destroyed would let the call fail fast instead of waiting indefinitely. It may also be worth tweaking the KDoc so it doesn't list rotation as a trigger.

options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
var handled = false
var handled = LoginManager.shared.application(application, open: url, options: options)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Small, non-blocking suggestion. LoginManager.shared.application(_:open:options:) now sees every incoming URL. In the LINE SDK (5.17.0), LoginProcess.resumeOpenURL fails the in-flight login with callbackURLSchemeNotMatching for any URL that isn't a LINE callback, so an unrelated deep link arriving while a LINE login is open would end that login. Previously unknown URLs just fell through and returned false.

It's probably rare in practice, but a cheap guard keeps LINE out of the way for other URLs:

var handled = false
if url.scheme?.hasPrefix("line3rdp.") == true {
  handled = LoginManager.shared.application(application, open: url, options: options)
}

(LINE also checks that the URL host is authorize, but the scheme check is enough as a pre-filter.)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants