Conversation
auth0_flutter/windows/request_handlers/web_auth/login_web_auth_request_handler.cpp
Show resolved
Hide resolved
…ground execution (cherry picked from commit 021b6d9)
(cherry picked from commit aeb3f22)
* main: (96 commits) Release af-v2.0.0-beta.5 (#768) fix: Show SSOCredentials (#767) Release af-v2.0.0-beta.4 (#764) chore: Fix RL Scanner pipeline (#763) Release afpi-v2.0.0-beta.4 (#762) chore: fix symlinks (#760) feat: add ssoExchange to AuthenticationApi for Native to Web SSO (#759) build(deps-dev): bump basic-ftp from 5.0.5 to 5.2.0 in /appium-test (#751) build(deps): bump actions/download-artifact from 7.0.0 to 8.0.0 (#754) build(deps): bump actions/upload-artifact from 6 to 7 in /.github/actions/unit-tests-darwin (#755) build(deps): bump nokogiri from 1.18.9 to 1.19.1 in /auth0_flutter/example/ios (#747) feat: Implement Native to Web (#749) build(deps): bump actions/upload-artifact from 6 to 7 (#753) build(deps): bump actions/upload-artifact from 6 to 7 in /.github/actions/smoke-tests-darwin (#756) build(deps): bump minimatch in /appium-test (#757) build(deps): bump fast-xml-parser and edgedriver in /appium-test (#758) chore: Removed PR analyzer (#752) build(deps): bump aws-actions/configure-aws-credentials from 5.1.1 to 6.0.0 in /.github/actions/rl-scanner (#744) chore: updated the RL wrapper installation path (#746) Release af-v2.0.0-beta.3 (#743) ...
auth0_flutter/darwin/Classes/WebAuth/WebAuthLoginMethodHandler.swift
Outdated
Show resolved
Hide resolved
| authUrl << "&max_age=" << maxAge.value(); | ||
| } | ||
|
|
||
| for (const auto &kv : extraParams) |
There was a problem hiding this comment.
Can we filter reserved OAuth/OIDC keys out of parameters here ?
Right now callers can inject duplicate/conflicting values for SDK-owned params like nonce, state, redirect_uri, and code_challenge.
| std::string uri = readAndClearEnv(); | ||
| if (!uri.empty()) | ||
| { | ||
| if (uri.rfind(appActivationUrl, 0) != 0) |
There was a problem hiding this comment.
Should this be an exact callback URL match instead of a prefix check ?
With the current logic, a URL like auth0flutter://callbackevil?... would also pass when appActivationURL is auth0flutter://callback.
|
|
||
| // RS256 signature validation via the JWKS well-known endpoint. | ||
| // Derived from the issuer URL: issuer already has a trailing "/". | ||
| validationConfig.jwksUri = issuer + ".well-known/jwks.json"; |
There was a problem hiding this comment.
Should we derive the JWKS URL from OIDC discovery instead of building it from issuer here ?
Right now this assumes every custom issuer uses issuer + ".well-known/jwks.json".
In Auth0, this assumption is mostly correct. Can you confirm if other similar SDKs are also doing the same this ?
| } | ||
| } | ||
|
|
||
| std::string nonce = generateCodeVerifier(); |
There was a problem hiding this comment.
Do we still need to read a top-level nonce here ? I don’t think the Dart request map sends nonce as a top-level field, so this path may be unused and parameters['nonce'] seems to be the only one that can affect the Windows flow.
|
|
||
| > ⚠️ 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 application. | ||
|
|
||
| ##### Windows: Configure protocol handler |
There was a problem hiding this comment.
Should the Windows setup docs also explain how to register the auth0flutter:// protocol with Windows ?
| | SDK 3.24.0+ | Android API 21+ | iOS 14+ | macOS 11+ | | ||
| | Dart 3.5.0+ | Java 8+ | Swift 5.9+ | Swift 5.9+ | | ||
| | | | Xcode 15.x / 16.x | Xcode 15.x / 16.x | | ||
| | Flutter | Android | iOS | macOS | Windows | |
There was a problem hiding this comment.
Should we document the required vcpkg packages and CMAKE_TOOLCHAIN_FILE setup for Windows ? The new CMake file depends on them. No ?
📋 Changes
This PR adds native Windows desktop support to the
auth0_flutterSDK, enabling Auth0 Universal Login on Flutter Windows apps using the OAuth 2.0 Authorization Code Flow with PKCE. The implementation is a C++ Flutter plugin that integrates with the existing platform-interface layer without modifying the mobile (iOS/Android) code paths.New:
WindowsWebAuthenticationclassA dedicated Windows authentication class exposed via
Auth0.windowsWebAuthentication(). Unlike the mobileWebAuthenticationclass, this:redirectUrlexplicitly (no platform default exists on Windows)CredentialsManager(no Keychain/Keystore on Windows)parametersmap for Windows-specific configurationNew: Windows C++ plugin (
auth0_flutter/windows/)login_web_auth_request_handler.cpplogout_web_auth_request_handler.cppoauth_helpers.cppauth0flutter://callback pollingauth0_client.cppid_token_validator.cppid_token_signature_validator.cppjwt_util.cpptoken_decoder.cppCredentialsstructuser_profile.cpp/user_identity.cppUserProfilestructtime_util.cppurl_utils.cppwindows_utils.cppWideToUtf8,BringFlutterWindowToFrontAuthentication flow:
code_verifier(32 cryptographically random bytes viaRAND_bytes) andcode_challenge(SHA-256 via OpenSSL, base64-URL encoded)statevalue for CSRF protection/authorizeURL with all parameters RFC 3986-encodedShellExecuteAPLUGIN_STARTUP_URLenvironment variable (set by Windows when the app is launched via theauth0flutter://custom scheme) every 200 ms until the callback arrives or the timeout expiresstateto prevent CSRF; extractcodecode+code_verifierfor tokens via POST to/oauth/tokenauth_time, nonce, RS256 signature)Key design decisions:
auth0flutter://callback(kDefaultRedirectUri). TheredirectUrlsent to Auth0 may differ (e.g. an HTTPS intermediary server URL); that server is responsible for forwarding toauth0flutter://callback?code=…&state=….authTimeoutSeconds) are consumed before building the authorize URL and are not appended to it.std::threadto avoid blocking the Flutter UI thread.openidscope is always enforced even when not explicitly passed, as required by OpenID Connect.New:
vcpkg.jsondependency manifestManages C++ dependencies via vcpkg, integrating automatically with CMake through the vcpkg toolchain file set by Flutter during
flutter build windows:cpprestsdkopensslRAND_bytes(PKCE entropy), SHA-256 (code challenge), RS256 signature verification, TLSboost-system/boost-date-time/boost-regexNew: Unit tests (Google Test,
auth0_flutter/windows/test/)oauth_helpers_test.cppid_token_validator_test.cppauth_time, nonce, leeway validationjwt_util_test.cpptime_util_test.cpptoken_decoder_test.cppurl_utils_test.cppuser_identity_test.cppuser_profile_test.cppwindows_utils_test.cppWideToUtf8wide-to-UTF-8 conversionTests are compiled as a separate
auth0_flutter_testsexecutable and registered with CTest, enabled via-DAUTH0_FLUTTER_ENABLE_TESTS=ON.New: CI pipeline (
.github/workflows/main.yml)Added a
windows-testsjob that installs vcpkg dependencies, builds the test executable with CMake, and runs all C++ unit tests via CTest onwindows-latest.📎 References
🎯 Testing
Automated — C++ unit tests (Windows)
All 9 test suites pass.
Automated — Flutter unit tests (any platform)
Manual — end-to-end on Windows
Prerequisites:
auth0flutteras a custom URL scheme pointing to your app executable (via installer or registry)auth0flutter://callbackto Allowed Callback URLs in the Auth0 dashboardcd auth0_flutter/example flutter run -d windowsauth0flutter://callback?code=…&state=…To test the intermediary server pattern, point
redirectUrlat an HTTPS endpoint that reads thecodeandstatequery parameters and responds with a redirect toauth0flutter://callback?code=…&state=….