Implement Intune MDM enrollment flow with ASWebAuth continuation#1662
Draft
Implement Intune MDM enrollment flow with ASWebAuth continuation#1662
Conversation
…tion and state machine Co-authored-by: Veena11 <9446116+Veena11@users.noreply.github.com>
IdentityCore/src/webview/embeddedWebview/MSIDAcquireBRTOnceControllerAction.h
Outdated
Show resolved
Hide resolved
Co-authored-by: Veena11 <9446116+Veena11@users.noreply.github.com>
Co-authored-by: Veena11 <9446116+Veena11@users.noreply.github.com>
Co-authored-by: Veena11 <9446116+Veena11@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add placeholder framework for special URL handling
Add placeholder framework for special URL handling in embedded WKWebView
Jan 16, 2026
Copilot
AI
changed the title
Add placeholder framework for special URL handling in embedded WKWebView
No changes needed - original PR implements special URL handling pattern
Jan 16, 2026
Copilot
AI
changed the title
No changes needed - original PR implements special URL handling pattern
Pass original URL to resolver helper methods and add headers support for ASWebAuthenticationSession
Jan 16, 2026
Copilot
AI
changed the title
Pass original URL to resolver helper methods and add headers support for ASWebAuthenticationSession
Add placeholder framework for special URL handling in embedded WKWebView with controller-action state machine
Jan 16, 2026
Copilot
AI
changed the title
Add placeholder framework for special URL handling in embedded WKWebView with controller-action state machine
Add placeholder framework for special URL handling in embedded WKWebView with state machine architecture
Jan 16, 2026
Copilot
AI
changed the title
Add special URL handling for Intune MDM enrollment with async BRT acquisition
Implement Intune MDM enrollment special URL handling with helper pattern
Feb 2, 2026
…nsistency + remove duplicate property - Add MSIDWebviewActionTypeDismissWebview to action enum (complete action set) - Add dismissalCompletion property to MSIDWebviewAction (for post-dismiss operations like retry) - Add dismissWebviewActionWithCompletion: factory method (creates dismiss action) - Implement DismissWebview case in executeViewAction (dismisses with completion callback) - Update processSpecialURL to return DismissWebview action (not call method directly) - Retry in broker happens in action's dismissalCompletion block (proper sequencing) - Remove dismissEmbeddedWebviewIfPresent method from helper (no longer needed!) - Remove dismissEmbeddedWebviewIfPresent method from controller (no longer needed!) - Remove embeddedWebviewController property from helper (webview dismisses itself!) - Remove currentSystemWebview property from controller (duplicate - helper has it!) - Remove currentSystemWebview mirroring assignment (single source of truth in helper) - Webview now dismisses itself via action (not called from helper) - Architectural consistency: ALL 4 webview operations via actions (Load, Open, Complete, Dismiss) - Better separation: Helper returns action, webview executes, no direct dismissal calls - Eliminates property duplication between controller and helper - Code reduction: -71 lines deleted, +59 lines added = -12 lines net - Addresses user requirements: "dismiss via action" and "remove duplicate currentSystemWebview" Co-authored-by: Veena11 <9446116+Veena11@users.noreply.github.com>
Copilot
AI
changed the title
Implement Intune MDM enrollment special URL handling with helper pattern
Add special URL handling for Intune MDM enrollment with BRT acquisition and broker retry
Feb 2, 2026
Copilot stopped work on behalf of
Veena11 due to an error
February 2, 2026 20:28
Copilot stopped work on behalf of
Veena11 due to an error
February 2, 2026 20:48
Copilot stopped work on behalf of
Veena11 due to an error
February 2, 2026 21:11
Copilot stopped work on behalf of
Veena11 due to an error
February 2, 2026 21:41
Contributor
|
@copilot So our requirement is |
Copilot stopped work on behalf of
Veena11 due to an error
February 2, 2026 22:25
Copilot stopped work on behalf of
Veena11 due to an error
February 2, 2026 22:38
Copilot stopped work on behalf of
Veena11 due to an error
February 3, 2026 00:18
Copilot
AI
changed the title
Add special URL handling for Intune MDM enrollment with BRT acquisition and broker retry
Implement special URL handling for Intune MDM enrollment in interactive auth flows
Feb 3, 2026
Copilot
AI
changed the title
Implement special URL handling for Intune MDM enrollment in interactive auth flows
Add Intune MDM enrollment special URL handling with ASWebAuth support
Feb 3, 2026
…oken request never cancelled - Create MSIDEnrollmentCompletionResponse class (similar to MSIDWPJResponse pattern) - Response indicates enrollment completion from ASWebAuth (profileInstalled/profileComplete) - Carries profileCompletedURL and shouldRetryInBroker flag (platform-dependent) - Update MSIDAADWebviewFactory.oAuthResponseWithURL to create enrollment response - Detect profileInstalled/profileComplete URLs and create MSIDEnrollmentCompletionResponse - Set shouldRetryInBroker: YES on iOS, NO on macOS (platform-specific retry logic) - Add responseFactory property to MSIDOAuth2EmbeddedWebviewController - Factory set during webview creation in MSIDAADWebviewFactory - Update ASWebAuth callback handling to create response via factory - Process callback URL (msauth://profileComplete) through factory.oAuthResponseWithURL - Call webview completion handler with response (flow continues, never cancelled!) - Response flows through MSIDInteractiveTokenRequest to MSIDLocalInteractiveController - Update handleWebMSAuthResponse to check for MSIDEnrollmentCompletionResponse type - If enrollment response with shouldRetryInBroker: call retryInBrokerContext - If enrollment response without retry: complete in current context - Token request never cancelled - completion handler flows through ASWebAuth to controller - Flow continuation: embedded webview → ASWebAuth → response → controller → retry/complete - Addresses critical requirement: "Token request should NEVER get cancelled. Flow should be continuation" - Complete Intune enrollment flow now properly continues after ASWebAuth completes Co-authored-by: Veena11 <9446116+Veena11@users.noreply.github.com>
Copilot
AI
changed the title
Add Intune MDM enrollment special URL handling with ASWebAuth support
Add Intune MDM enrollment special URL handling with flow continuation
Feb 3, 2026
Co-authored-by: Veena11 <9446116+Veena11@users.noreply.github.com>
Moved MSIDEnrollmentCompletionResponse PBXFileReference entries from PBXBuildFile section to proper PBXFileReference section to maintain correct Xcode project structure.
Copilot
AI
changed the title
Add Intune MDM enrollment special URL handling with flow continuation
Implement Intune MDM enrollment flow with ASWebAuth continuation
Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements special URL handling for Intune device enrollment during interactive authentication. When Conditional Access requires MDM enrollment, the flow switches from embedded webview to ASWebAuthenticationSession for enrollment, then continues the token request without cancellation.
Core Changes
Flow Continuation via Response Pattern
MSIDEnrollmentCompletionResponseclass followingMSIDWPJResponsepatternmsauth://profileCompleteAction-Based Architecture
LoadRequest,OpenASWebAuth,CompleteWithURL,DismissWebviewMSIDWebviewActionenhanced withdismissalCompletionfor post-dismiss sequencingHelper Pattern for Code Reuse
MSIDInteractiveWebviewHelperimplements shared logic (ASWebAuth creation, header capture)isRunningInBrokerContextparameterAsync Orchestration
processSpecialURL:completion:orchestrates BRT acquisition (async), action resolution, and broker retry (async)profileInstalledon iOS (non-broker only)Wiring
webviewHandlerproperty (no retain cycles)Example Flow
Token request completion handler preserved throughout - flow never cancels.
Original prompt
Add placeholder framework for special URL handling in embedded WKWebView using a controller-action state machine and MSIDWebviewAction view actions.
Repository: AzureAD/microsoft-authentication-library-common-for-objc
Base branch: dev
Background / Motivation
We need a scaffolding (placeholders) for a new architecture to handle
msauth://andbrowser://redirects in embedded WKWebView. This design separates:MSIDWebviewAction) that the embedded webview controller executesNo production behavior changes are required in this PR; it should compile and be safe to land without enabling the new flow.
Deliverables
1) Add MSIDWebviewAction placeholder (new)
Create a minimal view-action model:
MSIDWebviewActionTypeenum (at least: Noop, LoadRequestInWebview, OpenASWebAuthenticationSession, OpenExternalBrowser, CompleteWithURL, FailWithError)MSIDSystemWebviewPurposeenum including at leastMSIDSystemWebviewPurposeInstallProfileandMSIDSystemWebviewPurposeUnknownMSIDWebviewActionclass with readonly properties:type,request,url,purpose,error+noopAction+loadRequestAction:(NSURLRequest *)request+openASWebAuthSessionAction:(NSURL *)url purpose:(MSIDSystemWebviewPurpose)purpose+openExternalBrowserAction:(NSURL *)url+completeWithURLAction:(NSURL *)url+failWithErrorAction:(NSError *)error2) Add controller-action state machine placeholders (new)
Add these new types (placeholders with documentation and minimal logic):
MSIDInteractiveWebviewStatebrtGateEncountered,brtAttempted,brtAcquiredpendingURL,queryParams,isGateScheme,isRunningInBrokerContextbrtFailurePolicyenum (Continue/Fail)transferredToBrokerMSIDInteractiveWebviewHandlerprotocol-isRunningInBrokerContext-shouldAcquireBRTForSpecialURL:state:-brtFailurePolicyForSpecialURL:state:-shouldRetryInBrokerForSpecialURL:state:-acquireBRTTokenWithCompletion:-genericBrtError-retryInteractiveRequestInBrokerContextForURL:completion:-dismissEmbeddedWebviewIfPresent-viewActionForSpecialURL:state:-handleWebviewResponseForTelemetry:MSIDInteractiveWebviewStateMachine-initWithHandler:-handleSpecialURL:navigationAction:completion:returningMSIDWebviewAction *nextControllerActionForState:selection andrunUntilStableloop.CompleteWithURLorNoopvia handler/resolver; no wiring into production code.3) Add controller action placeholders (new)
MSIDAcquireBRTOnceControllerActionacquireBRTTokenWithCompletion:once; sets state flagsMSIDRetryInBrokerControllerActionretryInteractiveRequestInBrokerContextForURL:completion:state.transferredToBroker = YESand callsdismissEmbeddedWebviewIfPresent4) Add MSIDSpecialURLViewActionResolver placeholder (new)
Add a helper that maps special URLs to
MSIDWebviewAction(placeholder semantics):msauth://enroll?cpurl=...->LoadRequestInWebview(construct request from cpurl; placeholder for headers/params)msauth://compliance?cpurl=...->LoadRequestInWebviewmsauth://installProfile?url=...&requireASWebAuthenticationSession=true->OpenASWebAuthenticationSessionwith purpose InstallProfilemsauth://profileComplete->CompleteWithURL(retry handled by controller action policy)browser://...->CompleteWithURLInclude TODO comments for:
5) Safety / Non-breaking
6) Tests (if feasible)
If the repo has an existing unit test target, add minimal tests validating:
MSIDWebviewActionconstructorsNotes
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.