
User16941767811476136814 (Customer) asked a question.
Restricting Access on Mobile Browsers Using Authentication Policies
Does anyone have a creative solution for restricting access to applications on mobile browsers (as opposed to native iOS/Android Apps)? My initial thinking was using an expression. And while I can use request.userAgent to specific specific browser User Agent strings, there are too many options for individual matches.
So I was going to use request.userAgent.contains, which is references in several places, but it appears to not be supported by basic authentication policies.
Anyone thoughts on a good approach?

Updating this response for ease of access and reference:
Overview
Okta Identity Engine (OIE) authentication policy rules support custom expressions to restrict application access on mobile browsers while allowing native iOS and Android applications. Administrators can filter access based on User-Agent strings or device registration state.
Applies To
Solution
How does a regular expression restrict access?
Administrators can use the matches
function to evaluate a regular expression. This catches the majority of mobile browsers in a single line while explicitly ignoring the native application User-Agent.
Evaluate a regular expression to catch mobile browsers and ignore the native application User-Agent by using the following custom expression.
NOTE: Check the System Log to see exactly what User-Agent the native iOS or Android applications pass. Native applications often append a custom string, but if they use standard embedded WebViews, they might look identical to mobile Safari or Chrome.
Restrict access using the contains function.
As of the Okta 2025.06.1 release, OIE supports request.userAgent.contains() in custom expressions for authentication policy rules. Since contains only checks one specific string at a time, administrators must string together multiple conditions.
Target specific substrings without using regular expressions by using the following custom expression.
How does device trust restrict access?
Filtering by User-Agent is fragile because native applications frequently use embedded WebViews that spoof standard browser user agents, and OS updates can change these strings unexpectedly. Evaluating the device state provides a more robust solution.
Enforce a custom expression that requires the device to be registered via the Okta Verify application by using the following custom expression.
Administrators can combine this with policy rules to filter out casual mobile browser access. If a user tries to sign in via Mobile Safari, Okta prompts them to authenticate via Okta Verify. Restricting enrollment or requiring the native application workflow to pass the device context effectively blocks standard web browser access.