Add NativeAuthRequestInterceptor for custom per-request HTTP headers AB#3606613#2511
Add NativeAuthRequestInterceptor for custom per-request HTTP headers AB#3606613#2511spetrescu84 wants to merge 9 commits into
Conversation
Wire the NativeAuthRequestInterceptor through MSAL's public configuration and command parameters adapter, matching the iOS PR (microsoft-authentication-library-for-objc#2862). - Add requestInterceptor property to NativeAuthPublicClientApplicationConfiguration - Propagate interceptor in all 16 native auth CommandParametersAdapter builder calls - Update common submodule to spetrescu/custom_headers branch - Fix pre-existing duplicate .challengeType() call in createSignInResendCodeCommandParameters() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
❌ Work item link check failed. Description does not contain AB#{ID}. Click here to Learn more. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds native auth support for per-request custom HTTP headers by introducing a request interceptor on native auth configuration and propagating it into native auth command parameters.
Changes:
- Added a transient
requestInterceptorproperty toNativeAuthPublicClientApplicationConfigurationand included it in configuration merging. - Propagated
requestInterceptorthrough most native auth command parameter builders. - Removed a duplicate
challengeType()call in sign-in resend-code parameter construction.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
msal/src/main/java/com/microsoft/identity/nativeauth/NativeAuthPublicClientApplicationConfiguration.kt |
Adds the native auth request interceptor configuration field and merge behavior. |
msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java |
Passes the configured interceptor into native auth command parameter builders. |
Update comment
…/microsoft-authentication-library-for-android into spetrescu/custom_headers
|
@copilot apply changes based on the comments in this thread |
…eAuthPublicClientApplicationParameters Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-for-android/sessions/3e578494-fa53-4d9a-92cc-5f88b974f149 Co-authored-by: spetrescu84 <111577419+spetrescu84@users.noreply.github.com>
Applied both fixes in commit d6bb35a:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| .challengeType(configuration.getChallengeTypes()) | ||
| .requestInterceptor(configuration.getRequestInterceptor()) | ||
| .continuationToken(continuationToken) | ||
| .challengeType(configuration.getChallengeTypes()) |
There was a problem hiding this comment.
This was removed because it's duplicated above
Summary
Implements the Android equivalent of the iOS PR microsoft-authentication-library-for-objc#2862, enabling apps to inject custom
x-*headers into native auth HTTP requests (e.g., for CIAM fraud-signal scenarios like Akamai sensor data).Changes
MSAL (this PR)
NativeAuthPublicClientApplicationConfiguration.kt— Added@Transient var requestInterceptorproperty withmergeConfigurationsupportCommandParametersAdapter.java— PropagatedrequestInterceptorthrough all 16 native auth builder calls; fixed pre-existing duplicate.challengeType()increateSignInResendCodeCommandParameters()Common (spetrescu/custom_headers)
NativeAuthRequestInterceptor.kt— Public interface:fun additionalHeaders(requestUrl: URL): Map<String, String>?NativeAuthHeaderValidator.kt— Validates headers (must start withx-, must NOT start withx-ms-,x-client-,x-broker-,x-app-)applyInterceptorHeaders()before everyhttpClient.post()call in all 4 interactorsTesting
NativeAuthHeaderValidator(all validation scenarios)SignInInteractorRequestInterceptorTestDesign Decisions
challengeTypes/capabilitiesfor consistency@Transienton config field — set programmatically, not from JSONAB#3606613