<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
System Status
Announcements
Announcements
Search
Search
Select Language
0D54z00009z0dsACAQOkta Classic EngineAuthenticationAnswered2026-10-15T16:06:29.000Z2024-01-30T20:22:28.000Z2026-10-15T16:06:28.000Z

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?


  • Paul S. (Okta, Inc.)

    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

    • Okta Identity Engine (OIE)
    • Authentication Policies
    • Custom Expressions
    • Okta FastPass

     

    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.

    1. request.userAgent.matches("(?i).*(iphone|ipad|android).*(safari|chrome).*") && !request.userAgent.matches("(?i).*(YourNativeAppIdentifier|OktaMobile).*")

    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.

    1. (request.userAgent.contains("Mobile Safari") || request.userAgent.contains("Android")) && !request.userAgent.contains("YourNativeAppIdentifier")

    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.

    1. device.profile.registered == true

    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.

    Expand Post
    Selected as Best
  • Mihai N. (Okta, Inc.)

    Hi @User16941767811476136814 (Customer)​ , Thank you for reaching out to the Okta Community! 

     

    Judging by the way you formulated the question, I assume you have reviewed currently available options, but for clarity in case anyone else in the Community is looking into this as well - unfortunately , there currently is no easy way to do this. 

    The Authentication policy configurations would allow for restricting the platform. For example: Android, iOS, Other mobile.  

     

    That being said, we’ll leave this question open in case someone else has additional insight into the matter. 

     

     

    Regards.

     

    --------------------------------

    Subscribe Today: The Okta Community is on YouTube

    Expand Post
  • Paul S. (Okta, Inc.)

    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

    • Okta Identity Engine (OIE)
    • Authentication Policies
    • Custom Expressions
    • Okta FastPass

     

    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.

    1. request.userAgent.matches("(?i).*(iphone|ipad|android).*(safari|chrome).*") && !request.userAgent.matches("(?i).*(YourNativeAppIdentifier|OktaMobile).*")

    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.

    1. (request.userAgent.contains("Mobile Safari") || request.userAgent.contains("Android")) && !request.userAgent.contains("YourNativeAppIdentifier")

    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.

    1. device.profile.registered == true

    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.

    Expand Post
    Selected as Best
This question is closed.
Loading
Restricting Access on Mobile Browsers Using Authentication Policies
Okta Support Agent (Beta)

Terms of Service

Hello! I'm the Okta Support Agent (Beta), your go-to resource for questions about Okta products. Please remember for your security and privacy, do not share any Personally Identifiable Information (PII) such as passwords, IP addresses, or other details with me.

Okta Privacy Policy and Terms of Service apply