Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[decryptedResponse[@"success"] boolValue] returns 'nil' in MSIDDefaultBrokerResponseHandler #2528

Open
ryanmsmith-v opened this issue Feb 24, 2025 · 1 comment
Assignees

Comments

@ryanmsmith-v
Copy link

MSAL 1.7.0
Intune SDK 19.7.9
Xcode 15.4

I'm integrating the Intune SDK into our company's app and have run into a bug in MSAL.

On an unmanaged device or on an Intune MDM-managed device with MS Authenticator installed, Intune user enrollment is successful. However, on an unmanaged device that has MS Authenticator installed, completing the enrollment flow results in a -50000 error upon returning to the app.

Digging into the MSAL source code, I found that [decryptedResponse[@"success"] boolValue] in line 141 of MSIDDefaultBrokerResponseHandler is being evaluated as nil. The "success" value is a string, @"1", not a number. This causes the failure.

As a short-term solution, I have rewritten this to explicitly treat decryptedResponse[@"success"] as a string:

    // decryptedResponse[@"success"] is @"1"
    // [decryptedResponse[@"success"] boolValue] was returning `nil`, resulting in a failure
    // This instead explicitly converts the value to an NSNumber to get the boolean value
    BOOL success = NO;
    if (decryptedResponse[@"success"]) {
        // Make it an NSString, just in case it's something else
        NSString *successString = [NSString stringWithFormat:@"%@", decryptedResponse[@"success"]];
        if (![NSString msidIsStringNilOrBlank:successString]) {
            NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
            NSNumber *successNumber = [formatter numberFromString:successString];
            if (successNumber) {
                success = [successNumber boolValue];
            }
        }
    }
    // Successful case
    if ([NSString msidIsStringNilOrBlank:decryptedResponse[@"broker_error_domain"]]
        && success)
    {
@antonioalwan antonioalwan self-assigned this Feb 28, 2025
@antonioalwan
Copy link
Contributor

Thanks, @ryanmsmith-v, for submitting this issue. I will investigate further and update you with the outcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants