Struggling to get Playwright to work with Azure Active Directory Conditional Access

Viewed 969

I'm working on standing up a Playwright testing framework around our front-end PHP application to prototype automated testing for our team. Our authentication is managed by Azure Active Directory with 2FA as well as Conditional Access for our devices. The problem I'm encountering is the conditional access not liking the pseudo-incognito Chromium browser used by Playwright. Below is the message I get while attempting my login in the Edge InPrivate window (same error message as Chromium):

Azure Active Directory Conditional Access

I've gone through the authentication section on Playwright's documentation as well as searching, but I'm not having any luck with getting past the conditional access issue. The failing TypeScript code I'm currently running is:

import test from "@playwright/test";
const { chromium } = require('playwright');

test('Log into Application', async () => {
    const userDataDir = '\UserData';
    const context = await chromium.launchPersistentContext(userDataDir, { headless: false });

    const page = await context.newPage();
    await page.goto('https://MyApplication.com');
    await page.pause();
})

Any help would be deeply appreciated.

1 Answers
  1. According to last bulleted point in Grant controls | Microsoft Docs.

Conditional Access cannot consider Microsoft Edge in InPrivate mode as a compliant device or an approved client app.

  1. In normal chromium browser (not in private mode ) to work,you need to install and run a supported browser, based on your operating system. If you're using Windows 10, the supported browsers include Microsoft Edge, Internet Explorer, and Google Chrome.If you're using a different operating system, you can check the complete list of supported browsers.

(Or)

  1. The error message may be because the Global admin was created an conditional access policy in the Office 365 tenant at your company due to security reason, so only specific device registered in Azure, will be allowed to use for you. So, in that case you should talk with the "IT HelpDesk" department at your company, and you should ask them to configure and allow all browsers there.

An administrator can make use of access controls to either grant or block access to resources : Grant controls

You may need to contact the admin to raise a support ticket from the Office 365 admin center for further investigation

Reference: Troubleshooting compliance error

If you have global admin rights,You can troubleshoot unexpected sign-in outcomes related to Conditional Access using error messages and Azure AD sign-ins log.

  • You can click on more details and see the information.

  • Sign in to the Azure portal as a global administrator, security administrator, or global reader

  • Browse toAzure Active Directory > Sign-ins.

  • Find the event for the sign-in to review. Add or remove filters .

  • The Conditional Access tab will show the specific policy or policies that resulted in the sign-in interruption.

  • You can see and check basic info, device details whether registered or not and other policy details that are not compliant .

For complete details of troubleshooting. Please check this Troubleshooting | Microsoft Docs for complete details of troubleshooting.

Reference:

You Can’t Get There From Here – Vince's Server Stuff (vincecarbone.com)

Related