Skip to content

Commit

Permalink
Merge pull request #1483 from AzureAD/mipetriu/consent_fix
Browse files Browse the repository at this point in the history
Read camera suppression flag from user defaults instead of global variable
  • Loading branch information
mipetriu authored Feb 26, 2025
2 parents 7ce6a77 + 4ed5518 commit ea6ed86
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 0 additions & 2 deletions IdentityCore/src/MSIDBrokerConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,3 @@ extern NSString * _Nonnull const MSID_CREATE_NEW_URL_SESSION;
extern NSString * _Nonnull const MSID_HTTP_CONNECTION_VALUE;
extern NSString * _Nonnull const MSID_FORCE_REFRESH_KEY;

extern BOOL MSID_SUPPRESS_CAMERA_CONSENT_PROMPT_IN_WEBVIEW;

3 changes: 0 additions & 3 deletions IdentityCore/src/MSIDBrokerConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,3 @@
// Http header
NSString *const MSID_HTTP_CONNECTION = @"Connection";
NSString *const MSID_HTTP_CONNECTION_VALUE = @"close";

// Non-constant
BOOL MSID_SUPPRESS_CAMERA_CONSENT_PROMPT_IN_WEBVIEW = NO;
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ @implementation MSIDOAuth2EmbeddedWebviewController
#endif
}

#if AD_BROKER
NSString *const SSO_EXTENSION_USER_DEFAULTS_KEY = @"group.com.microsoft.azureauthenticator.sso";
NSString *const CAMERA_CONSENT_PROMPT_SUPPRESS_KEY = @"Microsoft.Broker.Feature.sdm_suppress_camera_consent";
#endif

- (id)initWithStartURL:(NSURL *)startURL
endURL:(NSURL *)endURL
webview:(WKWebView *)webview
Expand Down Expand Up @@ -484,21 +489,29 @@ - (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavig
}
}

#if AD_BROKER
- (void) webView:(WKWebView *)webView
requestMediaCapturePermissionForOrigin:(WKSecurityOrigin *)origin
initiatedByFrame:(WKFrameInfo *)frame
type:(WKMediaCaptureType)type
decisionHandler:(void (^)(WKPermissionDecision decision))decisionHandler API_AVAILABLE(ios(15.0), macos(12.0))
{
if (MSID_SUPPRESS_CAMERA_CONSENT_PROMPT_IN_WEBVIEW && type == WKMediaCaptureTypeCamera)
{
decisionHandler(WKPermissionDecisionGrant);
}
else

NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:SSO_EXTENSION_USER_DEFAULTS_KEY];
id cameraConsentValue = [userDefaults objectForKey:CAMERA_CONSENT_PROMPT_SUPPRESS_KEY];

if (cameraConsentValue && ([cameraConsentValue isKindOfClass:NSNumber.class] || [cameraConsentValue isKindOfClass:NSString.class]))
{
decisionHandler(WKPermissionDecisionPrompt);
if ([cameraConsentValue boolValue] && type == WKMediaCaptureTypeCamera)
{
decisionHandler(WKPermissionDecisionGrant);
return;
}
}

decisionHandler(WKPermissionDecisionPrompt);
}
#endif

#pragma mark - Loading Indicator

Expand Down

0 comments on commit ea6ed86

Please sign in to comment.